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.

26 lines
585 B

#include "crlf.hh"
namespace pEp
std::string operator""_CRLF(const char* str, size_t length)
static const std::string CRLF{"\r\n"};
std::string ret;
ret.reserve(length + ((length+29)/30) + 2 ); // rough guess for average line length of 30.
const char* end = str + length;
// N.B.: Loop could be more optimized, but not necessary because it is only used for string literals.
for(; str != end; ++str)
if(*str == '\n')
ret += CRLF;
ret += *str;
return ret;
} // end of namespace pEp