Changed: Constification of addSlashR and removeSlashR

This commit is contained in:
kervala 2016-12-02 16:01:43 +01:00
parent 9e2ce6596d
commit e6a2df9c7a
3 changed files with 7 additions and 14 deletions

View file

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

View file

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

View file

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