add wrapper for stringpair_t

master
roker 2 years ago
parent 2a8fbafbb8
commit b8b855e075

@ -15,7 +15,7 @@ ifneq ($(MAKECMDGOALS),clean)
-include $(DEPENDS)
endif
.PHONY: install uninstall clean
.PHONY: all install uninstall clean
all: $(TARGET)

@ -1,28 +1,63 @@
#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 class Wrapper<::pEp_identity>;
template class Wrapper<::stringpair_t>;
template class Wrapper<::message>;
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

@ -6,12 +6,18 @@
#include "wrapper.hh"
#include <stdexcept>
#include <pEp/pEpEngine.h>
#include <pEp/stringpair.h>
#include <pEp/message.h>
namespace pEp
{
class EngineError : std::runtime_error
{
public:
EngineError(PEP_STATUS status, const char* message = nullptr);
};
using Identity = Wrapper<::pEp_identity>;
using StringPair = Wrapper<::stringpair_t>;

Loading…
Cancel
Save