Browse Source

implement the wrapper for certain types.

master
roker 5 months ago
parent
commit
fe88301c3b
5 changed files with 56 additions and 6 deletions
  1. +3
    -3
      Makefile
  2. +1
    -1
      src/crlf.hh
  3. +27
    -0
      src/types.cc
  4. +23
    -0
      src/types.hh
  5. +2
    -2
      src/wrapper.hh

+ 3
- 3
Makefile View File

@ -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


+ 1
- 1
src/crlf.hh View File

@ -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
- 0
src/types.cc View File

@ -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
- 0
src/types.hh View File

@ -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

+ 2
- 2
src/wrapper.hh View File

@ -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