28 return (ch >= 65 && ch <= 90);
36 return (ch >= 97 && ch <= 122);
44 return (ch >= 48 && ch <= 57);
53 for(PVecString::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){
54 vecOut.push_back(it->eraseFirstLastChar(vecChar));
205 size_t sizePatern(pattern.size());
207 if(sizePatern == 0lu || src.size() == 0lu)
return *
this;
209 size_t sizeSrc(src.size());
210 size_t beginTest(0lu), nbMatch(0lu);
211 for(
size_t i(0lu); i < sizeSrc; ++i){
212 if(src[i] == pattern[nbMatch]){
217 if(nbMatch == sizePatern){
226 out += src[beginTest];
244 size_t sizePatern(pattern.size());
246 if(sizePatern == 0lu || src.size() == 0lu || maxNbReplace == 0lu)
return *
this;
248 size_t sizeSrc(src.size());
249 size_t beginTest(0lu), nbMatch(0lu), nbReplace(0lu);
250 for(
size_t i(0lu); i < sizeSrc; ++i){
251 if(src[i] == pattern[nbMatch] && nbReplace < maxNbReplace){
256 if(nbMatch == sizePatern){
266 out += src[beginTest];
284 for(PString::const_iterator it(begin()); it != end(); ++it){
285 if(vecChar.
find(*it)){
299 return replace(
"{}", arg, 1lu);
308 if(src.size() < beginStr.size())
return false;
309 std::string::const_iterator it = src.begin();
310 std::string::const_iterator it2 = beginStr.begin();
311 while(it != src.end() && it2 != beginStr.end()){
312 if(*it != *it2){
return false;}
326 std::string::const_iterator it(str.begin());
327 while(it != str.end()){
328 if(*it == ch) nbChar++;
340 long unsigned int sizePatern(patern.size()), sizeSrc(src.size());
341 if(sizePatern == 0lu || sizeSrc == 0lu){
return 0lu;}
342 size_t nbPaternFound(0lu);
344 long unsigned int beginTest(0lu), nbMatch(0lu);
345 for(
long unsigned int i(0lu); i < sizeSrc; ++i){
346 if(src[i] == patern[nbMatch]){
351 if(nbMatch == sizePatern){
364 return nbPaternFound;
372 PString::const_iterator it = begin();
374 if(*it == ch)
return true;
385 if(size() == 0lu || listChar.size() == 0lu){
return false;}
386 bool foundChar =
false;
387 long unsigned int i(0lu), size(listChar.size());
388 while(!foundChar && i < size){
389 foundChar =
find(listChar[i]);
402 PString::const_iterator it = str1.begin();
403 PString::const_iterator it2 = other.begin();
404 while(it != str1.end() && it2 != other.end()){
421 std::vector<PString> vec;
423 for(PString::const_iterator it = begin(); it != end(); ++it){
424 if(*it != separator){
427 vec.push_back(buffer);
431 if(buffer !=
""){vec.push_back(buffer);}
440 std::vector<PString> vec;
441 if(size() != 0lu && vecSeparator.size() != 0lu){
443 for(PString::const_iterator it(begin()); it != end(); ++it){
444 if(!vecSeparator.
find(*it)){
448 vec.push_back(buffer);
453 if(buffer !=
"") vec.push_back(buffer);
466 for(std::vector<PString>::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){
467 out += comma + (*it);
480 for(PString::const_iterator it = begin(); it != end(); it++){
481 if(*it != ch) buffer += *it;
492 for(PString::const_iterator it = vecChar.begin(); it != vecChar.end(); it++){
504 bool continuer =
true;
505 PString::iterator it = buffer.begin();
507 while(it != buffer.end() && continuer){
508 if(vecChar.
find(*it)){it = buffer.erase(it);}
523 size_t nbCharToRemove(0lu);
524 PString::const_reverse_iterator it(rbegin());
525 while(vecChar.
find(*it)){
530 if(nbCharToRemove == 0lu){
533 PString buffer(substr(0, size() - nbCharToRemove));
554 if(size() == 0lu){
return false;}
558 while(i < str.size() && isUpper){
569 if(size() == 0lu){
return false;}
573 while(i < str.size() && isLower){
584 if(size() == 0lu){
return false;}
599 if(size() == 0lu){
return *
this;}
601 std::string strOut(
"");
603 long unsigned int size(str.size());
604 for(
long unsigned int i(0lu); i < size; ++i){
605 currentChar = str[i];
607 strOut += currentChar + (char)32;
609 strOut += currentChar;
619 if(size() == 0lu){
return *
this;}
621 std::string strOut(
"");
623 long unsigned int size(str.size());
624 for(
long unsigned int i(0lu); i < size; ++i){
625 currentChar = str[i];
627 strOut += currentChar + (char)32;
629 if(currentChar ==
' '){strOut +=
'_';}
630 else{strOut += currentChar;}
640 if(size() == 0lu){
return *
this;}
642 std::string strOut(
"");
644 long unsigned int size(str.size());
645 for(
long unsigned int i(0); i < size; ++i){
646 currentChar = str[i];
648 strOut += currentChar - (char)32;
650 strOut += currentChar;
660 if(size() == 0lu){
return *
this;}
662 std::string strOut(str);
663 char currentChar = strOut[0lu];
665 strOut[0lu] = currentChar + (char)32;
674 if(size() == 0lu){
return *
this;}
676 std::string strOut(str);
677 char currentChar = strOut[0lu];
679 strOut[0lu] = currentChar - (char)32;
690 if(size() == 0lu || strCharToEscape.size() == 0lu || escapeSeq.size() == 0lu){
return *
this;}
693 for(
size_t i(0lu); i < src.size(); ++i){
695 if(strCharToEscape.
find(ch)){
707 resize(other.size());
708 memcpy((
char*)data(), other.data(), other.size());
715 resize(other.size());
716 memcpy((
char*)data(), other.data(), other.size());
723 std::string tmp(*
this);
724 resize(tmp.size() + other.size());
725 memcpy((
char*)data(), tmp.data(), tmp.size());
726 memcpy((
char*)data() + tmp.size(), other.data(), other.size());
733 std::string tmp(*
this);
734 resize(tmp.size() + other.size());
735 memcpy((
char*)data(), tmp.data(), tmp.size());
736 memcpy((
char*)data() + tmp.size(), other.data(), other.size());
bool phoenix_isCharNumber(char ch)
Tels if the character is a number or not.
PString phoenix_charToString(const char *ch)
Convert a char pointer into a string (event if the char pointer is NULL)
void eraseFirstLastChar(PVecString &vecOut, const PVecString &vecStr, const PString &vecChar)
Erase first and last characters of all PString in given vector.
bool phoenix_isCharUpperCase(char ch)
Tels if the character is upper case letter.
bool phoenix_isCharLowerCase(char ch)
Tels if the character is lower case letter.
PString operator+(const PString &other1, const PString &other2)
Concatenate 2 PString together.
std::vector< PString > PVecString
PString & operator=(const PString &other)
Definition of equal operator of PString.
PString & add(const PString &other)
Add a PString to an other.
bool isLowerCase() const
Say if the given PString is in lowercase.
PString toLowerUnderscore() const
Convert std::string in lower case and space in '_'.
PString getCommonBegining(const PString &other) const
Get the common begining between the current PString and other.
virtual ~PString()
Destructeur of PString.
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
PString eraseChar(char ch) const
Erase char ch of current string.
PString format(const PString &arg) const
Replace first {} with arg.
std::vector< PString > split(char separator) const
Cut a PString on the given separator char.
PString toLower() const
Convert PString in lower case.
PString toUpper() const
Convert std::string in upper case.
PString replaceChar(const PString &vecChar, const PString &replaceStr) const
Replace characters in vecChar by replaceStr.
bool find(char ch) const
Find a char in a string.
PString firstToLower() const
Convert first letter of the PString in lower case.
PString escapeStr(const PString &strCharToEscape, const PString &escapeSeq) const
Escape given string with passed characters.
PString & operator+=(const PString &other)
Add a PString to an other.
bool isNumber() const
Say if the given PString is composed of numbers.
bool isSameBegining(const PString &beginStr) const
Say if the current PString has the same begining of beginStr.
size_t count(char ch) const
Count the number of char ch in the current PString.
PString & merge(const std::vector< PString > &vecStr, const PString &separator="")
Merge a set of PString.
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
void copyPString(const PString &other)
Copy function of PString.
void concatenatePString(const PString &other)
Concatenate a PString into the current PString.
PString eraseFirstChar(const PString &vecChar) const
Erase first char in a string.
PString()
Default constructor of PString.
bool isUpperCase() const
Say if the given PString is in uppercase.
void initialisationPString()
Initialisation function of the class PString.
PString firstToUpper() const
Convert first letter of the PString in upper case.
PString eraseLastChar(const PString &vecChar) const
Erase first and last char in a string.