mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 14:56:13 +00:00
Changed: Constification of addSlashR and removeSlashR
This commit is contained in:
parent
9e2ce6596d
commit
e6a2df9c7a
3 changed files with 7 additions and 14 deletions
|
@ -28,8 +28,8 @@ namespace NLMISC
|
||||||
{
|
{
|
||||||
|
|
||||||
// get a string and add \r before \n if necessary
|
// get a string and add \r before \n if necessary
|
||||||
std::string addSlashR (std::string str);
|
std::string addSlashR (const std::string &str);
|
||||||
std::string removeSlashR (std::string str);
|
std::string removeSlashR (const std::string &str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MaxCStringSize
|
* \def MaxCStringSize
|
||||||
|
|
|
@ -27,7 +27,7 @@ using namespace std;
|
||||||
namespace NLMISC
|
namespace NLMISC
|
||||||
{
|
{
|
||||||
|
|
||||||
string addSlashR (string str)
|
string addSlashR (const string &str)
|
||||||
{
|
{
|
||||||
string formatedStr;
|
string formatedStr;
|
||||||
// replace \n with \r\n
|
// replace \n with \r\n
|
||||||
|
@ -42,10 +42,10 @@ string addSlashR (string str)
|
||||||
return formatedStr;
|
return formatedStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string removeSlashR (string str)
|
string removeSlashR (const string &str)
|
||||||
{
|
{
|
||||||
string formatedStr;
|
string formatedStr;
|
||||||
// replace \n with \r\n
|
// remove \r
|
||||||
for (uint i = 0; i < str.size(); i++)
|
for (uint i = 0; i < str.size(); i++)
|
||||||
{
|
{
|
||||||
if (str[i] != '\r')
|
if (str[i] != '\r')
|
||||||
|
|
|
@ -196,15 +196,8 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to,
|
||||||
// we must skip the first line
|
// we must skip the first line
|
||||||
formatedBody = "\r\n";
|
formatedBody = "\r\n";
|
||||||
|
|
||||||
// replace \n with \r\n
|
// replace \n by \r\n
|
||||||
for (i = 0; i < body.size(); i++)
|
formatedBody += addSlashR(body);
|
||||||
{
|
|
||||||
if (body[i] == '\n' && i > 0 && body[i-1] != '\r')
|
|
||||||
{
|
|
||||||
formatedBody += '\r';
|
|
||||||
}
|
|
||||||
formatedBody += body[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// add attachment if any
|
// add attachment if any
|
||||||
if (!attachedFile.empty())
|
if (!attachedFile.empty())
|
||||||
|
|
Loading…
Reference in a new issue