A C++ wrapper for the basic C datatypes defined by the pEpEngine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

63 lines
1.5 KiB

#include "types.hh"
#include <pEp/status_to_string.hh> // from libpEpAdapter
/*
#include <pEp/pEpEngine.h>
#include <pEp/stringpair.h>
#include <pEp/message.h>
*/
#include <string>
namespace pEp
{
EngineError::EngineError(PEP_STATUS status, const char* message)
: std::runtime_error(
std::string{"EngineError: "}
+ (message ? '"' + std::string{message} + "\" " : std::string{} )
+ status_to_string(status)
)
{}
template<>
template<>
message* Wrapper<::message*>::_new<PEP_msg_direction, char*>(PEP_msg_direction dir, char* s)
{
message* m = new_message(dir);
if(!m)
{
throw EngineError(PEP_OUT_OF_MEMORY, "new_message()");
}
return m;
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(const char* key, const char* value)
{
stringpair_t* sp = new_stringpair(key, value);
if(!sp)
{
throw EngineError(PEP_OUT_OF_MEMORY, "new_stringpair()");
}
return sp;
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(const std::string& key, const std::string& value)
{
return Wrapper<::stringpair_t*>::_new(key.c_str(), value.c_str());
}
Message m(PEP_dir_incoming, "Foo");
StringPair sp(std::string("foo"), std::string("bar"));
template class Wrapper<::pEp_identity>;
template class Wrapper<::stringpair_t>;
template class Wrapper<::message>;
} // end of namespace pEp