You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libpEpDatatypes/src/crlf.cc

27 lines
585 B
C++

#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;
else
ret += *str;
}
return ret;
}
} // end of namespace pEp