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() < offset + sizePatern){
return size();}
209 size_t sizeSrc(src.size());
210 size_t beginTest(0lu), nbMatch(0lu);
211 for(
size_t i(offset); i < sizeSrc; ++i){
212 if(src[i] == pattern[nbMatch]){
217 if(nbMatch == sizePatern){
237 size_t indexBeginPattern(
findPatternIndex(beginPattern) + beginPattern.size());
239 if(indexBeginPattern != size() && indexEndPattern != size()){
240 return substr(indexBeginPattern, indexEndPattern - indexBeginPattern);
252 size_t sizePatern(pattern.size());
254 if(sizePatern == 0lu || src.size() == 0lu)
return *
this;
256 size_t sizeSrc(src.size());
257 size_t beginTest(0lu), nbMatch(0lu);
258 for(
size_t i(0lu); i < sizeSrc; ++i){
259 if(src[i] == pattern[nbMatch]){
264 if(nbMatch == sizePatern){
273 out += src[beginTest];
291 size_t sizePatern(pattern.size());
293 if(sizePatern == 0lu || src.size() == 0lu || maxNbReplace == 0lu)
return *
this;
295 size_t sizeSrc(src.size());
296 size_t beginTest(0lu), nbMatch(0lu), nbReplace(0lu);
297 for(
size_t i(0lu); i < sizeSrc; ++i){
298 if(src[i] == pattern[nbMatch] && nbReplace < maxNbReplace){
303 if(nbMatch == sizePatern){
313 out += src[beginTest];
331 for(PString::const_iterator it(begin()); it != end(); ++it){
332 if(vecChar.
find(*it)){
346 return replace(
"{}", arg, 1lu);
355 if(src.size() < beginStr.size())
return false;
356 std::string::const_iterator it = src.begin();
357 std::string::const_iterator it2 = beginStr.begin();
358 while(it != src.end() && it2 != beginStr.end()){
359 if(*it != *it2){
return false;}
373 std::string::const_iterator it(str.begin());
374 while(it != str.end()){
375 if(*it == ch) nbChar++;
387 long unsigned int sizePatern(patern.size()), sizeSrc(src.size());
388 if(sizePatern == 0lu || sizeSrc == 0lu){
return 0lu;}
389 size_t nbPaternFound(0lu);
391 long unsigned int beginTest(0lu), nbMatch(0lu);
392 for(
long unsigned int i(0lu); i < sizeSrc; ++i){
393 if(src[i] == patern[nbMatch]){
398 if(nbMatch == sizePatern){
411 return nbPaternFound;
419 PString::const_iterator it = begin();
421 if(*it == ch)
return true;
432 if(size() == 0lu || listChar.size() == 0lu){
return false;}
433 bool foundChar =
false;
434 long unsigned int i(0lu), size(listChar.size());
435 while(!foundChar && i < size){
436 foundChar =
find(listChar[i]);
447 if(listChar.size() == 0lu){
return "";}
449 for(PString::const_iterator it = begin(); it != end(); ++it){
450 if(listChar.
find(*it)){
464 PString::const_iterator it = str1.begin();
465 PString::const_iterator it2 = other.begin();
466 while(it != str1.end() && it2 != other.end()){
483 std::vector<PString> vec;
485 for(PString::const_iterator it = begin(); it != end(); ++it){
486 if(*it != separator){
489 vec.push_back(buffer);
493 if(buffer !=
""){vec.push_back(buffer);}
502 std::vector<PString> vec;
503 if(size() != 0lu && vecSeparator.size() != 0lu){
505 for(PString::const_iterator it(begin()); it != end(); ++it){
506 if(!vecSeparator.
find(*it)){
510 vec.push_back(buffer);
515 if(buffer !=
"") vec.push_back(buffer);
528 for(std::vector<PString>::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){
529 out += comma + (*it);
542 for(PString::const_iterator it = begin(); it != end(); it++){
543 if(*it != ch) buffer += *it;
554 for(PString::const_iterator it = vecChar.begin(); it != vecChar.end(); it++){
566 bool continuer =
true;
567 PString::iterator it = buffer.begin();
569 while(it != buffer.end() && continuer){
570 if(vecChar.
find(*it)){it = buffer.erase(it);}
585 size_t nbCharToRemove(0lu);
586 PString::const_reverse_iterator it(rbegin());
587 while(vecChar.
find(*it)){
592 if(nbCharToRemove == 0lu){
595 PString buffer(substr(0, size() - nbCharToRemove));
616 if(size() == 0lu){
return false;}
620 while(i < str.size() && isUpper){
631 if(size() == 0lu){
return false;}
635 while(i < str.size() && isLower){
646 if(size() == 0lu){
return false;}
661 if(size() == 0lu){
return *
this;}
663 std::string strOut(
"");
665 long unsigned int size(str.size());
666 for(
long unsigned int i(0lu); i < size; ++i){
667 currentChar = str[i];
669 strOut += currentChar + (char)32;
671 strOut += currentChar;
681 if(size() == 0lu){
return *
this;}
683 std::string strOut(
"");
685 long unsigned int size(str.size());
686 for(
long unsigned int i(0lu); i < size; ++i){
687 currentChar = str[i];
689 strOut += currentChar + (char)32;
691 if(currentChar ==
' '){strOut +=
'_';}
692 else{strOut += currentChar;}
702 if(size() == 0lu){
return *
this;}
704 std::string strOut(
"");
706 long unsigned int size(str.size());
707 for(
long unsigned int i(0); i < size; ++i){
708 currentChar = str[i];
710 strOut += currentChar - (char)32;
712 strOut += currentChar;
722 if(size() == 0lu){
return *
this;}
724 std::string strOut(str);
725 char currentChar = strOut[0lu];
727 strOut[0lu] = currentChar + (char)32;
736 if(size() == 0lu){
return *
this;}
738 std::string strOut(str);
739 char currentChar = strOut[0lu];
741 strOut[0lu] = currentChar - (char)32;
752 if(size() == 0lu || strCharToEscape.size() == 0lu || escapeSeq.size() == 0lu){
return *
this;}
755 for(
size_t i(0lu); i < src.size(); ++i){
757 if(strCharToEscape.
find(ch)){
769 resize(other.size());
770 memcpy((
char*)data(), other.data(), other.size());
777 resize(other.size());
778 memcpy((
char*)data(), other.data(), other.size());
785 std::string tmp(*
this);
786 resize(tmp.size() + other.size());
787 memcpy((
char*)data(), tmp.data(), tmp.size());
788 memcpy((
char*)data() + tmp.size(), other.data(), other.size());
795 std::string tmp(*
this);
796 resize(tmp.size() + other.size());
797 memcpy((
char*)data(), tmp.data(), tmp.size());
798 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.
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.