Browse Source

implement the wrapper for certain types.

master
roker 4 years ago
parent
commit
fe88301c3b
  1. 6
      Makefile
  2. 2
      src/crlf.hh
  3. 27
      src/types.cc
  4. 23
      src/types.hh
  5. 4
      src/wrapper.hh

6
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

2
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

27
src/types.cc

@ -0,0 +1,27 @@
#include "types.hh"
/*
#include <pEp/pEpEngine.h>
#include <pEp/stringpair.h>
#include <pEp/message.h>
*/
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

23
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 <pEp/pEpEngine.h>
#include <pEp/stringpair.h>
#include <pEp/message.h>
namespace pEp
{
using Identity = Wrapper<::pEp_identity>;
using StringPair = Wrapper<::stringpair_t>;
using Message = Wrapper<::message>;
} // end of namespace pEp
#endif // LIBPEPDATATYPES_TYPES_HH

4
src/wrapper.hh

@ -12,7 +12,7 @@ class Wrapper
{
public:
template<class... Args>
Wrapper(Args... args) : value{ _new(args...) } {}
Wrapper(Args... args) : value{ this->_new(args...) } {}
// no implicit copying... (yet?)
Wrapper(const Wrapper<T>&) = delete;
@ -43,7 +43,7 @@ public:
Wrapper() : value{nullptr} {}
template<class... Args>
Wrapper(Args... args) : value{ _new(args...) } {}
Wrapper(Args... args) : value{ this->_new(args...) } {}
// no implicit copying... (yet?)
Wrapper(const Wrapper<T*>&) = delete;

Loading…
Cancel
Save