Open-Systems-Pharmacology / OSPSuite.FuncParser

Function parser for numeric and logic expressions used by the Open Systems Pharmacology Suite
Other
0 stars 3 forks source link

simplify capitalize helper #48

Closed IndrajeetPatil closed 2 years ago

IndrajeetPatil commented 2 years ago

@Yuri05 I am not sure why you are heap allocating the new string.

If there is no special reason, this is a much simpler solution.

Yuri05 commented 2 years ago

I am not sure as well. 18 years old code, lol

IndrajeetPatil commented 2 years ago

It used to lower case other letters...

Just needs one extra line of code then:

#include "FuncParser/StringHelper.h"
#include <string>
#include <algorithm>

namespace FuncParserNative
{

std::string StringHelper::Capitalize (const std::string & pInString)
{
    std::string newString = pInString;
    newString[0] = toupper(pInString[0]);
    std::transform(newString.begin() + 1, newString.end(), newString.begin() + 1, ::tolower);

    return newString;
}

}//.. end "namespace FuncParserNative"
IndrajeetPatil commented 2 years ago

I think. I will make a new PR.