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));
75 if(vecStr.size() == 0lu || str ==
""){
return false;}
77 PVecString::const_iterator it(vecStr.begin());
78 while(it != vecStr.end() && isSearch){
79 isSearch = *it != str;
221 size_t sizePatern(pattern.size());
223 if(sizePatern == 0lu || src.size() < offset + sizePatern){
return size();}
225 size_t sizeSrc(src.size());
226 size_t beginTest(0lu), nbMatch(0lu);
227 for(
size_t i(offset); i < sizeSrc; ++i){
228 if(src[i] == pattern[nbMatch]){
233 if(nbMatch == sizePatern){
253 size_t indexBeginPattern(
findPatternIndex(beginPattern) + beginPattern.size());
255 if(indexBeginPattern != size() && indexEndPattern != size()){
256 return substr(indexBeginPattern, indexEndPattern - indexBeginPattern);
268 size_t sizePatern(pattern.size());
270 if(sizePatern == 0lu || src.size() == 0lu)
return *
this;
272 size_t sizeSrc(src.size());
273 size_t beginTest(0lu), nbMatch(0lu);
274 for(
size_t i(0lu); i < sizeSrc; ++i){
275 if(src[i] == pattern[nbMatch]){
280 if(nbMatch == sizePatern){
289 out += src[beginTest];
307 size_t sizePatern(pattern.size());
309 if(sizePatern == 0lu || src.size() == 0lu || maxNbReplace == 0lu)
return *
this;
311 size_t sizeSrc(src.size());
312 size_t beginTest(0lu), nbMatch(0lu), nbReplace(0lu);
313 for(
size_t i(0lu); i < sizeSrc; ++i){
314 if(src[i] == pattern[nbMatch] && nbReplace < maxNbReplace){
319 if(nbMatch == sizePatern){
329 out += src[beginTest];
347 for(PString::const_iterator it(begin()); it != end(); ++it){
348 if(vecChar.
find(*it)){
362 return replace(
"{}", arg, 1lu);
371 if(src.size() < beginStr.size())
return false;
372 std::string::const_iterator it = src.begin();
373 std::string::const_iterator it2 = beginStr.begin();
374 while(it != src.end() && it2 != beginStr.end()){
375 if(*it != *it2){
return false;}
389 std::string::const_iterator it(str.begin());
390 while(it != str.end()){
391 if(*it == ch) nbChar++;
403 long unsigned int sizePatern(patern.size()), sizeSrc(src.size());
404 if(sizePatern == 0lu || sizeSrc == 0lu){
return 0lu;}
405 size_t nbPaternFound(0lu);
407 long unsigned int beginTest(0lu), nbMatch(0lu);
408 for(
long unsigned int i(0lu); i < sizeSrc; ++i){
409 if(src[i] == patern[nbMatch]){
414 if(nbMatch == sizePatern){
427 return nbPaternFound;
435 PString::const_iterator it = begin();
437 if(*it == ch)
return true;
448 if(size() == 0lu || listChar.size() == 0lu){
return false;}
449 bool foundChar =
false;
450 long unsigned int i(0lu), size(listChar.size());
451 while(!foundChar && i < size){
452 foundChar =
find(listChar[i]);
463 if(listChar.size() == 0lu){
return "";}
465 for(PString::const_iterator it = begin(); it != end(); ++it){
466 if(listChar.
find(*it)){
480 PString::const_iterator it = str1.begin();
481 PString::const_iterator it2 = other.begin();
482 while(it != str1.end() && it2 != other.end()){
499 std::vector<PString> vec;
501 for(PString::const_iterator it = begin(); it != end(); ++it){
502 if(*it != separator){
505 vec.push_back(buffer);
509 if(buffer !=
""){vec.push_back(buffer);}
518 std::vector<PString> vec;
519 if(size() != 0lu && vecSeparator.size() != 0lu){
521 for(PString::const_iterator it(begin()); it != end(); ++it){
522 if(!vecSeparator.
find(*it)){
526 vec.push_back(buffer);
531 if(buffer !=
"") vec.push_back(buffer);
544 for(std::vector<PString>::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){
545 out += comma + (*it);
558 for(PString::const_iterator it = begin(); it != end(); it++){
559 if(*it != ch) buffer += *it;
570 for(PString::const_iterator it = vecChar.begin(); it != vecChar.end(); it++){
582 bool continuer =
true;
583 PString::iterator it = buffer.begin();
585 while(it != buffer.end() && continuer){
586 if(vecChar.
find(*it)){it = buffer.erase(it);}
601 size_t nbCharToRemove(0lu);
602 PString::const_reverse_iterator it(rbegin());
603 while(vecChar.
find(*it)){
608 if(nbCharToRemove == 0lu){
611 PString buffer(substr(0, size() - nbCharToRemove));
632 if(size() == 0lu){
return false;}
636 while(i < str.size() && isUpper){
647 if(size() == 0lu){
return false;}
651 while(i < str.size() && isLower){
662 if(size() == 0lu){
return false;}
677 if(size() == 0lu){
return *
this;}
679 std::string strOut(
"");
681 long unsigned int size(str.size());
682 for(
long unsigned int i(0lu); i < size; ++i){
683 currentChar = str[i];
685 strOut += currentChar + (char)32;
687 strOut += currentChar;
697 if(size() == 0lu){
return *
this;}
699 std::string strOut(
"");
701 long unsigned int size(str.size());
702 for(
long unsigned int i(0lu); i < size; ++i){
703 currentChar = str[i];
705 strOut += currentChar + (char)32;
707 if(currentChar ==
' '){strOut +=
'_';}
708 else{strOut += currentChar;}
718 if(size() == 0lu){
return *
this;}
720 std::string strOut(
"");
722 long unsigned int size(str.size());
723 for(
long unsigned int i(0); i < size; ++i){
724 currentChar = str[i];
726 strOut += currentChar - (char)32;
728 strOut += currentChar;
738 if(size() == 0lu){
return *
this;}
740 std::string strOut(str);
741 char currentChar = strOut[0lu];
743 strOut[0lu] = currentChar + (char)32;
752 if(size() == 0lu){
return *
this;}
754 std::string strOut(str);
755 char currentChar = strOut[0lu];
757 strOut[0lu] = currentChar - (char)32;
768 if(size() == 0lu || strCharToEscape.size() == 0lu || escapeSeq.size() == 0lu){
return *
this;}
771 for(
size_t i(0lu); i < src.size(); ++i){
773 if(strCharToEscape.
find(ch)){
785 resize(other.size());
786 memcpy((
char*)data(), other.data(), other.size());
793 resize(other.size());
794 memcpy((
char*)data(), other.data(), other.size());
801 std::string tmp(*
this);
802 resize(tmp.size() + other.size());
803 memcpy((
char*)data(), tmp.data(), tmp.size());
804 memcpy((
char*)data() + tmp.size(), other.data(), other.size());
811 std::string tmp(*
this);
812 resize(tmp.size() + other.size());
813 memcpy((
char*)data(), tmp.data(), tmp.size());
814 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)
bool findInVectorString(const PVecString &vecStr, const PString &str)
Find a string in a vector of string.
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.
size_t findPatternIndex(const PString &pattern, size_t offset=0lu) const
Get the index of the first character of the given pattern.
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 keepChar(const PString &listChar) const
Keep only the characters in the given listChar.
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 getBetweenDelimiter(const PString &beginPattern, const PString &endPattern) const
Get the PString between delimiter.
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.