ProteoWizard
Namespaces | Macros | Functions
cpp_cli_utilities.hpp File Reference
#include <gcroot.h>
#include <vcclr.h>
#include <comdef.h>
#include <vector>
#include <string>
#include <stdexcept>
#include <boost/algorithm/string/split.hpp>
#include <boost/range/algorithm/copy.hpp>
#include "automation_vector.h"

Go to the source code of this file.

Namespaces

 pwiz
 
 pwiz::util
 

Macros

#define CATCH_AND_FORWARD
 forwards managed exception to unmanaged code; prepends function with a single level of scope, e.g. More...
 

Functions

std::string pwiz::util::ToStdString (System::String^ source)
 
System::String pwiz::util::ToSystemString (const std::string &source, bool utf8=true)
 
template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToStdVector (cli::array< managed_value_type >^ managedArray, std::vector< native_value_type > &stdVector)
 
template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToStdVector (System::Collections::Generic::IList< managed_value_type >^ managedList, std::vector< native_value_type > &stdVector)
 
template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToAutomationVector (cli::array< managed_value_type >^ managedArray, automation_vector< native_value_type > &automationArray)
 wraps a managed array in an automation_vector to enable direct access from unmanaged code More...
 

Macro Definition Documentation

§ CATCH_AND_FORWARD

#define CATCH_AND_FORWARD
Value:
catch (std::exception&) {throw;} \
catch (_com_error& e) {throw std::runtime_error(string("COM error: ") + e.ErrorMessage());} \
/*catch (CException* e) {std::auto_ptr<CException> exceptionDeleter(e); char message[1024]; e->GetErrorMessage(message, 1024); throw std::runtime_error(string("MFC error: ") + message);}*/ \
catch (System::Exception^ e) \
{ \
std::vector<boost::iterator_range<std::string::const_iterator> > tokens; \
std::string function(__FUNCTION__); \
boost::algorithm::split(tokens, function, boost::is_any_of(":"), boost::algorithm::token_compress_on); \
std::string what("["); \
if (tokens.size() > 1) \
{ \
boost::range::copy(*(tokens.rbegin()+1), std::back_inserter(what)); \
what += "::"; \
if (boost::range::equal(*(tokens.rbegin()+1), *tokens.rbegin())) \
what += "ctor"; \
else if (tokens.rbegin()->front() == '~') \
what += "dtor"; \
else \
boost::range::copy(*tokens.rbegin(), std::back_inserter(what)); \
} \
else if (tokens.size() > 0) \
boost::range::copy(*tokens.rbegin(), std::back_inserter(what)); \
what += "] "; \
what += pwiz::util::ToStdString(e->Message); \
throw std::runtime_error(what); \
}
std::string ToStdString(System::String^ source)

forwards managed exception to unmanaged code; prepends function with a single level of scope, e.g.

"Reader::read()" instead of "pwiz::data::msdata::Reader::read()"

Definition at line 116 of file cpp_cli_utilities.hpp.