From fe88301c3b23b609271e5d6ab9c7553d31accbdd Mon Sep 17 00:00:00 2001 From: roker Date: Thu, 3 Jun 2021 23:10:09 +0200 Subject: [PATCH] implement the wrapper for certain types. --- Makefile | 6 +++--- src/crlf.hh | 2 +- src/types.cc | 27 +++++++++++++++++++++++++++ src/types.hh | 23 +++++++++++++++++++++++ src/wrapper.hh | 4 ++-- 5 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 src/types.cc create mode 100644 src/types.hh diff --git a/Makefile b/Makefile index 6553db7..8c6a58a 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ all: src src: $(MAKE) -C src -#test: src -# $(MAKE) -C test +test: src + $(MAKE) -C test clean: $(MAKE) -C src clean -# $(MAKE) -C test clean + $(MAKE) -C test clean install: $(MAKE) -C src install diff --git a/src/crlf.hh b/src/crlf.hh index 8b1b383..bd4771a 100644 --- a/src/crlf.hh +++ b/src/crlf.hh @@ -11,7 +11,7 @@ namespace pEp // creates a string where \n ("linefeed" a.k.a. LF) are replaced // by \r\n ("carriage return + linefeed" a.k.a. CRLF). // Useful to define strings in NET-ASCII or Net-Unicode (RFC5198) format - // from string literals. + // from string literals. std::string operator""_CRLF(const char* str, size_t length); } // end of namespace pEp diff --git a/src/types.cc b/src/types.cc new file mode 100644 index 0000000..4567283 --- /dev/null +++ b/src/types.cc @@ -0,0 +1,27 @@ +#include "types.hh" + +/* +#include +#include +#include +*/ + +namespace pEp +{ + + template class Wrapper<::pEp_identity>; + template class Wrapper<::stringpair_t>; + + template class Wrapper<::message>; + + template<> + message* Wrapper<::message>::_new(PEP_msg_direction dir, char* s) + { + message* m = new_message(dir); + return m; + } + + + Message m(PEP_dir_incoming, "Foo"); + +} // end of namespace pEp diff --git a/src/types.hh b/src/types.hh new file mode 100644 index 0000000..b8148b4 --- /dev/null +++ b/src/types.hh @@ -0,0 +1,23 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPDATATYPES_TYPES_HH +#define LIBPEPDATATYPES_TYPES_HH + +#include "wrapper.hh" + +#include +#include +#include + +namespace pEp +{ + + using Identity = Wrapper<::pEp_identity>; + using StringPair = Wrapper<::stringpair_t>; + + using Message = Wrapper<::message>; + +} // end of namespace pEp + +#endif // LIBPEPDATATYPES_TYPES_HH diff --git a/src/wrapper.hh b/src/wrapper.hh index 327ea56..2bc9478 100644 --- a/src/wrapper.hh +++ b/src/wrapper.hh @@ -12,7 +12,7 @@ class Wrapper { public: template - Wrapper(Args... args) : value{ _new(args...) } {} + Wrapper(Args... args) : value{ this->_new(args...) } {} // no implicit copying... (yet?) Wrapper(const Wrapper&) = delete; @@ -43,7 +43,7 @@ public: Wrapper() : value{nullptr} {} template - Wrapper(Args... args) : value{ _new(args...) } {} + Wrapper(Args... args) : value{ this->_new(args...) } {} // no implicit copying... (yet?) Wrapper(const Wrapper&) = delete;