string doc
This commit is contained in:
@@ -1,348 +0,0 @@
|
|||||||
#include "pip.h"
|
|
||||||
|
|
||||||
void _() {
|
|
||||||
|
|
||||||
//! [PIString(char * )]
|
|
||||||
PIString s("string");
|
|
||||||
//! [PIString(char * )]
|
|
||||||
//! [PIString(wchar_t * )]
|
|
||||||
PIString s(L"string");
|
|
||||||
//! [PIString(wchar_t * )]
|
|
||||||
//! [PIString(char * , int)]
|
|
||||||
PIString s("string", 3); // s = "str"
|
|
||||||
//! [PIString(char * , int)]
|
|
||||||
//! [PIString(int, char)]
|
|
||||||
PIString s(5, 'p'); // s = "ppppp"
|
|
||||||
//! [PIString(int, char)]
|
|
||||||
//! [PIString(int, PIChar)]
|
|
||||||
PIString s(5, "№"); // s = "№№№№№"
|
|
||||||
//! [PIString(int, PIChar)]
|
|
||||||
//! [PIString::char*]
|
|
||||||
PIString s("pip");
|
|
||||||
cout << (char*)s << endl; // pip
|
|
||||||
//! [PIString::char*]
|
|
||||||
//! [PIString::<<(PIString)]
|
|
||||||
PIString s("this"), s1(" is"), s2(" string");
|
|
||||||
s << s1 << s2; // s = "this is string"
|
|
||||||
//! [PIString::<<(PIString)]
|
|
||||||
//! [PIString::<<(PIChar)]
|
|
||||||
PIString s("stri");
|
|
||||||
s << PIChar('n') << PIChar('g'); // s = "string"
|
|
||||||
//! [PIString::<<(PIChar)]
|
|
||||||
//! [PIString::<<(char * )]
|
|
||||||
PIString s("this");
|
|
||||||
s << " is" << " string"; // s = "this is string"
|
|
||||||
//! [PIString::<<(char * )]
|
|
||||||
//! [PIString::<<(wchar_t * )]
|
|
||||||
PIString s;
|
|
||||||
s << L"№ -" << " number"; // s = "№ - number"
|
|
||||||
//! [PIString::<<(wchar_t * )]
|
|
||||||
//! [PIString::<<(int)]
|
|
||||||
PIString s("ten - ");
|
|
||||||
s << 10; // s = "ten - 10"
|
|
||||||
//! [PIString::<<(int)]
|
|
||||||
//! [PIString::mid]
|
|
||||||
PIString s("0123456789");
|
|
||||||
piCout << s.mid(-2, -1); // s = "0123456789"
|
|
||||||
piCout << s.mid(-2, 4); // s = "01"
|
|
||||||
piCout << s.mid(3, -1); // s = "3456789"
|
|
||||||
piCout << s.mid(3, 4); // s = "3456"
|
|
||||||
//! [PIString::mid]
|
|
||||||
//! [PIString::left]
|
|
||||||
PIString s("0123456789");
|
|
||||||
piCout << s.left(-1); // s = ""
|
|
||||||
piCout << s.left(1); // s = "0"
|
|
||||||
piCout << s.left(5); // s = "01234"
|
|
||||||
piCout << s.left(15); // s = "0123456789"
|
|
||||||
//! [PIString::left]
|
|
||||||
//! [PIString::right]
|
|
||||||
PIString s("0123456789");
|
|
||||||
piCout << s.right(-1); // s = ""
|
|
||||||
piCout << s.right(1); // s = "9"
|
|
||||||
piCout << s.right(5); // s = "56789"
|
|
||||||
piCout << s.right(15); // s = "0123456789"
|
|
||||||
//! [PIString::right]
|
|
||||||
//! [PIString::cutMid]
|
|
||||||
PIString s("0123456789");
|
|
||||||
s.cutMid(1, 3);
|
|
||||||
piCout << s; // s = "0456789"
|
|
||||||
s.cutMid(-1, 3);
|
|
||||||
piCout << s; // s = "56789"
|
|
||||||
s.cutMid(3, -1);
|
|
||||||
piCout << s; // s = "567"
|
|
||||||
//! [PIString::cutMid]
|
|
||||||
//! [PIString::cutLeft]
|
|
||||||
PIString s("0123456789");
|
|
||||||
s.cutLeft(1);
|
|
||||||
piCout << s; // s = "123456789"
|
|
||||||
s.cutLeft(3);
|
|
||||||
piCout << s; // s = "456789"
|
|
||||||
s.cutLeft(30);
|
|
||||||
piCout << s; // s = ""
|
|
||||||
//! [PIString::cutLeft]
|
|
||||||
//! [PIString::cutRight]
|
|
||||||
PIString s("0123456789");
|
|
||||||
s.cutRight(1);
|
|
||||||
piCout << s; // s = "012345678"
|
|
||||||
s.cutRight(3);
|
|
||||||
piCout << s; // s = "012345"
|
|
||||||
s.cutRight(30);
|
|
||||||
piCout << s; // s = ""
|
|
||||||
//! [PIString::cutRight]
|
|
||||||
//! [PIString::trim]
|
|
||||||
PIString s(" string ");
|
|
||||||
s.trim();
|
|
||||||
piCout << s; // s = "string"
|
|
||||||
//! [PIString::trim]
|
|
||||||
//! [PIString::trimmed]
|
|
||||||
PIString s(" string ");
|
|
||||||
piCout << s.trimmed(); // s = "string"
|
|
||||||
piCout << s; // s = " string "
|
|
||||||
//! [PIString::trimmed]
|
|
||||||
//! [PIString::replace_0]
|
|
||||||
PIString s("0123456789");
|
|
||||||
s.replace(2, 3, "_cut_");
|
|
||||||
piCout << s; // s = "01_cut_56789"
|
|
||||||
s.replace(0, 1, "one_");
|
|
||||||
piCout << s; // s = "one_1_cut_56789"
|
|
||||||
//! [PIString::replace_0]
|
|
||||||
//! [PIString::replaced_0]
|
|
||||||
PIString s("0123456789");
|
|
||||||
piCout << s.replaced(2, 3, "_cut_"); // s = "01_cut_56789"
|
|
||||||
piCout << s.replaced(0, 1, "one_"); // s = "one_123456789"
|
|
||||||
//! [PIString::replaced_0]
|
|
||||||
//! [PIString::replace_1]
|
|
||||||
PIString s("pip string");
|
|
||||||
bool ok;
|
|
||||||
s.replace("string", "conf", &ok);
|
|
||||||
piCout << s << ok; // s = "pip conf", true
|
|
||||||
s.replace("PIP", "PlInPr", &ok);
|
|
||||||
piCout << s << ok; // s = "pip conf", false
|
|
||||||
//! [PIString::replace_1]
|
|
||||||
//! [PIString::replaced_1]
|
|
||||||
PIString s("pip string");
|
|
||||||
bool ok;
|
|
||||||
piCout << s.replace("string", "conf", &ok); // s = "pip conf", true
|
|
||||||
piCout << s.replace("PIP", "PlInPr", &ok); // s = "pip string", false
|
|
||||||
//! [PIString::replaced_1]
|
|
||||||
//! [PIString::replaceAll]
|
|
||||||
PIString s("substrings");
|
|
||||||
s.replaceAll("s", "_");
|
|
||||||
piCout << s; // s = "_ub_tring_"
|
|
||||||
//! [PIString::replaceAll]
|
|
||||||
//! [PIString::repeat]
|
|
||||||
PIString s(" :-) ");
|
|
||||||
s.repeat(3);
|
|
||||||
piCout << s; // :-) :-) :-)
|
|
||||||
//! [PIString::repeat]
|
|
||||||
//! [PIString::repeated]
|
|
||||||
PIString s(" :-) ");
|
|
||||||
piCout << s.repeated(3); // :-) :-) :-)
|
|
||||||
piCout << s; // :-)
|
|
||||||
//! [PIString::repeated]
|
|
||||||
//! [PIString::insert_0]
|
|
||||||
PIString s("pp");
|
|
||||||
s.insert(1, "i");
|
|
||||||
piCout << s; // s = "pip"
|
|
||||||
//! [PIString::insert_0]
|
|
||||||
//! [PIString::insert_1]
|
|
||||||
PIString s("pp");
|
|
||||||
s.insert(1, 'i');
|
|
||||||
piCout << s; // s = "pip"
|
|
||||||
//! [PIString::insert_1]
|
|
||||||
//! [PIString::insert_2]
|
|
||||||
PIString s("stg");
|
|
||||||
s.insert(2, "rin");
|
|
||||||
piCout << s; // s = "string"
|
|
||||||
//! [PIString::insert_2]
|
|
||||||
//! [PIString::expandRightTo]
|
|
||||||
PIString s("str");
|
|
||||||
s.expandRightTo(2, "_");
|
|
||||||
piCout << s; // s = "str"
|
|
||||||
s.expandRightTo(6, "_");
|
|
||||||
piCout << s; // s = "str___"
|
|
||||||
//! [PIString::expandRightTo]
|
|
||||||
//! [PIString::expandLeftTo]
|
|
||||||
PIString s("str");
|
|
||||||
s.expandLeftTo(2, "_");
|
|
||||||
piCout << s; // s = "str"
|
|
||||||
s.expandLeftTo(6, "_");
|
|
||||||
piCout << s; // s = "___str"
|
|
||||||
//! [PIString::expandLeftTo]
|
|
||||||
//! [PIString::reverse]
|
|
||||||
PIString s("0123456789");
|
|
||||||
s.reverse();
|
|
||||||
piCout << s; // s = "9876543210"
|
|
||||||
//! [PIString::reverse]
|
|
||||||
//! [PIString::reversed]
|
|
||||||
PIString s("0123456789");
|
|
||||||
piCout << s.reversed(); // s = "9876543210"
|
|
||||||
piCout << s; // s = "0123456789"
|
|
||||||
//! [PIString::reversed]
|
|
||||||
//! [PIString::elided]
|
|
||||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideLeft); // ..ABCDEF
|
|
||||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideCenter); // 123..DEF
|
|
||||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideRight); // 123456..
|
|
||||||
piCout << PIString("123456789ABCDEF").elided(8, 0.25); // 12..CDEF
|
|
||||||
//! [PIString::elided]
|
|
||||||
//! [PIString::lengthAscii]
|
|
||||||
piCout << PIString("0123456789").lengthAscii(); // 10
|
|
||||||
piCout << PIString("№1").lengthAscii(); // 3
|
|
||||||
//! [PIString::lengthAscii]
|
|
||||||
//! [PIString::data]
|
|
||||||
piCout << PIString("0123456789").data(); // 0123456789
|
|
||||||
piCout << PIString("№1").data(); // №1
|
|
||||||
//! [PIString::data]
|
|
||||||
//! [PIString::split]
|
|
||||||
PIString s("1 2 3");
|
|
||||||
piCout << s.split(" "); // {"1", "2", "3"}
|
|
||||||
//! [PIString::split]
|
|
||||||
//! [PIString::find]
|
|
||||||
PIString s("012345012345");
|
|
||||||
piCout << s.find("-"); // -1
|
|
||||||
piCout << s.find("3"); // 3
|
|
||||||
piCout << s.find("3", 4); // 9
|
|
||||||
piCout << s.find("3", 10); // -1
|
|
||||||
//! [PIString::find]
|
|
||||||
//! [PIString::findLast]
|
|
||||||
PIString s("012345012345");
|
|
||||||
piCout << s.find("-"); // -1
|
|
||||||
piCout << s.find("3"); // 9
|
|
||||||
piCout << s.find("3", 4); // 9
|
|
||||||
piCout << s.find("3", 10); // -1
|
|
||||||
//! [PIString::findLast]
|
|
||||||
//! [PIString::findAny]
|
|
||||||
piCout << PIString("1.str").findAny(".,:"); // 1
|
|
||||||
piCout << PIString("1,str").findAny(".,:"); // 1
|
|
||||||
piCout << PIString("1:str").findAny(".,:"); // 1
|
|
||||||
//! [PIString::findAny]
|
|
||||||
//! [PIString::findAnyLast]
|
|
||||||
piCout << PIString("str.0").findAny(".,:"); // 3
|
|
||||||
piCout << PIString("str,0").findAny(".,:"); // 3
|
|
||||||
piCout << PIString("str:0").findAny(".,:"); // 3
|
|
||||||
//! [PIString::findAnyLast]
|
|
||||||
//! [PIString::findWord]
|
|
||||||
PIString s("this is <PIP>");
|
|
||||||
piCout << s.find("this"); // 0
|
|
||||||
piCout << s.find("is"); // 5
|
|
||||||
piCout << s.find("PIP", 4); // -1
|
|
||||||
piCout << s.find("<PIP>", 10); // 8
|
|
||||||
//! [PIString::findWord]
|
|
||||||
//! [PIString::findCWord]
|
|
||||||
PIString s("this::is <PIP>");
|
|
||||||
piCout << s.find("this"); // 0
|
|
||||||
piCout << s.find("is"); // 6
|
|
||||||
piCout << s.find("PIP", 4); // 10
|
|
||||||
piCout << s.find("<PIP>", 10); // 9
|
|
||||||
//! [PIString::findCWord]
|
|
||||||
//! [PIString::toNumber]
|
|
||||||
piCout << PIString("123").toInt(); // 123
|
|
||||||
piCout << PIString("123").toInt(16); // 291
|
|
||||||
piCout << PIString("0x123").toInt(); // 291
|
|
||||||
piCout << PIString("1001").toInt(2); // 9
|
|
||||||
//! [PIString::toNumber]
|
|
||||||
//! [PIString::toFloat]
|
|
||||||
piCout << PIString("123").toFloat(); // 123
|
|
||||||
piCout << PIString("1.2E+2").toFloat(); // 120
|
|
||||||
piCout << PIString("0.01").toFloat(); // 0.01
|
|
||||||
//! [PIString::toFloat]
|
|
||||||
//! [PIString::setNumber]
|
|
||||||
PIString s;
|
|
||||||
s.setNumber(123);
|
|
||||||
piCout << s; // 123
|
|
||||||
s.setNumber(123, 16);
|
|
||||||
piCout << s; // 7B
|
|
||||||
//! [PIString::setNumber]
|
|
||||||
//! [PIString::setFloat]
|
|
||||||
PIString s;
|
|
||||||
s.setNumber(12.3);
|
|
||||||
piCout << s; // 12.3
|
|
||||||
//! [PIString::setFloat]
|
|
||||||
//! [PIString::setReadableSize]
|
|
||||||
PIString s;
|
|
||||||
s.setReadableSize(512);
|
|
||||||
piCout << s; // 512 B
|
|
||||||
s.setReadableSize(5120);
|
|
||||||
piCout << s; // 5.0 kB
|
|
||||||
s.setReadableSize(512000);
|
|
||||||
piCout << s; // 500.0 kB
|
|
||||||
s.setReadableSize(5120000);
|
|
||||||
piCout << s; // 4.8 MB
|
|
||||||
s.setReadableSize(512000000);
|
|
||||||
piCout << s; // 488.2 MB
|
|
||||||
s.setReadableSize(51200000000);
|
|
||||||
piCout << s; // 47.6 GB
|
|
||||||
//! [PIString::setReadableSize]
|
|
||||||
//! [PIString::fromNumber]
|
|
||||||
piCout << PIString::fromNumber(123); // 123
|
|
||||||
piCout << PIString::fromNumber(123, 16); // 7B
|
|
||||||
//! [PIString::fromNumber]
|
|
||||||
//! [PIString::fromFloat]
|
|
||||||
piCout << PIString::fromNumber(12.3); // 12.3
|
|
||||||
//! [PIString::fromFloat]
|
|
||||||
//! [PIString::readableSize]
|
|
||||||
piCout << PIString::readableSize(512); // 512 B
|
|
||||||
piCout << PIString::readableSize(5120); // 5.0 kB
|
|
||||||
piCout << PIString::readableSize(512000); // 500.0 kB
|
|
||||||
piCout << PIString::readableSize(5120000); // 4.8 MB
|
|
||||||
piCout << PIString::readableSize(512000000); // 488.2 MB
|
|
||||||
piCout << PIString::readableSize(51200000000); // 47.6 GB
|
|
||||||
//! [PIString::readableSize]
|
|
||||||
//! [PIString::takeSymbol]
|
|
||||||
PIString s("\t ! word");
|
|
||||||
piCout << s.takeSymbol(); // "!"
|
|
||||||
piCout << s.takeSymbol(); // "w"
|
|
||||||
piCout << s.takeSymbol(); // "o"
|
|
||||||
piCout << s; // "rd"
|
|
||||||
//! [PIString::takeSymbol]
|
|
||||||
//! [PIString::takeWord]
|
|
||||||
PIString s("some words\nnew line ");
|
|
||||||
piCout << s.takeWord(); // "some"
|
|
||||||
piCout << s.takeWord(); // "words"
|
|
||||||
piCout << s.takeWord(); // "new"
|
|
||||||
piCout << s; // " line "
|
|
||||||
//! [PIString::takeWord]
|
|
||||||
//! [PIString::takeLine]
|
|
||||||
PIString s("some words\nnew line \n\nend");
|
|
||||||
piCout << s.takeLine(); // "some words"
|
|
||||||
piCout << s.takeLine(); // "new line "
|
|
||||||
piCout << s.takeLine(); // ""
|
|
||||||
piCout << s; // "end"
|
|
||||||
//! [PIString::takeLine]
|
|
||||||
//! [PIString::takeNumber]
|
|
||||||
PIString s(" 0xFF -99 1.2E+5f 1000L");
|
|
||||||
piCout << s.takeNumber(); // "0xFF"
|
|
||||||
piCout << s.takeNumber(); // "-99"
|
|
||||||
piCout << s.takeNumber(); // "1.2E+5f"
|
|
||||||
piCout << s.takeNumber(); // "1000L"
|
|
||||||
piCout << s; // ""
|
|
||||||
//! [PIString::takeNumber]
|
|
||||||
//! [PIString::takeRange]
|
|
||||||
PIString s(" {figures{inside}}");
|
|
||||||
piCout << s.takeRange('{', '}'); // "figures{inside}"
|
|
||||||
piCout << s; // ""
|
|
||||||
s = "\"text\\\"shielded\" next";
|
|
||||||
piCout << s.takeRange('"', '"'); // "text\"shielded"
|
|
||||||
piCout << s; // " next"
|
|
||||||
//! [PIString::takeRange]
|
|
||||||
|
|
||||||
//! [PIStringList::join]
|
|
||||||
PIStringList sl("1", "2");
|
|
||||||
sl << "3";
|
|
||||||
piCout << sl.join(" < "); // 1 < 2 < 3
|
|
||||||
//! [PIStringList::join]
|
|
||||||
//! [PIStringList::removeStrings]
|
|
||||||
PIStringList sl("1", "2");
|
|
||||||
sl << "1" << "2" << "3";
|
|
||||||
piCout << sl; // {"1", "2", "1", "2", "3"}
|
|
||||||
piCout << sl.removeStrings("1"); // {"2", "2", "3"}
|
|
||||||
//! [PIStringList::removeStrings]
|
|
||||||
//! [PIStringList::removeDuplicates]
|
|
||||||
PIStringList sl("1", "2");
|
|
||||||
sl << "1" << "2" << "3";
|
|
||||||
piCout << sl; // {"1", "2", "1", "2", "3"}
|
|
||||||
piCout << sl.removeDuplicates(); // {"1", "2", "3"}
|
|
||||||
//! [PIStringList::removeDuplicates]
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -28,7 +28,6 @@
|
|||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english The %PIByteArray class provides an array of bytes
|
//! \~english The %PIByteArray class provides an array of bytes
|
||||||
//! \~russian Класс %PIByteArray представляет собой массив байтов
|
//! \~russian Класс %PIByteArray представляет собой массив байтов
|
||||||
//! \}
|
|
||||||
//!
|
//!
|
||||||
//! \~\details
|
//! \~\details
|
||||||
//! \~english
|
//! \~english
|
||||||
@@ -99,6 +98,7 @@
|
|||||||
//! метов \a append().
|
//! метов \a append().
|
||||||
//! \~\snippet pibytearray.cpp 3
|
//! \~\snippet pibytearray.cpp 3
|
||||||
//!
|
//!
|
||||||
|
//! \}
|
||||||
|
|
||||||
|
|
||||||
static const uchar base64Table[64] = {
|
static const uchar base64Table[64] = {
|
||||||
|
|||||||
@@ -35,81 +35,32 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \class PIString
|
//! \addtogroup Core
|
||||||
* \brief String class
|
//! \{
|
||||||
* \details PIP use this class for use string information.
|
//! \class PIString pistring.h
|
||||||
*
|
//! \brief
|
||||||
* \section PIString_sec0 Synopsis
|
//! \~english String class
|
||||||
* This class based on \a PIVector to store information.
|
//! \~russian Класс строки
|
||||||
* String is a sequence of \a PIChar and can contain multibyte
|
//!
|
||||||
* symbols. Therefore real memory size of string is symbols count * 4.
|
//! \~\details
|
||||||
* String can be constucted from many types of data and can be converted
|
//! \~english \section PIString_sec0 Synopsis
|
||||||
* to many types. There are man operators and handly functions to use
|
//! \~russian \section PIString_sec0 Краткий обзор
|
||||||
* string as you wish.
|
//!
|
||||||
*
|
//! \~english
|
||||||
* \section PIString_sec1 To/from data convertions
|
//! String is a sequence of \a PIChar. Real memory size of string is symbols count * 2.
|
||||||
* Most common constructor is \a PIString(const char * str), where "str"
|
//! String can be constucted from many types of data and can be converted
|
||||||
* is null-terminated string, e.g. \c "string". This is 7 chars with last char = 0.
|
//! to many types. There are many operators and handly functions to use
|
||||||
* Also you can constructs \a PIString from single \a PIChar, \a PIByteArray,
|
//! string as you wish.
|
||||||
* other \a PIString or sequency of the same characters with custom length.\n \n
|
//!
|
||||||
* This class has implicit conversions to <tt>const char * </tt> and
|
//! \~russian
|
||||||
* \c std::string. Also there are functions to make same convertions:
|
//! Строка состоит из последовательности \a PIChar. Реальный объем памяти,
|
||||||
* * \a data() - to <tt>const char * </tt>,
|
//! занимаемый строкой, равен количеству символов * 2. Строка может быть
|
||||||
* * \a stdString() - to \c std::string,
|
//! создана из множества типов и преобразована в несколько типов.
|
||||||
* * \a toByteArray() - to \a PIByteArray.
|
//! Имеет множество методов для манипуляций.
|
||||||
*
|
//!
|
||||||
* \section PIString_sec2 Numeric operations
|
//! \}
|
||||||
* You can get symbolic representation of any numeric value with function
|
|
||||||
* \a setNumber(any integer value, int base = 10, bool * ok = 0). Default
|
|
||||||
* arguments are set for decimal base system, but you can choose any system
|
|
||||||
* from 2 to 40. There are the same static functions \a fromNumber(), that
|
|
||||||
* returns \a PIString. \n
|
|
||||||
* Also there is function \a setReadableSize() which is set human-readable
|
|
||||||
* size in bytes, Kb, Mb, Gb or Pb. Static analog is \a readableSize().
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*! \fn int versionCompare(const PIString & v0, const PIString & v1, int components = 6)
|
|
||||||
* \relatesalso PIString
|
|
||||||
* \brief Compare two version strings in free notation and returns 0, -1 or 1
|
|
||||||
* \details This function parse version to number codes and labels. Then it
|
|
||||||
* compare no more than "components" codes. If there is no difference, compare
|
|
||||||
* labels. Each label has corresponding integer value, so
|
|
||||||
* "prealpha" < "alpha" < "prebeta" < "beta" < "rcN" < "" < "rN".
|
|
||||||
* Example:
|
|
||||||
* \code
|
|
||||||
* piCout << versionCompare("1.0.0_rc2-999", "1.0.1_rc2-999"); // -1
|
|
||||||
* piCout << versionCompare("1.0.0", "0.9.2"); // 1
|
|
||||||
* piCout << versionCompare("1.0.0_r1", "1.0.0"); // 1
|
|
||||||
* piCout << versionCompare("1.0.0_r1", "1.0.0", 3); // 0
|
|
||||||
* piCout << versionCompare("1.0.0_r1", "1.0.0", 3); // 0
|
|
||||||
* piCout << versionCompare(".2-alpha", "0.2_alpha"); // 0
|
|
||||||
* piCout << versionCompare("1_prebeta", "1.0_alpha"); // 1
|
|
||||||
* \endcode
|
|
||||||
* \return
|
|
||||||
* * 0 - equal
|
|
||||||
* * 1 - v0 > v1
|
|
||||||
* * -1 - v0 < v1
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \fn PIString versionNormalize(const PIString & v)
|
|
||||||
* \relatesalso PIString
|
|
||||||
* \brief Converts version string in free notation to classic view
|
|
||||||
* \details Parse version as described in \a versionCompare() and
|
|
||||||
* returns classic view of codes and labels: major.minor.revision[-build][_label].
|
|
||||||
* Example:
|
|
||||||
* \code
|
|
||||||
* piCout << versionNormalize(""); // 0.0.0
|
|
||||||
* piCout << versionNormalize("1"); // 1.0.0
|
|
||||||
* piCout << versionNormalize("1.2"); // 1.2.0
|
|
||||||
* piCout << versionNormalize("1.2.3"); // 1.2.3
|
|
||||||
* piCout << versionNormalize("1.2+rc1.99"); // 1.2.99_rc1
|
|
||||||
* piCout << versionNormalize("1.2-alpha"); // 1.2.0_alpha
|
|
||||||
* piCout << versionNormalize("1..4_rc2-999"); // 1.0.4-999_rc2
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const char PIString::toBaseN[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
const char PIString::toBaseN[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
@@ -376,6 +327,19 @@ PIString PIString::fromCodepage(const char * s, const char * c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! Example:
|
||||||
|
//! \~russian
|
||||||
|
//! Пример:
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::readableSize(512); // 512 B
|
||||||
|
//! piCout << PIString::readableSize(5120); // 5.0 kB
|
||||||
|
//! piCout << PIString::readableSize(512000); // 500.0 kB
|
||||||
|
//! piCout << PIString::readableSize(5120000); // 4.8 MB
|
||||||
|
//! piCout << PIString::readableSize(512000000); // 488.2 MB
|
||||||
|
//! piCout << PIString::readableSize(51200000000); // 47.6 GB
|
||||||
|
//! \endcode
|
||||||
PIString PIString::readableSize(llong bytes) {
|
PIString PIString::readableSize(llong bytes) {
|
||||||
PIString s;
|
PIString s;
|
||||||
s.setReadableSize(bytes);
|
s.setReadableSize(bytes);
|
||||||
@@ -458,28 +422,6 @@ void PIString::trimsubstr(int &st, int &fn) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * PIString::dataConsole() const {
|
|
||||||
buildData(__sysoemname__ );
|
|
||||||
return (const char *)(data_.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * PIString::dataUTF8() const {
|
|
||||||
buildData(__utf8name__);
|
|
||||||
return (const char *)(data_.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * PIString::dataAscii() const {
|
|
||||||
data_.clear();
|
|
||||||
for (int i = 0; i < size_s(); ++i) {
|
|
||||||
data_.push_back(uchar(at(i).ch));
|
|
||||||
}
|
|
||||||
data_.push_back(uchar('\0'));
|
|
||||||
return (const char *)data_.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint PIString::hash() const {
|
uint PIString::hash() const {
|
||||||
return piHashData((const uchar*)PIDeque<PIChar>::data(), size() * sizeof(PIChar));
|
return piHashData((const uchar*)PIDeque<PIChar>::data(), size() * sizeof(PIChar));
|
||||||
}
|
}
|
||||||
@@ -579,6 +521,21 @@ bool PIString::operator >(const PIString & str) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! If "len" < 0 then returns substring from symbol "start" to end.
|
||||||
|
//! \~russian
|
||||||
|
//! Если "len" < 0 тогда возвращается подстрока от символа "start" и до конца.
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.mid(-2, -1); // s = "0123456789"
|
||||||
|
//! piCout << s.mid(-2, 4); // s = "01"
|
||||||
|
//! piCout << s.mid(3, -1); // s = "3456789"
|
||||||
|
//! piCout << s.mid(3, 4); // s = "3456"
|
||||||
|
//! piCout << s.mid(7, 1); // s = "7"
|
||||||
|
//! piCout << s.mid(7, 4); // s = "789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a left(), \a right()
|
||||||
PIString PIString::mid(const int start, const int len) const {
|
PIString PIString::mid(const int start, const int len) const {
|
||||||
//PIString str;
|
//PIString str;
|
||||||
int s = start, l = len;
|
int s = start, l = len;
|
||||||
@@ -597,6 +554,17 @@ PIString PIString::mid(const int start, const int len) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! s.cutMid(1, 3);
|
||||||
|
//! piCout << s; // s = "0456789"
|
||||||
|
//! s.cutMid(-1, 3);
|
||||||
|
//! piCout << s; // s = "56789"
|
||||||
|
//! s.cutMid(3, -1);
|
||||||
|
//! piCout << s; // s = "567"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a cutLeft(), \a cutRight()
|
||||||
PIString & PIString::cutMid(const int start, const int len) {
|
PIString & PIString::cutMid(const int start, const int len) {
|
||||||
int s = start, l = len;
|
int s = start, l = len;
|
||||||
if (l == 0) return *this;
|
if (l == 0) return *this;
|
||||||
@@ -614,6 +582,16 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english Remove spaces, tabulations, line feeds and null symbols:
|
||||||
|
//! \~russian Удаляет пробелы, табуляцию, переводы строк и нулевые символы:
|
||||||
|
//! \~ ' ', '\\n', '\\r', '\\t', '\\0'
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" \t string \n");
|
||||||
|
//! s.trim();
|
||||||
|
//! piCout << s; // s = "string"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a trimmed()
|
||||||
PIString & PIString::trim() {
|
PIString & PIString::trim() {
|
||||||
int st = -1, fn = 0;
|
int st = -1, fn = 0;
|
||||||
trimsubstr(st, fn);
|
trimsubstr(st, fn);
|
||||||
@@ -635,6 +613,15 @@ PIString PIString::trimmed() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! s.replace(2, 3, "_cut_");
|
||||||
|
//! piCout << s; // s = "01_cut_56789"
|
||||||
|
//! s.replace(0, 1, "one_");
|
||||||
|
//! piCout << s; // s = "one_1_cut_56789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replaced(), \a replaceAll()
|
||||||
PIString & PIString::replace(int from, int count, const PIString & with) {
|
PIString & PIString::replace(int from, int count, const PIString & with) {
|
||||||
count = piMini(count, length() - from);
|
count = piMini(count, length() - from);
|
||||||
if (count == with.size_s()) {
|
if (count == with.size_s()) {
|
||||||
@@ -647,6 +634,18 @@ PIString & PIString::replace(int from, int count, const PIString & with) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "ok" is not null, it set to "true" if something was replaced
|
||||||
|
//! \~russian Если "ok" не null, то устанавливает в "true" если замена произведена
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("pip string");
|
||||||
|
//! bool ok;
|
||||||
|
//! s.replace("string", "conf", &ok);
|
||||||
|
//! piCout << s << ok; // s = "pip conf", true
|
||||||
|
//! s.replace("PIP", "PlInPr", &ok);
|
||||||
|
//! piCout << s << ok; // s = "pip conf", false
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replaced(), \a replaceAll()
|
||||||
PIString & PIString::replace(const PIString & what, const PIString & with, bool * ok) {
|
PIString & PIString::replace(const PIString & what, const PIString & with, bool * ok) {
|
||||||
if (what.isEmpty()) {
|
if (what.isEmpty()) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
@@ -659,6 +658,13 @@ PIString & PIString::replace(const PIString & what, const PIString & with, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("substrings");
|
||||||
|
//! s.replaceAll("s", "_");
|
||||||
|
//! piCout << s; // s = "_ub_tring_"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replace(), \a replaced(), \a replacedAll()
|
||||||
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
||||||
if (what.isEmpty() || what == with) return *this;
|
if (what.isEmpty() || what == with) return *this;
|
||||||
if (with.isEmpty()) {
|
if (with.isEmpty()) {
|
||||||
@@ -683,6 +689,13 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("substrings");
|
||||||
|
//! s.replaceAll("s", '_');
|
||||||
|
//! piCout << s; // s = "_ub_tring_"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replace(), \a replaced(), \a replacedAll()
|
||||||
PIString & PIString::replaceAll(const PIString & what, const char with) {
|
PIString & PIString::replaceAll(const PIString & what, const char with) {
|
||||||
if (what.isEmpty()) return *this;
|
if (what.isEmpty()) return *this;
|
||||||
int l = what.length(), dl = what.length() - 1;
|
int l = what.length(), dl = what.length() - 1;
|
||||||
@@ -702,6 +715,13 @@ PIString & PIString::replaceAll(const PIString & what, const char with) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("substrings");
|
||||||
|
//! s.replaceAll('s', '_');
|
||||||
|
//! piCout << s; // s = "_ub_tring_"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replace(), \a replaced(), \a replacedAll()
|
||||||
PIString & PIString::replaceAll(const char what, const char with) {
|
PIString & PIString::replaceAll(const char what, const char with) {
|
||||||
int l = length();
|
int l = length();
|
||||||
for (int i = 0; i < l; ++i) {
|
for (int i = 0; i < l; ++i) {
|
||||||
@@ -767,6 +787,15 @@ PIStringList PIString::split(const PIString & delim) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.find('-'); // -1
|
||||||
|
//! piCout << s.find('3'); // 3
|
||||||
|
//! piCout << s.find('3', 4); // 9
|
||||||
|
//! piCout << s.find('3', 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int PIString::find(const char c, const int start) const {
|
int PIString::find(const char c, const int start) const {
|
||||||
for (int i = start; i < length(); ++i) {
|
for (int i = start; i < length(); ++i) {
|
||||||
if (at(i) == c) return i;
|
if (at(i) == c) return i;
|
||||||
@@ -775,6 +804,15 @@ int PIString::find(const char c, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.find("-"); // -1
|
||||||
|
//! piCout << s.find("34"); // 3
|
||||||
|
//! piCout << s.find("3", 4); // 9
|
||||||
|
//! piCout << s.find("3", 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int PIString::find(const PIString & str, const int start) const {
|
int PIString::find(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = start; i < length() - l + 1; ++i) {
|
for (int i = start; i < length() - l + 1; ++i) {
|
||||||
@@ -784,6 +822,30 @@ int PIString::find(const PIString & str, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("1.str").findAny(".,:"); // 1
|
||||||
|
//! piCout << PIString("1,str").findAny(".,:"); // 1
|
||||||
|
//! piCout << PIString("1:str").findAny(".,:"); // 1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
|
int PIString::findAny(const PIString & str, const int start) const {
|
||||||
|
for (int i = start; i < length(); ++i) {
|
||||||
|
if (str.contains(at(i))) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.findLast('-'); // -1
|
||||||
|
//! piCout << s.findLast('3'); // 9
|
||||||
|
//! piCout << s.findLast('3', 4); // 9
|
||||||
|
//! piCout << s.findLast('3', 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int PIString::findLast(const char c, const int start) const {
|
int PIString::findLast(const char c, const int start) const {
|
||||||
for (int i = length() - 1; i >= start; --i) {
|
for (int i = length() - 1; i >= start; --i) {
|
||||||
if (at(i) == c) return i;
|
if (at(i) == c) return i;
|
||||||
@@ -792,6 +854,15 @@ int PIString::findLast(const char c, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.findLast("-"); // -1
|
||||||
|
//! piCout << s.findLast("34"); // 9
|
||||||
|
//! piCout << s.findLast("3", 4); // 9
|
||||||
|
//! piCout << s.findLast("3", 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int PIString::findLast(const PIString & str, const int start) const {
|
int PIString::findLast(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = length() - l; i >= start; --i) {
|
for (int i = length() - l; i >= start; --i) {
|
||||||
@@ -801,6 +872,30 @@ int PIString::findLast(const PIString & str, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString(".str.0").findAnyLast(".,:"); // 4
|
||||||
|
//! piCout << PIString(".str,0").findAnyLast(".,:"); // 4
|
||||||
|
//! piCout << PIString(".str:0").findAnyLast(".,:"); // 4
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
|
int PIString::findAnyLast(const PIString & str, const int start) const {
|
||||||
|
for (int i = length() - 1; i >= start; --i) {
|
||||||
|
if (str.contains(at(i))) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("this is <PIP>");
|
||||||
|
//! piCout << s.findWord("this"); // 0
|
||||||
|
//! piCout << s.findWord("is"); // 5
|
||||||
|
//! piCout << s.findWord("PIP", 4); // -1
|
||||||
|
//! piCout << s.findWord("<PIP>", 4); // 8
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findAnyLast(), \a findCWord(), \a findRange()
|
||||||
int PIString::findWord(const PIString & word, const int start) const {
|
int PIString::findWord(const PIString & word, const int start) const {
|
||||||
int f = start - 1, tl = length(), wl = word.length();
|
int f = start - 1, tl = length(), wl = word.length();
|
||||||
while ((f = find(word, f + 1)) >= 0) {
|
while ((f = find(word, f + 1)) >= 0) {
|
||||||
@@ -826,6 +921,15 @@ int PIString::findWord(const PIString & word, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("this::is <PIP>");
|
||||||
|
//! piCout << s.findCWord("this"); // 0
|
||||||
|
//! piCout << s.findCWord("is"); // 6
|
||||||
|
//! piCout << s.findCWord("PIP", 4); // 10
|
||||||
|
//! piCout << s.findCWord("<PIP>", 4); // 9
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findRange()
|
||||||
int PIString::findCWord(const PIString & word, const int start) const {
|
int PIString::findCWord(const PIString & word, const int start) const {
|
||||||
int f = start - 1, tl = length(), wl = word.length();
|
int f = start - 1, tl = length(), wl = word.length();
|
||||||
while ((f = find(word, f + 1)) >= 0) {
|
while ((f = find(word, f + 1)) >= 0) {
|
||||||
@@ -851,6 +955,15 @@ int PIString::findCWord(const PIString & word, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" {figures{inside}}");
|
||||||
|
//! int len = -1;
|
||||||
|
//! piCout << s.findRange('{', '}', '\\', 0, &len) << len << s.mid(2, len); // 2 15 figures{inside}
|
||||||
|
//! s = "\"text\\\"shielded\" next";
|
||||||
|
//! piCout << s.findRange('"', '"', '\\', 0, &len) << len << s.mid(1, len); // 1 14 text\"shielded
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord()
|
||||||
int PIString::findRange(const PIChar start, const PIChar end, const PIChar shield, const int start_index, int * len) const {
|
int PIString::findRange(const PIChar start, const PIChar end, const PIChar shield, const int start_index, int * len) const {
|
||||||
if (len) *len = 0;
|
if (len) *len = 0;
|
||||||
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
|
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
|
||||||
@@ -891,22 +1004,6 @@ int PIString::findRange(const PIChar start, const PIChar end, const PIChar shiel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::findAny(const PIString & str, const int start) const {
|
|
||||||
for (int i = start; i < length(); ++i) {
|
|
||||||
if (str.contains(at(i))) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PIString::findAnyLast(const PIString & str, const int start) const {
|
|
||||||
for (int i = length() - 1; i >= start; --i) {
|
|
||||||
if (str.contains(at(i))) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PIString::entries(const PIChar c) const {
|
int PIString::entries(const PIChar c) const {
|
||||||
int sz = size_s(), ret = 0;
|
int sz = size_s(), ret = 0;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
@@ -928,6 +1025,17 @@ bool PIString::endsWith(const PIString & str) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("true").toBool(); // true
|
||||||
|
//! piCout << PIString("Yes").toBool(); // true
|
||||||
|
//! piCout << PIString(" TRUE ").toBool(); // true
|
||||||
|
//! piCout << PIString(" 1 ").toBool(); // true
|
||||||
|
//! piCout << PIString("0").toBool(); // false
|
||||||
|
//! piCout << PIString("0.1").toBool(); // true
|
||||||
|
//! piCout << PIString("-1").toBool(); // false
|
||||||
|
//! piCout << PIString("").toBool(); // false
|
||||||
|
//! \endcode
|
||||||
bool PIString::toBool() const {
|
bool PIString::toBool() const {
|
||||||
static const PIString s_true = PIStringAscii("true");
|
static const PIString s_true = PIStringAscii("true");
|
||||||
static const PIString s_yes = PIStringAscii("yes" );
|
static const PIString s_yes = PIStringAscii("yes" );
|
||||||
@@ -941,6 +1049,15 @@ bool PIString::toBool() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("\t ! word");
|
||||||
|
//! piCout << s.takeSymbol(); // "!"
|
||||||
|
//! piCout << s.takeSymbol(); // "w"
|
||||||
|
//! piCout << s.takeSymbol(); // "o"
|
||||||
|
//! piCout << s; // "rd"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeWord(), \a takeCWord(), \a takeLine(), \a takeNumber(), \a takeRange()
|
||||||
PIString PIString::takeSymbol() {
|
PIString PIString::takeSymbol() {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
int sz = size_s(), ss = -1;
|
int sz = size_s(), ss = -1;
|
||||||
@@ -957,6 +1074,15 @@ PIString PIString::takeSymbol() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("some words\nnew line ");
|
||||||
|
//! piCout << s.takeWord(); // "some"
|
||||||
|
//! piCout << s.takeWord(); // "words"
|
||||||
|
//! piCout << s.takeWord(); // "new"
|
||||||
|
//! piCout << s; // " line "
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeSymbol(), \a takeCWord(), \a takeLine(), \a takeNumber(), \a takeRange()
|
||||||
PIString PIString::takeWord() {
|
PIString PIString::takeWord() {
|
||||||
int sz = size_s(), ws = -1, we = -1;
|
int sz = size_s(), ws = -1, we = -1;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
@@ -977,6 +1103,10 @@ PIString PIString::takeWord() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber(), \a takeRange()
|
||||||
PIString PIString::takeCWord() {
|
PIString PIString::takeCWord() {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
int sz = size_s(), ws = -1, we = -1;
|
int sz = size_s(), ws = -1, we = -1;
|
||||||
@@ -1009,6 +1139,15 @@ PIString PIString::takeCWord() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("some words\nnew line \n\nend");
|
||||||
|
//! piCout << s.takeLine(); // "some words"
|
||||||
|
//! piCout << s.takeLine(); // "new line "
|
||||||
|
//! piCout << s.takeLine(); // ""
|
||||||
|
//! piCout << s; // "end"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeSymbol(), \a takeWord(), \a takeCWord(), \a takeNumber(), \a takeRange()
|
||||||
PIString PIString::takeLine() {
|
PIString PIString::takeLine() {
|
||||||
int sz = size_s(), le = -1;
|
int sz = size_s(), le = -1;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
@@ -1029,6 +1168,16 @@ PIString PIString::takeLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" 0xFF -99 1.2E+5f 1000L");
|
||||||
|
//! piCout << s.takeNumber(); // "0xFF"
|
||||||
|
//! piCout << s.takeNumber(); // "-99"
|
||||||
|
//! piCout << s.takeNumber(); // "1.2E+5f"
|
||||||
|
//! piCout << s.takeNumber(); // "1000L"
|
||||||
|
//! piCout << s; // ""
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeSymbol(), \a takeWord(), \a takeCWord(), \a takeLine(), \a takeRange()
|
||||||
PIString PIString::takeNumber() {
|
PIString PIString::takeNumber() {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
int sz = size_s(), ls = -1, le = -1, phase = 0;
|
int sz = size_s(), ls = -1, le = -1, phase = 0;
|
||||||
@@ -1123,6 +1272,18 @@ PIString PIString::takeNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english "shield" symbol prevent analysis of the next symbol
|
||||||
|
//! \~russian Символ "shield" экранирует следующий символ
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" {figures{inside}}");
|
||||||
|
//! piCout << s.takeRange('{', '}'); // "figures{inside}"
|
||||||
|
//! piCout << s; // ""
|
||||||
|
//! s = "\"text\\\"shielded\" next";
|
||||||
|
//! piCout << s.takeRange('"', '"'); // "text\"shielded"
|
||||||
|
//! piCout << s; // " next"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber()
|
||||||
PIString PIString::takeRange(const PIChar start, const PIChar end, const PIChar shield) {
|
PIString PIString::takeRange(const PIChar start, const PIChar end, const PIChar shield) {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
|
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
|
||||||
@@ -1170,6 +1331,12 @@ PIString PIString::takeRange(const PIChar start, const PIChar end, const PIChar
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("a(b(c)d)e");
|
||||||
|
//! piCout << s.inBrackets('(', ')'); // "b(c)d"
|
||||||
|
//! piCout << s; // s = "a(b(c)d)e"
|
||||||
|
//! \endcode
|
||||||
PIString PIString::inBrackets(const PIChar start, const PIChar end) const {
|
PIString PIString::inBrackets(const PIChar start, const PIChar end) const {
|
||||||
int slen = length();
|
int slen = length();
|
||||||
int st = -1, bcnt = 0;
|
int st = -1, bcnt = 0;
|
||||||
@@ -1189,6 +1356,96 @@ PIString PIString::inBrackets(const PIChar start, const PIChar end) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english It`s equivalent length of char sequence returned by function \a data() - 1, without terminating null-char
|
||||||
|
//! \~russian Эквивалентно длине данных, возвращаемых \a data() - 1, без завершающего нулевого байта
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("0123456789").lengthAscii(); // 10
|
||||||
|
//! piCout << PIString("№1").lengthAscii(); // 3
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a data()
|
||||||
|
int PIString::lengthAscii() const {
|
||||||
|
buildData(__syslocname__);
|
||||||
|
return data_.size_s() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! This function fill internal buffer by sequence
|
||||||
|
//! of chars. Minimum length of this buffer is count
|
||||||
|
//! of symbols. Returned pointer is valid until next
|
||||||
|
//! execution of this function
|
||||||
|
//! \~russian
|
||||||
|
//! Этот метод заполняет внутренный байтовый буфер. Минимальный размер
|
||||||
|
//! этого буфера равен количеству символов строки. Возвращаемый указатель
|
||||||
|
//! действителен до следующего вызова этого метода
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("0123456789").data(); // 0123456789
|
||||||
|
//! piCout << PIString("№1").data(); // №1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a dataConsole(), \a dataUTF8()
|
||||||
|
const char * PIString::data() const {
|
||||||
|
buildData(__syslocname__);
|
||||||
|
return (const char *)(data_.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! This function fill internal buffer by sequence
|
||||||
|
//! of chars. Minimum length of this buffer is count
|
||||||
|
//! of symbols. Returned pointer is valid until next
|
||||||
|
//! execution of this function
|
||||||
|
//! \~russian
|
||||||
|
//! Этот метод заполняет внутренный байтовый буфер. Минимальный размер
|
||||||
|
//! этого буфера равен количеству символов строки. Возвращаемый указатель
|
||||||
|
//! действителен до следующего вызова этого метода
|
||||||
|
//! \~\sa \a data(), \a dataUTF8()
|
||||||
|
const char * PIString::dataConsole() const {
|
||||||
|
buildData(__sysoemname__ );
|
||||||
|
return (const char *)(data_.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! This function fill internal buffer by sequence
|
||||||
|
//! of chars. Minimum length of this buffer is count
|
||||||
|
//! of symbols. Returned pointer is valid until next
|
||||||
|
//! execution of this function
|
||||||
|
//! \~russian
|
||||||
|
//! Этот метод заполняет внутренный байтовый буфер. Минимальный размер
|
||||||
|
//! этого буфера равен количеству символов строки. Возвращаемый указатель
|
||||||
|
//! действителен до следующего вызова этого метода
|
||||||
|
//! \~\sa \a data(), \a dataConsole()
|
||||||
|
const char * PIString::dataUTF8() const {
|
||||||
|
buildData(__utf8name__);
|
||||||
|
return (const char *)(data_.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! This function fill internal buffer by sequence
|
||||||
|
//! of chars. Length of this buffer is count
|
||||||
|
//! of symbols. Returned pointer is valid until next
|
||||||
|
//! execution of this function
|
||||||
|
//! \~russian
|
||||||
|
//! Этот метод заполняет внутренный байтовый буфер. Размер
|
||||||
|
//! этого буфера равен количеству символов строки. Возвращаемый указатель
|
||||||
|
//! действителен до следующего вызова этого метода
|
||||||
|
//! \~\sa \a dataConsole(), \a dataUTF8()
|
||||||
|
const char * PIString::dataAscii() const {
|
||||||
|
data_.clear();
|
||||||
|
for (int i = 0; i < size_s(); ++i) {
|
||||||
|
data_.push_back(uchar(at(i).ch));
|
||||||
|
}
|
||||||
|
data_.push_back(uchar('\0'));
|
||||||
|
return (const char *)data_.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIString::toUpperCase() const {
|
PIString PIString::toUpperCase() const {
|
||||||
PIString str(*this);
|
PIString str(*this);
|
||||||
int l = str.size();
|
int l = str.size();
|
||||||
@@ -1243,6 +1500,26 @@ ldouble PIString::toLDouble() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! Example:
|
||||||
|
//! \~russian
|
||||||
|
//! Пример:
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setReadableSize(512);
|
||||||
|
//! piCout << s; // 512 B
|
||||||
|
//! s.setReadableSize(5120);
|
||||||
|
//! piCout << s; // 5.0 kB
|
||||||
|
//! s.setReadableSize(512000);
|
||||||
|
//! piCout << s; // 500.0 kB
|
||||||
|
//! s.setReadableSize(5120000);
|
||||||
|
//! piCout << s; // 4.8 MB
|
||||||
|
//! s.setReadableSize(512000000);
|
||||||
|
//! piCout << s; // 488.2 MB
|
||||||
|
//! s.setReadableSize(51200000000);
|
||||||
|
//! piCout << s; // 47.6 GB
|
||||||
|
//! \endcode
|
||||||
PIString & PIString::setReadableSize(llong bytes) {
|
PIString & PIString::setReadableSize(llong bytes) {
|
||||||
clear();
|
clear();
|
||||||
if (bytes < 1024) {
|
if (bytes < 1024) {
|
||||||
@@ -1351,6 +1628,38 @@ int versionLabelValue(PIString s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIString
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! This function parse version to number codes and labels. Then it
|
||||||
|
//! compare no more than "components" codes. If there is no difference, compare
|
||||||
|
//! labels. Each label has corresponding integer value, so
|
||||||
|
//! "prealpha" < "alpha" < "prebeta" < "beta" < "rc[N]" < "" < "r[N]".
|
||||||
|
//! Example:
|
||||||
|
//! \~russian
|
||||||
|
//! Этот метод разбирает версии на числовые части и метку. Затем сравнивает
|
||||||
|
//! не более чем "components" частей. Если различий нет, то сравниваются
|
||||||
|
//! метки. Каждой метке соответствует своё значение так, что
|
||||||
|
//! "prealpha" < "alpha" < "prebeta" < "beta" < "rc[N]" < "" < "r[N]".
|
||||||
|
//! Пример:
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << versionCompare("1.0.0_rc2-999", "1.0.1_rc2-999"); // -1, <
|
||||||
|
//! piCout << versionCompare("1.0.0", "0.9.2"); // 1, >
|
||||||
|
//! piCout << versionCompare("1.0.0_r1", "1.0.0"); // 1, >
|
||||||
|
//! piCout << versionCompare("1.0.0_r1", "1.0.0", 3); // 0, =
|
||||||
|
//! piCout << versionCompare("1.0.0_r2", "1.0.0", 3); // 0, =
|
||||||
|
//! piCout << versionCompare(".2-alpha", "0.2_alpha"); // 0, =
|
||||||
|
//! piCout << versionCompare("1_prebeta", "1.0_alpha"); // 1, >
|
||||||
|
//! \endcode
|
||||||
|
//! \~\return
|
||||||
|
//! \~english
|
||||||
|
//! * 0 - equal
|
||||||
|
//! * 1 - v0 > v1
|
||||||
|
//! * -1 - v0 < v1
|
||||||
|
//! \~russian
|
||||||
|
//! * 0 - равны
|
||||||
|
//! * 1 - v0 > v1
|
||||||
|
//! * -1 - v0 < v1
|
||||||
int versionCompare(const PIString & v0, const PIString & v1, int components) {
|
int versionCompare(const PIString & v0, const PIString & v1, int components) {
|
||||||
PIStringList strs[2]; PIVector<int> codes[2];
|
PIStringList strs[2]; PIVector<int> codes[2];
|
||||||
parseVersion(v0.toLowerCase(), codes[0], strs[0]);
|
parseVersion(v0.toLowerCase(), codes[0], strs[0]);
|
||||||
@@ -1379,6 +1688,25 @@ int versionCompare(const PIString & v0, const PIString & v1, int components) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIString
|
||||||
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! Parse version as described in \a versionCompare() and returns
|
||||||
|
//! classic view of codes and labels: major.minor.revision[-build][_label].
|
||||||
|
//! Example:
|
||||||
|
//! \~russian
|
||||||
|
//! Разбирает версию по описанию \a versionCompare() и возвращает
|
||||||
|
//! классическое представление версии и метки: major.minor.revision[-build][_label].
|
||||||
|
//! Пример:
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << versionNormalize(""); // 0.0.0
|
||||||
|
//! piCout << versionNormalize("1"); // 1.0.0
|
||||||
|
//! piCout << versionNormalize("1.2"); // 1.2.0
|
||||||
|
//! piCout << versionNormalize("1.2.3"); // 1.2.3
|
||||||
|
//! piCout << versionNormalize("1.2+rc1.99"); // 1.2.99_rc1
|
||||||
|
//! piCout << versionNormalize("1.2-alpha"); // 1.2.0_alpha
|
||||||
|
//! piCout << versionNormalize("1..4_rc2-999"); // 1.0.4-999_rc2
|
||||||
|
//! \endcode
|
||||||
PIString versionNormalize(const PIString & v) {
|
PIString versionNormalize(const PIString & v) {
|
||||||
PIStringList strs; PIVector<int> codes;
|
PIStringList strs; PIVector<int> codes;
|
||||||
parseVersion(v.toLowerCase(), codes, strs);
|
parseVersion(v.toLowerCase(), codes, strs);
|
||||||
@@ -1407,4 +1735,3 @@ PICout operator <<(PICout s, const PIString & v) {
|
|||||||
s.quote();
|
s.quote();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,20 @@ class PIP_EXPORT PIString: public PIDeque<PIChar>
|
|||||||
{
|
{
|
||||||
friend PIByteArray & operator >>(PIByteArray & s, PIString & v);
|
friend PIByteArray & operator >>(PIByteArray & s, PIString & v);
|
||||||
public:
|
public:
|
||||||
//! Contructs an empty string
|
//! \~english Contructs an empty string
|
||||||
|
//! \~russian Создает пустую строку
|
||||||
PIString(): PIDeque<PIChar>() {}
|
PIString(): PIDeque<PIChar>() {}
|
||||||
|
|
||||||
|
//! \~english Value for elide at left
|
||||||
|
//! \~russian Значение для пропуска слева
|
||||||
static const float ElideLeft ;
|
static const float ElideLeft ;
|
||||||
|
|
||||||
|
//! \~english Value for elide at center
|
||||||
|
//! \~russian Значение для пропуска в середине
|
||||||
static const float ElideCenter;
|
static const float ElideCenter;
|
||||||
|
|
||||||
|
//! \~english Value for elide at right
|
||||||
|
//! \~russian Значение для пропуска справа
|
||||||
static const float ElideRight ;
|
static const float ElideRight ;
|
||||||
|
|
||||||
PIString & operator +=(const PIChar c) {push_back(c); return *this;}
|
PIString & operator +=(const PIChar c) {push_back(c); return *this;}
|
||||||
@@ -51,683 +60,1272 @@ public:
|
|||||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
||||||
PIString & operator +=(const PIString & str);
|
PIString & operator +=(const PIString & str);
|
||||||
|
|
||||||
|
//! \~english Contructs a copy of string
|
||||||
|
//! \~russian Создает копию строки
|
||||||
PIString(const PIString & o): PIDeque<PIChar>(o) {}
|
PIString(const PIString & o): PIDeque<PIChar>(o) {}
|
||||||
|
|
||||||
PIString(PIString && o): PIDeque<PIChar>(std::move(o)) {}
|
PIString(PIString && o): PIDeque<PIChar>(std::move(o)) {}
|
||||||
|
|
||||||
|
|
||||||
//! Contructs string with single symbol "c"
|
//! \~english Contructs string with single symbol "c"
|
||||||
|
//! \~russian Создает строку из одного символа "c"
|
||||||
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
|
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
|
||||||
|
|
||||||
|
//! \~english Contructs string with single symbol "c"
|
||||||
|
//! \~russian Создает строку из одного символа "c"
|
||||||
PIString(const char c): PIDeque<PIChar>() {*this += PIChar(c);}
|
PIString(const char c): PIDeque<PIChar>() {*this += PIChar(c);}
|
||||||
|
|
||||||
/*! \brief Contructs string from c-string "str"
|
//! \~english Contructs string from C-string "str" (system codepage)
|
||||||
* \details "str" should be null-terminated\n
|
//! \~russian Создает строку из C-строки "str" (кодировка системы)
|
||||||
* Example: \snippet pistring.cpp PIString(char * ) */
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! "str" should be null-terminated\n
|
||||||
|
//! \~russian
|
||||||
|
//! "str" должна заканчиваться нулевым байтом\n
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("string");
|
||||||
|
//! \endcode
|
||||||
PIString(const char * str): PIDeque<PIChar>() {*this += str;}
|
PIString(const char * str): PIDeque<PIChar>() {*this += str;}
|
||||||
|
|
||||||
/*! \brief Contructs string from \c wchar_t c-string "str"
|
//! \~english Contructs string from \c wchar_t C-string "str"
|
||||||
* \details "str" should be null-terminated\n
|
//! \~russian Создает строку из \c wchar_t C-строки "str"
|
||||||
* Example: \snippet pistring.cpp PIString(wchar_t * ) */
|
//! \~\details
|
||||||
|
//! \~english
|
||||||
|
//! "str" should be null-terminated
|
||||||
|
//! \~russian
|
||||||
|
//! "str" должна заканчиваться нулевым \c wchar_t
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(L"string");
|
||||||
|
//! \endcode
|
||||||
PIString(const wchar_t * str): PIDeque<PIChar>() {*this += str;}
|
PIString(const wchar_t * str): PIDeque<PIChar>() {*this += str;}
|
||||||
|
|
||||||
//! Contructs string from byte array "ba"
|
//! \~english Contructs string from byte array "ba" (as UTF-8)
|
||||||
|
//! \~russian Создает строку из байтового массива "ba" (как UTF-8)
|
||||||
PIString(const PIByteArray & ba): PIDeque<PIChar>() {*this += ba;}
|
PIString(const PIByteArray & ba): PIDeque<PIChar>() {*this += ba;}
|
||||||
|
|
||||||
//! \brief Contructs string from "len" characters of buffer "str"
|
//! \~english Contructs string from "len" characters of buffer "str"
|
||||||
|
//! \~russian Создает строку из "len" символов массива "str"
|
||||||
PIString(const PIChar * str, const int len): PIDeque<PIChar>(str, size_t(len)) {}
|
PIString(const PIChar * str, const int len): PIDeque<PIChar>(str, size_t(len)) {}
|
||||||
|
|
||||||
/*! \brief Contructs string from "len" characters of buffer "str"
|
//! \~english Contructs string from "len" characters of buffer "str" (system codepage)
|
||||||
* \details Example: \snippet pistring.cpp PIString(char * , int) */
|
//! \~russian Создает строку из "len" символов массива "str" (кодировка системы)
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("string", 3); // s = "str"
|
||||||
|
//! \endcode
|
||||||
PIString(const char * str, const int len): PIDeque<PIChar>() {appendFromChars(str, len);}
|
PIString(const char * str, const int len): PIDeque<PIChar>() {appendFromChars(str, len);}
|
||||||
|
|
||||||
/*! \brief Contructs string as sequence of characters "c" of buffer with length "len"
|
//! \~english Contructs string as sequence of characters "c" of buffer with length "len"
|
||||||
* \details Example: \snippet pistring.cpp PIString(int, char) */
|
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(5, 'p'); // s = "ppppp"
|
||||||
|
//! \endcode
|
||||||
PIString(const int len, const char c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
|
PIString(const int len, const char c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
|
||||||
|
|
||||||
/*! \brief Contructs string as sequence of symbols "c" of buffer with length "len"
|
//! \~english Contructs string as sequence of symbols "c" of buffer with length "len"
|
||||||
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
|
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(5, "№"); // s = "№№№№№"
|
||||||
|
//! \endcode
|
||||||
PIString(const int len, const PIChar c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
|
PIString(const int len, const PIChar c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
|
||||||
|
|
||||||
~PIString() {}
|
~PIString() {}
|
||||||
|
|
||||||
|
|
||||||
|
//! \~english Assign operator
|
||||||
|
//! \~russian Оператор присваивания
|
||||||
PIString & operator =(const PIString & o) {if (this == &o) return *this; clear(); *this += o; return *this;}
|
PIString & operator =(const PIString & o) {if (this == &o) return *this; clear(); *this += o; return *this;}
|
||||||
|
|
||||||
PIString & operator =(PIString && o) {swap(o); return *this;}
|
PIString & operator =(PIString && o) {swap(o); return *this;}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator ==(const PIString & str) const;
|
bool operator ==(const PIString & str) const;
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator ==(const PIChar c) const {if (size_s() != 1) return false; return at(0) == c;}
|
bool operator ==(const PIChar c) const {if (size_s() != 1) return false; return at(0) == c;}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator ==(const char * str) const {return *this == PIString(str);}
|
bool operator ==(const char * str) const {return *this == PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator !=(const PIString & str) const;
|
bool operator !=(const PIString & str) const;
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator !=(const PIChar c) const {if (size_s() != 1) return true; return at(0) != c;}
|
bool operator !=(const PIChar c) const {if (size_s() != 1) return true; return at(0) != c;}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator !=(const char * str) const {return *this != PIString(str);}
|
bool operator !=(const char * str) const {return *this != PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <(const PIString & str) const;
|
bool operator <(const PIString & str) const;
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <(const PIChar c) const {if (size_s() != 1) return size_s() < 1; return at(0) < c;}
|
bool operator <(const PIChar c) const {if (size_s() != 1) return size_s() < 1; return at(0) < c;}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <(const char * str) const {return *this < PIString(str);}
|
bool operator <(const char * str) const {return *this < PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >(const PIString & str) const;
|
bool operator >(const PIString & str) const;
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >(const PIChar c) const {if (size_s() != 1) return size_s() > 1; return at(0) > c;}
|
bool operator >(const PIChar c) const {if (size_s() != 1) return size_s() > 1; return at(0) > c;}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >(const char * str) const {return *this > PIString(str);}
|
bool operator >(const char * str) const {return *this > PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <=(const PIString & str) const {return !(*this > str);}
|
bool operator <=(const PIString & str) const {return !(*this > str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <=(const PIChar c) const {return !(*this > c);}
|
bool operator <=(const PIChar c) const {return !(*this > c);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator <=(const char * str) const {return *this <= PIString(str);}
|
bool operator <=(const char * str) const {return *this <= PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >=(const PIString & str) const {return !(*this < str);}
|
bool operator >=(const PIString & str) const {return !(*this < str);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >=(const PIChar c) const {return !(*this < c);}
|
bool operator >=(const PIChar c) const {return !(*this < c);}
|
||||||
|
|
||||||
//! Compare operator
|
//! \~english Compare operator
|
||||||
|
//! \~russian Оператор сравнения
|
||||||
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
||||||
|
|
||||||
/*! \brief Append string "str" at the end of string
|
//! \~english Append string "str" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(PIString) */
|
//! \~russian Добавляет в конец строку "str"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("this"), s1(" is"), s2(" string");
|
||||||
|
//! s << s1 << s2; // s = "this is string"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
||||||
|
|
||||||
/*! \brief Append symbol "c" at the end of string
|
//! \~english Append symbol "c" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
|
//! \~russian Добавляет в конец символ "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("stri");
|
||||||
|
//! s << PIChar('n') << PIChar('g'); // s = "string"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const PIChar c) {*this += c; return *this;}
|
PIString & operator <<(const PIChar c) {*this += c; return *this;}
|
||||||
|
|
||||||
/*! \brief Append symbol "c" at the end of string
|
//! \~english Append symbol "c" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
|
//! \~russian Добавляет в конец символ "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("stri");
|
||||||
|
//! s << 'n' << 'g'; // s = "string"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const char c) {*this += PIChar(c); return *this;}
|
PIString & operator <<(const char c) {*this += PIChar(c); return *this;}
|
||||||
|
|
||||||
/*! \brief Append c-string "str" at the end of string
|
//! \~english Append С-string "str" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(char * ) */
|
//! \~russian Добавляет в конец C-строку "str"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("this");
|
||||||
|
//! s << " is" << " string"; // s = "this is string"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const char * str) {*this += str; return *this;}
|
PIString & operator <<(const char * str) {*this += str; return *this;}
|
||||||
|
|
||||||
/*! \brief Append \c wchar_t c-string "str" at the end of string
|
//! \~english Append \c wchar_t C-string "str" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(wchar_t * ) */
|
//! \~russian Добавляет в конец \c wchar_t C-строку "str"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s << L"№ -" << " number"; // s = "№ - number"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const wchar_t * str) {*this += str; return *this;}
|
PIString & operator <<(const wchar_t * str) {*this += str; return *this;}
|
||||||
|
|
||||||
/*! \brief Append string representation of "num" at the end of string
|
//! \~english Append string representation of "num" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
//! \~russian Добавляет в конец строковое представление "num"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("ten - ");
|
||||||
|
//! s << 10; // s = "ten - 10"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
PIString & operator <<(const uint & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const uint & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
/*! \brief Append string representation of "num" at the end of string
|
//! \~english Append string representation of "num" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
//! \~russian Добавляет в конец строковое представление "num"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("ten - ");
|
||||||
|
//! s << 10; // s = "ten - 10"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
PIString & operator <<(const ulong & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const ulong & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
PIString & operator <<(const llong & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const llong & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
PIString & operator <<(const ullong & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const ullong & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
/*! \brief Append string representation of "num" at the end of string
|
//! \~english Append string representation of "num" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
//! \~russian Добавляет в конец строковое представление "num"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("1/10 - ");
|
||||||
|
//! s << 0.1; // s = "1/10 - 0.1"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const float & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const float & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
/*! \brief Append string representation of "num" at the end of string
|
//! \~english Append string representation of "num" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
//! \~russian Добавляет в конец строковое представление "num"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("1/10 - ");
|
||||||
|
//! s << 0.1; // s = "1/10 - 0.1"
|
||||||
|
//! \endcode
|
||||||
PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
|
|
||||||
//! \brief Insert string "str" at the begin of string
|
//! \~english Insert string "str" at the begin of string
|
||||||
|
//! \~russian Вставляет "str" в начало строки
|
||||||
PIString & prepend(const PIString & str) {insert(0, str); return *this;}
|
PIString & prepend(const PIString & str) {insert(0, str); return *this;}
|
||||||
|
|
||||||
//! \brief Insert string "str" at the end of string
|
//! \~english Insert string "str" at the end of string
|
||||||
|
//! \~russian Вставляет "str" в конец строки
|
||||||
PIString & append(const PIString & str) {*this += str; return *this;}
|
PIString & append(const PIString & str) {*this += str; return *this;}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Return part of string from symbol at index "start" and maximum length "len"
|
//! \~english Returns part of string from symbol at index "start" and maximum length "len"
|
||||||
* \details All variants demonstrated in example: \snippet pistring.cpp PIString::mid
|
//! \~russian Возвращает подстроку от символа "start" и максимальной длиной "len"
|
||||||
* \sa \a left(), \a right() */
|
|
||||||
PIString mid(const int start, const int len = -1) const;
|
PIString mid(const int start, const int len = -1) const;
|
||||||
|
|
||||||
/*! \brief Return sub-string of string from symbol at index "start" and maximum length "len" */
|
//! \~english Synonym of \a mid()
|
||||||
|
//! \~russian Аналог \a mid()
|
||||||
PIString subString(const int start, const int len = -1) const {return mid(start, len);}
|
PIString subString(const int start, const int len = -1) const {return mid(start, len);}
|
||||||
|
|
||||||
/*! \brief Return part of string from left and maximum length "len"
|
//! \~english Returns part of string from start and maximum length "len"
|
||||||
* \details Example: \snippet pistring.cpp PIString::left
|
//! \~russian Возвращает подстроку от начала и максимальной длиной "len"
|
||||||
* \sa \a mid(), \a right() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.left(-1); // s = ""
|
||||||
|
//! piCout << s.left(1); // s = "0"
|
||||||
|
//! piCout << s.left(5); // s = "01234"
|
||||||
|
//! piCout << s.left(15); // s = "0123456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a mid(), \a right()
|
||||||
PIString left(const int len) const {return len <= 0 ? PIString() : mid(0, len);}
|
PIString left(const int len) const {return len <= 0 ? PIString() : mid(0, len);}
|
||||||
|
|
||||||
/*! \brief Return part of string from right and maximum length "len"
|
//! \~english Returns part of string at end and maximum length "len"
|
||||||
* \details Example: \snippet pistring.cpp PIString::right
|
//! \~russian Возвращает подстроку максимальной длиной "len" и до конца
|
||||||
* \sa \a mid(), \a left() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.right(-1); // s = ""
|
||||||
|
//! piCout << s.right(1); // s = "9"
|
||||||
|
//! piCout << s.right(5); // s = "56789"
|
||||||
|
//! piCout << s.right(15); // s = "0123456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a mid(), \a left()
|
||||||
PIString right(const int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
|
PIString right(const int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
|
||||||
|
|
||||||
/*! \brief Remove part of string from symbol as index "start" and maximum length "len"
|
//! \~english Remove part of string from symbol as index "start" and maximum length "len" and return this string
|
||||||
* and return this string
|
//! \~russian Удаляет часть строки от символа "start" и максимальной длины "len", возвращает эту строку
|
||||||
* \details All variants demonstrated in example: \snippet pistring.cpp PIString::cutMid
|
|
||||||
* \sa \a cutLeft(), \a cutRight() */
|
|
||||||
PIString & cutMid(const int start, const int len);
|
PIString & cutMid(const int start, const int len);
|
||||||
|
|
||||||
/*! \brief Remove part of string from left and maximum length "len" and return this string
|
//! \~english Remove part of string from start and maximum length "len" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::cutLeft
|
//! \~russian Удаляет часть строки от начала и максимальной длины "len", возвращает эту строку
|
||||||
* \sa \a cutMid(), \a cutRight() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! s.cutLeft(1);
|
||||||
|
//! piCout << s; // s = "123456789"
|
||||||
|
//! s.cutLeft(3);
|
||||||
|
//! piCout << s; // s = "456789"
|
||||||
|
//! s.cutLeft(30);
|
||||||
|
//! piCout << s; // s = ""
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a cutMid(), \a cutRight()
|
||||||
PIString & cutLeft(const int len) {return len <= 0 ? *this : cutMid(0, len);}
|
PIString & cutLeft(const int len) {return len <= 0 ? *this : cutMid(0, len);}
|
||||||
|
|
||||||
/*! \brief Remove part of string from right and maximum length "len" and return this string
|
//! \~english Remove part of string at end and maximum length "len" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::cutRight
|
//! \~russian Удаляет часть строки максимальной длины "len" от конца, возвращает эту строку
|
||||||
* \sa \a cutMid(), \a cutLeft() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! s.cutRight(1);
|
||||||
|
//! piCout << s; // s = "012345678"
|
||||||
|
//! s.cutRight(3);
|
||||||
|
//! piCout << s; // s = "012345"
|
||||||
|
//! s.cutRight(30);
|
||||||
|
//! piCout << s; // s = ""
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a cutMid(), \a cutLeft()
|
||||||
PIString & cutRight(const int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
|
PIString & cutRight(const int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
|
||||||
|
|
||||||
/*! \brief Remove spaces at the start and at the end of string and return this string
|
//! \~english Remove spaces at the start and at the end of string and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::trim
|
//! \~russian Удаляет пробельные символы с начала и конца строки и возвращает эту строку
|
||||||
* \sa \a trimmed() */
|
|
||||||
PIString & trim();
|
PIString & trim();
|
||||||
|
|
||||||
/*! \brief Return copy of this string without spaces at the start and at the end
|
//! \~english Returns copy of this string without spaces at the start and at the end
|
||||||
* \details Example: \snippet pistring.cpp PIString::trimmed
|
//! \~russian Возвращает копию этой строки без пробельных символов с начала и конца
|
||||||
* \sa \a trim() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" \t string \n");
|
||||||
|
//! piCout << s.trimmed(); // s = "string"
|
||||||
|
//! piCout << s; // s = " string "
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a trim()
|
||||||
PIString trimmed() const;
|
PIString trimmed() const;
|
||||||
|
|
||||||
/*! \brief Replace part of string from index "from" and maximum length "len"
|
//! \~english Replace part of string from index "from" and maximum length "len" with string "with" and return this string
|
||||||
* with string "with" and return this string
|
//! \~russian Заменяет часть строки от символа "from" и максимальной длины "len" строкой "with", возвращает эту строку
|
||||||
* \details Example: \snippet pistring.cpp PIString::replace_0
|
|
||||||
* \sa \a replaced(), \a replaceAll() */
|
|
||||||
PIString & replace(const int from, const int count, const PIString & with);
|
PIString & replace(const int from, const int count, const PIString & with);
|
||||||
|
|
||||||
/*! \brief Replace part copy of this string from index "from" and maximum length "len"
|
//! \~english Replace part copy of this string from index "from" and maximum length "len" with string "with"
|
||||||
* with string "with" and return copied string
|
//! \~russian Заменяет часть копии этой строки от символа "from" и максимальной длины "len" строкой "with"
|
||||||
* \details Example: \snippet pistring.cpp PIString::replaced_0
|
//! \~\details
|
||||||
* \sa \a replace(), \a replaceAll() */
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.replaced(2, 3, "_cut_"); // s = "01_cut_56789"
|
||||||
|
//! piCout << s.replaced(0, 1, "one_"); // s = "one_123456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replace(), \a replaceAll()
|
||||||
PIString replaced(const int from, const int count, const PIString & with) const {PIString str(*this); str.replace(from, count, with); return str;}
|
PIString replaced(const int from, const int count, const PIString & with) const {PIString str(*this); str.replace(from, count, with); return str;}
|
||||||
|
|
||||||
/*! \brief Replace first founded substring "what" with string "with" and return this string
|
//! \~english Replace first founded substring "what" with string "with" and return this string
|
||||||
* \details If "ok" is not null, it set to "true" if something was replaced\n
|
//! \~russian Заменяет первую найденную подстроку "what" строкой "with", возвращает эту строку
|
||||||
* Example: \snippet pistring.cpp PIString::replace_1
|
|
||||||
* \sa \a replaced(), \a replaceAll() */
|
|
||||||
PIString & replace(const PIString & what, const PIString & with, bool * ok = 0);
|
PIString & replace(const PIString & what, const PIString & with, bool * ok = 0);
|
||||||
|
|
||||||
/*! \brief Replace first founded substring "what" with string "with" and return copied string
|
//! \~english Replace in string copy first founded substring "what" with string "with"
|
||||||
* \details If "ok" is not null, it set to "true" if something was replaced\n
|
//! \~russian Заменяет в копии строки первую найденную подстроку "what" строкой "with"
|
||||||
* Example: \snippet pistring.cpp PIString::replaced_1
|
//! \~\details
|
||||||
* \sa \a replaced(), \a replaceAll() */
|
//! \~english If "ok" is not null, it set to "true" if something was replaced
|
||||||
|
//! \~russian Если "ok" не null, то устанавливает в "true" если замена произведена
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("pip string");
|
||||||
|
//! bool ok;
|
||||||
|
//! piCout << s.replace("string", "conf", &ok); // s = "pip conf", true
|
||||||
|
//! piCout << s.replace("PIP", "PlInPr", &ok); // s = "pip string", false
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a replaced(), \a replaceAll()
|
||||||
PIString replaced(const PIString & what, const PIString & with, bool * ok = 0) const {PIString str(*this); str.replace(what, with, ok); return str;}
|
PIString replaced(const PIString & what, const PIString & with, bool * ok = 0) const {PIString str(*this); str.replace(what, with, ok); return str;}
|
||||||
|
|
||||||
/*! \brief Replace all founded substrings "what" with strings "with" and return this string
|
//! \~english Replace all founded substrings "what" with strings "with" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::replaceAll
|
//! \~russian Заменяет все найденные подстроки "what" строками "with", возвращает эту строку
|
||||||
* \sa \a replace(), \a replaced() */
|
|
||||||
PIString & replaceAll(const PIString & what, const PIString & with);
|
PIString & replaceAll(const PIString & what, const PIString & with);
|
||||||
|
|
||||||
/*! \brief Replace all founded substrings "what" with symbol "with" and return this string
|
//! \~english Replace all founded substrings "what" with symbols "with" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::replaceAll
|
//! \~russian Заменяет все найденные подстроки "what" символами "with", возвращает эту строку
|
||||||
* \sa \a replace(), \a replaced() */
|
|
||||||
PIString & replaceAll(const PIString & what, const char with);
|
PIString & replaceAll(const PIString & what, const char with);
|
||||||
|
|
||||||
/*! \brief Replace all founded symbols "what" with symbol "with" and return this string
|
//! \~english Replace all founded symbols "what" with symbols "with" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::replaceAll
|
//! \~russian Заменяет все найденные символы "what" символами "with", возвращает эту строку
|
||||||
* \sa \a replace(), \a replaced() */
|
|
||||||
PIString & replaceAll(const char what, const char with);
|
PIString & replaceAll(const char what, const char with);
|
||||||
|
|
||||||
|
//! \~english Replace all founded substrings "what" with strings "with" in string copy
|
||||||
|
//! \~russian Заменяет в копии строки все найденные подстроки "what" строками "with"
|
||||||
|
//! \~\sa \a replaceAll()
|
||||||
PIString replacedAll(const PIString & what, const PIString & with) const {PIString str(*this); str.replaceAll(what, with); return str;}
|
PIString replacedAll(const PIString & what, const PIString & with) const {PIString str(*this); str.replaceAll(what, with); return str;}
|
||||||
|
|
||||||
|
//! \~english Replace all founded substrings "what" with symbols "with" in string copy
|
||||||
|
//! \~russian Заменяет в копии строки все найденные подстроки "what" символами "with"
|
||||||
|
//! \~\sa \a replaceAll()
|
||||||
|
PIString replacedAll(const PIString & what, const char with) const {PIString str(*this); str.replaceAll(what, with); return str;}
|
||||||
|
|
||||||
|
//! \~english Replace all founded symbols "what" with symbols "with" in string copy
|
||||||
|
//! \~russian Заменяет в копии строки все найденные символы "what" символами "with"
|
||||||
|
//! \~\sa \a replaceAll()
|
||||||
PIString replacedAll(const char what, const char with) const {PIString str(*this); str.replaceAll(what, with); return str;}
|
PIString replacedAll(const char what, const char with) const {PIString str(*this); str.replaceAll(what, with); return str;}
|
||||||
|
|
||||||
|
//! \~english Remove all founded substrings "what" and return this string
|
||||||
|
//! \~russian Удаляет все найденные подстроки "what", возвращает эту строку
|
||||||
PIString & removeAll(const PIString & str);
|
PIString & removeAll(const PIString & str);
|
||||||
|
|
||||||
|
//! \~english Remove all founded symbols "what" and return this string
|
||||||
|
//! \~russian Удаляет все найденные символы "what", возвращает эту строку
|
||||||
PIString & removeAll(char c) {PIDeque<PIChar>::removeAll(PIChar(c)); return *this;}
|
PIString & removeAll(char c) {PIDeque<PIChar>::removeAll(PIChar(c)); return *this;}
|
||||||
|
|
||||||
/*! \brief Repeat content of string "times" times and return this string
|
//! \~english Repeat content of string "times" times and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::repeat */
|
//! \~russian Повторяет содержимое строки "times" раз и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" :-) ");
|
||||||
|
//! s.repeat(3);
|
||||||
|
//! piCout << s; // :-) :-) :-)
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a repeated()
|
||||||
PIString & repeat(int times) {PIString ss(*this); times--; piForTimes (times) *this += ss; return *this;}
|
PIString & repeat(int times) {PIString ss(*this); times--; piForTimes (times) *this += ss; return *this;}
|
||||||
|
|
||||||
/*! \brief Returns repeated "times" times string
|
//! \~english Returns repeated "times" times string
|
||||||
* \details Example: \snippet pistring.cpp PIString::repeated */
|
//! \~russian Возвращает повторённую "times" раз строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s(" :-) ");
|
||||||
|
//! piCout << s.repeated(3); // :-) :-) :-)
|
||||||
|
//! piCout << s; // :-)
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a repeat()
|
||||||
PIString repeated(int times) const {PIString ss(*this); return ss.repeat(times);}
|
PIString repeated(int times) const {PIString ss(*this); return ss.repeat(times);}
|
||||||
|
|
||||||
/*! \brief Insert symbol "c" after index "index" and return this string
|
//! \~english Insert symbol "c" after index "index" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::insert_0 */
|
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("pp");
|
||||||
|
//! s.insert(1, "i");
|
||||||
|
//! piCout << s; // s = "pip"
|
||||||
|
//! \endcode
|
||||||
PIString & insert(const int index, const PIChar c) {PIDeque<PIChar>::insert(index, c); return *this;}
|
PIString & insert(const int index, const PIChar c) {PIDeque<PIChar>::insert(index, c); return *this;}
|
||||||
|
|
||||||
/*! \brief Insert symbol "c" after index "index" and return this string
|
//! \~english Insert symbol "c" after index "index" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::insert_1 */
|
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("pp");
|
||||||
|
//! s.insert(1, 'i');
|
||||||
|
//! piCout << s; // s = "pip"
|
||||||
|
//! \endcode
|
||||||
PIString & insert(const int index, const char c) {return insert(index, PIChar(c));}
|
PIString & insert(const int index, const char c) {return insert(index, PIChar(c));}
|
||||||
|
|
||||||
/*! \brief Insert string "str" after index "index" and return this string
|
//! \~english Insert string "str" after index "index" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::insert_2 */
|
//! \~russian Вставляет строку "str" после позиции "index" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("stg");
|
||||||
|
//! s.insert(2, "rin");
|
||||||
|
//! piCout << s; // s = "string"
|
||||||
|
//! \endcode
|
||||||
PIString & insert(const int index, const PIString & str);
|
PIString & insert(const int index, const PIString & str);
|
||||||
|
|
||||||
/*! \brief Insert string "str" after index "index" and return this string
|
//! \~english Insert string "str" after index "index" and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::insert_2 */
|
//! \~russian Вставляет строку "str" после позиции "index" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("stg");
|
||||||
|
//! s.insert(2, "rin");
|
||||||
|
//! piCout << s; // s = "string"
|
||||||
|
//! \endcode
|
||||||
PIString & insert(const int index, const char * c) {return insert(index, PIString(c));}
|
PIString & insert(const int index, const char * c) {return insert(index, PIString(c));}
|
||||||
|
|
||||||
/*! \brief Enlarge string to length "len" by addition sequence of symbols
|
//! \~english Enlarge string to length "len" by addition symbols "c" at the end, and return this string
|
||||||
* "c" at the end of string, and return this string
|
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в конец и возвращает эту строку
|
||||||
* \details Example: \snippet pistring.cpp PIString::expandRightTo
|
//! \~\details
|
||||||
* \sa \a expandLeftTo() */
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! s.expandRightTo(2, "_");
|
||||||
|
//! piCout << s; // s = "str"
|
||||||
|
//! s.expandRightTo(6, "_");
|
||||||
|
//! piCout << s; // s = "str___"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a expandLeftTo(), \a expandedRightTo(), \a expandedLeftTo()
|
||||||
PIString & expandRightTo(const int len, const PIChar c) {if (len > length()) resize(len, c); return *this;}
|
PIString & expandRightTo(const int len, const PIChar c) {if (len > length()) resize(len, c); return *this;}
|
||||||
|
|
||||||
/*! \brief Enlarge string to length "len" by addition sequence of symbols
|
//! \~english Enlarge string to length "len" by addition symbols "c" at the begin, and return this string
|
||||||
* "c" at the beginning of string, and return this string
|
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в начало и возвращает эту строку
|
||||||
* \details Example: \snippet pistring.cpp PIString::expandLeftTo
|
//! \~\details
|
||||||
* \sa \a expandRightTo() */
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! s.expandLeftTo(2, "_");
|
||||||
|
//! piCout << s; // s = "str"
|
||||||
|
//! s.expandLeftTo(6, "_");
|
||||||
|
//! piCout << s; // s = "___str"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a expandRightTo(), \a expandedRightTo(), \a expandedLeftTo()
|
||||||
PIString & expandLeftTo(const int len, const PIChar c) {if (len > length()) insert(0, PIString(len - length(), c)); return *this;}
|
PIString & expandLeftTo(const int len, const PIChar c) {if (len > length()) insert(0, PIString(len - length(), c)); return *this;}
|
||||||
|
|
||||||
/*! \brief Enlarge and returns copy of this string to length "len"
|
//! \~english Enlarge copy of this string to length "len" by addition symbols "c" at the end
|
||||||
* by addition sequence of symbols "c" at the end of string
|
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в конец
|
||||||
* \sa \a expandRightTo() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! piCouy << s.expandedRightTo(5, "_"); // s = "str__"
|
||||||
|
//! piCout << s; // s = "str"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a expandRightTo(), \a expandLeftTo(), \a expandedLeftTo()
|
||||||
PIString expandedRightTo(const int len, const PIChar c) const {return PIString(*this).expandRightTo(len, c);}
|
PIString expandedRightTo(const int len, const PIChar c) const {return PIString(*this).expandRightTo(len, c);}
|
||||||
|
|
||||||
/*! \brief Enlarge and returns copy of this string to length "len"
|
//! \~english Enlarge copy of this string to length "len" by addition symbols "c" at the begin
|
||||||
* by addition sequence of symbols "c" at the beginning of string
|
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в начало
|
||||||
* \sa \a expandLeftTo() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! piCouy << s.expandedLeftTo(5, "_"); // s = "__str"
|
||||||
|
//! piCout << s; // s = "str"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a expandRightTo(), \a expandLeftTo(), \a expandedRightTo()
|
||||||
PIString expandedLeftTo(const int len, const PIChar c) const {return PIString(*this).expandLeftTo(len, c);}
|
PIString expandedLeftTo(const int len, const PIChar c) const {return PIString(*this).expandLeftTo(len, c);}
|
||||||
|
|
||||||
/*! \brief Add "c" symbols at the beginning and end of the string, and return this string
|
//! \~english Add "c" symbols at the beginning and end, and return this string
|
||||||
* \sa \a quoted() */
|
//! \~russian Добавляет символ "c" в начало и конец и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! s.quote();
|
||||||
|
//! piCout << s; // s = ""str""
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a quoted()
|
||||||
PIString & quote(PIChar c = PIChar('"')) {insert(0, c); *this += c; return *this;}
|
PIString & quote(PIChar c = PIChar('"')) {insert(0, c); *this += c; return *this;}
|
||||||
|
|
||||||
/*! \brief Return quoted copy of this string
|
//! \~english Returns quoted copy of this string
|
||||||
* \sa \a quote() */
|
//! \~russian Возвращает копию строки с добавленным в начало и конец символом "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("str");
|
||||||
|
//! piCout << s.quoted(); // s = ""str""
|
||||||
|
//! piCout << s; // s = "str"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a quote()
|
||||||
PIString quoted(PIChar c = PIChar('"')) {return PIString(*this).quote(c);}
|
PIString quoted(PIChar c = PIChar('"')) {return PIString(*this).quote(c);}
|
||||||
|
|
||||||
/*! \brief Reverse string and return this string
|
//! \~english Reverse string and return this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::reverse
|
//! \~russian Разворачивает и возвращает эту строку
|
||||||
* \sa \a reversed() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! s.reverse();
|
||||||
|
//! piCout << s; // s = "9876543210"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a reversed()
|
||||||
PIString & reverse() {PIString str(*this); clear(); piForeachCR (PIChar c, str) push_back(c); return *this;}
|
PIString & reverse() {PIString str(*this); clear(); piForeachCR (PIChar c, str) push_back(c); return *this;}
|
||||||
|
|
||||||
/*! \brief Reverse copy of this string and return it
|
//! \~english Reverse copy of this string
|
||||||
* \details Example: \snippet pistring.cpp PIString::reversed
|
//! \~russian Разворачивает копию этой строки
|
||||||
* \sa \a reverse() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.reversed(); // s = "9876543210"
|
||||||
|
//! piCout << s; // s = "0123456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a reverse()
|
||||||
PIString reversed() const {PIString str(*this); str.reverse(); return str;}
|
PIString reversed() const {PIString str(*this); str.reverse(); return str;}
|
||||||
|
|
||||||
/*! \brief Elide string to maximum size \"size\" and return this string
|
//! \~english Fit string to maximum size "size" by inserting ".." at position "pos" and return this string
|
||||||
* \sa \a elided() */
|
//! \~russian Уменьшает строку до размера "size", вставляя ".." в положение "pos" и возвращает эту строку
|
||||||
|
//! \~\sa \a elided()
|
||||||
PIString & elide(int size, float pos = ElideCenter);
|
PIString & elide(int size, float pos = ElideCenter);
|
||||||
|
|
||||||
/*! \brief Elide copy of this string to maximum size \"size\" and return it
|
//! \~english Fit copy of this string to maximum size "size" by inserting ".." at position "pos"
|
||||||
* \details Example: \snippet pistring.cpp PIString::elided
|
//! \~russian Уменьшает копию этой строки до размера "size", вставляя ".." в положение "pos"
|
||||||
* \sa \a elide() */
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideLeft); // ..ABCDEF
|
||||||
|
//! piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideCenter); // 123..DEF
|
||||||
|
//! piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideRight); // 123456..
|
||||||
|
//! piCout << PIString("123456789ABCDEF").elided(8, 0.25); // 12..CDEF
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a elide()
|
||||||
PIString elided(int size, float pos = ElideCenter) const {PIString str(*this); str.elide(size, pos); return str;}
|
PIString elided(int size, float pos = ElideCenter) const {PIString str(*this); str.elide(size, pos); return str;}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Take a part of string from symbol at index "start" and maximum length "len" and return it
|
//! \~english Take a part of string from symbol at index "start" and maximum length "len" and return it
|
||||||
* \sa \a takeLeft, \a takeRight() */
|
//! \~russian Извлекает часть строки от символа "start" максимальной длины "len" и возвращает её
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.takeMid(1, 3); // "123"
|
||||||
|
//! piCout << s; // s = "0456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeLeft, \a takeRight()
|
||||||
PIString takeMid(const int start, const int len = -1) {PIString ret(mid(start, len)); cutMid(start, len); return ret;}
|
PIString takeMid(const int start, const int len = -1) {PIString ret(mid(start, len)); cutMid(start, len); return ret;}
|
||||||
|
|
||||||
/*! \brief Take a part from the begin of string with maximum length "len" and return it
|
//! \~english Take a part from the begin of string with maximum length "len" and return it
|
||||||
* \sa \a takeMid(), \a takeRight() */
|
//! \~russian Извлекает часть строки от начала максимальной длины "len" и возвращает её
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.takeLeft(3); // "012"
|
||||||
|
//! piCout << s; // s = "3456789"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeMid(), \a takeRight()
|
||||||
PIString takeLeft(const int len) {PIString ret(left(len)); cutLeft(len); return ret;}
|
PIString takeLeft(const int len) {PIString ret(left(len)); cutLeft(len); return ret;}
|
||||||
|
|
||||||
/*! \brief Take a part from the end of string with maximum length "len" and return it
|
//! \~english Take a part from the end of string with maximum length "len" and return it
|
||||||
* \sa \a takeMid(), \a takeLeft() */
|
//! \~russian Извлекает часть строки с конца максимальной длины "len" и возвращает её
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("0123456789");
|
||||||
|
//! piCout << s.takeRight(3); // "789"
|
||||||
|
//! piCout << s; // s = "0123456"
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a takeMid(), \a takeLeft()
|
||||||
PIString takeRight(const int len) {PIString ret(right(len)); cutRight(len); return ret;}
|
PIString takeRight(const int len) {PIString ret(right(len)); cutRight(len); return ret;}
|
||||||
|
|
||||||
/*! \brief Take a symbol from the begin of this string and return it
|
//! \~english Take a symbol from the begin of this string and return it
|
||||||
* \details Example: \snippet pistring.cpp PIString::takeSymbol
|
//! \~russian Извлекает символ с начала строки и возвращает его как строку
|
||||||
* \sa \a takeWord(), \a takeCWord(), \a takeLine(), \a takeNumber(), \a takeRange() */
|
|
||||||
PIString takeSymbol();
|
PIString takeSymbol();
|
||||||
|
|
||||||
/*! \brief Take a word from the begin of this string and return it
|
//! \~english Take a word from the begin of this string and return it
|
||||||
* \details Example: \snippet pistring.cpp PIString::takeWord
|
//! \~russian Извлекает слово с начала строки и возвращает его
|
||||||
* \sa \a takeSymbol(), \a takeCWord(), \a takeLine(), \a takeNumber(), \a takeRange() */
|
|
||||||
PIString takeWord();
|
PIString takeWord();
|
||||||
|
|
||||||
/*! \brief Take a word with letters, numbers and '_' symbols from the
|
//! \~english Take a word with letters, numbers and '_' symbols from the begin of this string and return it
|
||||||
* begin of this string and return it
|
//! \~russian Извлекает слово из букв, цифр и симолов '_' с начала строки и возвращает его
|
||||||
* \details Example: \snippet pistring.cpp PIString::takeCWord
|
|
||||||
* \sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber(), \a takeRange() */
|
|
||||||
PIString takeCWord();
|
PIString takeCWord();
|
||||||
|
|
||||||
/*! \brief Take a line from the begin of this string and return it
|
//! \~english Take a line from the begin of this string and return it
|
||||||
* \details Example: \snippet pistring.cpp PIString::takeLine
|
//! \~russian Извлекает строку текста (до новой строки) с начала строки и возвращает её
|
||||||
* \sa \a takeSymbol(), \a takeWord(), \a takeCWord(), \a takeNumber(), \a takeRange() */
|
|
||||||
PIString takeLine();
|
PIString takeLine();
|
||||||
|
|
||||||
/*! \brief Take a number with C-format from the begin of this string and return it
|
//! \~english Take a number with C-format from the begin of this string and return it
|
||||||
* \details Example: \snippet pistring.cpp PIString::takeNumber
|
//! \~russian Извлекает число в C-формате с начала строки и возвращает его как строку
|
||||||
* \sa \a takeSymbol(), \a takeWord(), \a takeCWord(), \a takeLine(), \a takeRange() */
|
|
||||||
PIString takeNumber();
|
PIString takeNumber();
|
||||||
|
|
||||||
/*! \brief Take a range between "start" and "end" symbols from the begin of this
|
//! \~english Take a range between "start" and "end" symbols from the begin of this string and return it
|
||||||
* string and return it.
|
//! \~russian Извлекает диапазон между символами "start" и "end" с начала строки и возвращает его
|
||||||
* \details "Shield" symbol prevent analysis of the next symbol.
|
|
||||||
* Example: \snippet pistring.cpp PIString::takeRange
|
|
||||||
* \sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber() */
|
|
||||||
PIString takeRange(const PIChar start, const PIChar end, const PIChar shield = '\\');
|
PIString takeRange(const PIChar start, const PIChar end, const PIChar shield = '\\');
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Return a string in brackets "start" and "end" symbols from the begin of this
|
//! \~english Returns string in brackets "start" and "end" symbols from the beginning
|
||||||
* string and return it.
|
//! \~russian Возвращает строку между символами "start" и "end" с начала строки
|
||||||
* \details Example: string = "a(b(c)d)e"; inBrackets('(', ')') = "b(c)d"; */
|
|
||||||
PIString inBrackets(const PIChar start, const PIChar end) const;
|
PIString inBrackets(const PIChar start, const PIChar end) const;
|
||||||
|
|
||||||
/*! \brief Return real bytes count of this string
|
//! \~english Returns bytes count of this string in system codepage
|
||||||
* \details It`s equivalent length of char sequence
|
//! \~russian Возвращает объем строки в системной кодировке
|
||||||
* returned by function \a data() - 1, without terminating null-char \n
|
int lengthAscii() const;
|
||||||
* Example: \snippet pistring.cpp PIString::lengthAscii
|
|
||||||
* \sa \a data() */
|
|
||||||
int lengthAscii() const {buildData(__syslocname__); return data_.size_s() - 1;}
|
|
||||||
|
|
||||||
/*! \brief Return \c char * representation of this string in system codepage
|
//! \~english Returns \c char * representation of this string in system codepage
|
||||||
* \details This function fill buffer by sequence
|
//! \~russian Возвращает \c char * представление строки в системной кодировке
|
||||||
* of chars. Minimum length of this buffer is count
|
const char * data() const;
|
||||||
* of symbols. Returned \c char * is valid until next
|
|
||||||
* execution of this function.\n
|
|
||||||
* Example: \snippet pistring.cpp PIString::data
|
|
||||||
* \sa \a dataConsole(), \a dataUTF8() */
|
|
||||||
const char * data() const {buildData(__syslocname__); return (const char *)(data_.data());}
|
|
||||||
|
|
||||||
/*! \brief Return \c char * representation of this string in terminal codepage
|
//! \~english Returns \c char * representation of this string in terminal codepage
|
||||||
* \details This function fill buffer by sequence
|
//! \~russian Возвращает \c char * представление строки в кодировке консоли
|
||||||
* of chars. Minimum length of this buffer is count
|
|
||||||
* of symbols. Returned \c char * is valid until next
|
|
||||||
* execution of this function.\n
|
|
||||||
* \sa \a data(), \a dataUTF8() */
|
|
||||||
const char * dataConsole() const;
|
const char * dataConsole() const;
|
||||||
|
|
||||||
/*! \brief Return \c char * representation of this string in UTF-8
|
//! \~english Returns \c char * representation of this string in UTF-8
|
||||||
* \details This function fill buffer by sequence
|
//! \~russian Возвращает \c char * представление строки в кодировке UTF-8
|
||||||
* of chars. Minimum length of this buffer is count
|
|
||||||
* of symbols. Returned \c char * is valid until next
|
|
||||||
* execution of this function.\n
|
|
||||||
* \sa \a data(), \a dataConsole() */
|
|
||||||
const char * dataUTF8() const;
|
const char * dataUTF8() const;
|
||||||
|
|
||||||
/*! \brief Return \c char * representation of this string in ASCII
|
//! \~english Returns \c char * representation of this string in ASCII
|
||||||
* \details This function fill buffer by sequence
|
//! \~russian Возвращает \c char * представление строки в кодировке ASCII
|
||||||
* of chars. Minimum length of this buffer is count
|
|
||||||
* of symbols. Returned \c char * is valid until next
|
|
||||||
* execution of this function.\n */
|
|
||||||
const char * dataAscii() const;
|
const char * dataAscii() const;
|
||||||
|
|
||||||
//! Returns hash
|
//! \~english Returns hash
|
||||||
|
//! \~russian Возвращает хэш
|
||||||
uint hash() const;
|
uint hash() const;
|
||||||
|
|
||||||
//! \brief Return \a PIByteArray contains \a data() of this string without terminating null-char
|
//! \~english Returns \a PIByteArray contains \a data() of this string without terminating null-char
|
||||||
|
//! \~russian Возвращает \a PIByteArray содержащий \a data() строки без завершающего нулевого байта
|
||||||
PIByteArray toByteArray() const {buildData(__utf8name__); return data_.resized(data_.size_s() - 1);}
|
PIByteArray toByteArray() const {buildData(__utf8name__); return data_.resized(data_.size_s() - 1);}
|
||||||
|
|
||||||
//! \brief Return \a PIByteArray contains UTF-8 \a data() of this string without terminating null-char
|
//! \~english Returns \a PIByteArray contains \a dataUTF8() of this string without terminating null-char
|
||||||
|
//! \~russian Возвращает \a PIByteArray содержащий \a dataUTF8() строки без завершающего нулевого байта
|
||||||
PIByteArray toUTF8() const;
|
PIByteArray toUTF8() const;
|
||||||
|
|
||||||
//! \brief Return \a PIByteArray contains custom charset representation of this string without terminating null-char
|
//! \~english Returns \a PIByteArray contains custom charset representation of this string without terminating null-char
|
||||||
|
//! \~russian Возвращает \a PIByteArray содержащий строку в указанной кодировке без завершающего нулевого байта
|
||||||
PIByteArray toCharset(const char * c) const;
|
PIByteArray toCharset(const char * c) const;
|
||||||
|
|
||||||
/*! \brief Split string with delimiter "delim" to \a PIStringList and return it
|
//! \~english Split string with delimiter "delim" to \a PIStringList
|
||||||
* \details Example: \snippet pistring.cpp PIString::split */
|
//! \~russian Разделяет строку в \a PIStringList через разделитель "delim"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("1 2 3");
|
||||||
|
//! piCout << s.split(" "); // {"1", "2", "3"}
|
||||||
|
//! \endcode
|
||||||
PIStringList split(const PIString & delim) const;
|
PIStringList split(const PIString & delim) const;
|
||||||
|
|
||||||
|
|
||||||
//! \brief Convert each symbol in copyed string to upper case and return it
|
//! \~english Convert each symbol in copied string to upper case
|
||||||
|
//! \~russian Преобразует каждый символ в скопированной строке в верхний регистр
|
||||||
PIString toUpperCase() const;
|
PIString toUpperCase() const;
|
||||||
|
|
||||||
//! \brief Convert each symbol in copyed string to lower case and return it
|
//! \~english Convert each symbol in copied string to lower case
|
||||||
|
//! \~russian Преобразует каждый символ в скопированной строке в нижний регистр
|
||||||
PIString toLowerCase() const;
|
PIString toLowerCase() const;
|
||||||
|
|
||||||
PIString toNativeDecimalPoints() const;
|
PIString toNativeDecimalPoints() const;
|
||||||
|
|
||||||
|
|
||||||
//! \brief Returns if string contains "c"
|
//! \~english Returns if string contains symbol "c"
|
||||||
|
//! \~russian Возвращает содержит ли строка символ "c"
|
||||||
bool contains(const char c) const {return PIDeque<PIChar>::contains(PIChar(c));}
|
bool contains(const char c) const {return PIDeque<PIChar>::contains(PIChar(c));}
|
||||||
|
|
||||||
//! \brief Returns if string contains "str"
|
//! \~english Returns if string contains substring "str"
|
||||||
|
//! \~russian Возвращает содержит ли строка подстроку "str"
|
||||||
bool contains(const char * str) const {return contains(PIString(str));}
|
bool contains(const char * str) const {return contains(PIString(str));}
|
||||||
|
|
||||||
//! \brief Returns if string contains "str"
|
//! \~english Returns if string contains substring "str"
|
||||||
|
//! \~russian Возвращает содержит ли строка подстроку "str"
|
||||||
bool contains(const PIString & str) const {return find(str) >= 0;}
|
bool contains(const PIString & str) const {return find(str) >= 0;}
|
||||||
|
|
||||||
|
|
||||||
//! \brief Search symbol "c" from symbol at index "start" and return first occur position
|
//! \~english Search symbol "c" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::find
|
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение
|
||||||
int find(const char c, const int start = 0) const;
|
int find(const char c, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::find
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
||||||
int find(const PIString & str, const int start = 0) const;
|
int find(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::find
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.find("-"); // -1
|
||||||
|
//! piCout << s.find("34"); // 3
|
||||||
|
//! piCout << s.find("3", 4); // 9
|
||||||
|
//! piCout << s.find("3", 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int find(const char * str, const int start = 0) const {return find(PIString(str), start);}
|
int find(const char * str, const int start = 0) const {return find(PIString(str), start);}
|
||||||
|
|
||||||
//! \brief Search symbol "c" from symbol at index "start" and return last occur position
|
//! \~english Search any symbol of "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findLast
|
//! \~russian Ищет любой символ строки "str" от симола "start" и возвращает первое вхождение
|
||||||
int findLast(const char c, const int start = 0) const;
|
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findLast
|
|
||||||
int findLast(const PIString & str, const int start = 0) const;
|
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findLast
|
|
||||||
int findLast(const char * str, const int start = 0) const {return findLast(PIString(str), start);}
|
|
||||||
|
|
||||||
//! \brief Search word "word" from symbol at index "start" and return first occur position.
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findWord
|
|
||||||
int findWord(const PIString & word, const int start = 0) const;
|
|
||||||
|
|
||||||
//! \brief Search C-style word "word" from symbol at index "start" and return first occur position.
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findCWord
|
|
||||||
int findCWord(const PIString & word, const int start = 0) const;
|
|
||||||
|
|
||||||
//! \brief Search range between "start" and "end" symbols at index "start_index" and return first occur position.
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findRange
|
|
||||||
int findRange(const PIChar start, const PIChar end, const PIChar shield = '\\', const int start_index = 0, int * len = 0) const;
|
|
||||||
|
|
||||||
//! \brief Search any symbol of "str" from symbol at index "start" and return first occur position
|
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findAny
|
|
||||||
int findAny(const PIString & str, const int start = 0) const;
|
int findAny(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search any symbol of "str" from symbol at index "start" and return first occur position
|
//! \~english Search any symbol of "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findAny
|
//! \~russian Ищет любой символ строки "str" от симола "start" и возвращает первое вхождение
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("1.str").findAny(".,:"); // 1
|
||||||
|
//! piCout << PIString("1,str").findAny(".,:"); // 1
|
||||||
|
//! piCout << PIString("1:str").findAny(".,:"); // 1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int findAny(const char * str, const int start = 0) const {return findAny(PIString(str), start);}
|
int findAny(const char * str, const int start = 0) const {return findAny(PIString(str), start);}
|
||||||
|
|
||||||
//! \brief Search any symbol of "str" from symbol at index "start" and return last occur position
|
//! \~english Search symbol "c" from symbol at index "start" and return last occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findAnyLast
|
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение
|
||||||
|
int findLast(const char c, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
||||||
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
||||||
|
int findLast(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
||||||
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s("012345012345");
|
||||||
|
//! piCout << s.findLast("-"); // -1
|
||||||
|
//! piCout << s.findLast("34"); // 9
|
||||||
|
//! piCout << s.findLast("3", 4); // 9
|
||||||
|
//! piCout << s.findLast("3", 10); // -1
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
|
int findLast(const char * str, const int start = 0) const {return findLast(PIString(str), start);}
|
||||||
|
|
||||||
|
//! \~english Search any symbol of "str" from symbol at index "start" and return last occur position
|
||||||
|
//! \~russian Ищет любой символ строки "str" от символа "start" и возвращает последнее вхождение
|
||||||
int findAnyLast(const PIString & str, const int start = 0) const;
|
int findAnyLast(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search any symbol of "str" from symbol at index "start" and return last occur position
|
//! \~english Search any symbol of "str" from symbol at index "start" and return last occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findAnyLast
|
//! \~russian Ищет любой символ строки "str" от символа "start" и возвращает последнее вхождение
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString(".str.0").findAnyLast(".,:"); // 4
|
||||||
|
//! piCout << PIString(".str,0").findAnyLast(".,:"); // 4
|
||||||
|
//! piCout << PIString(".str:0").findAnyLast(".,:"); // 4
|
||||||
|
//! \endcode
|
||||||
|
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||||
int findAnyLast(const char * str, const int start = 0) const {return findAnyLast(PIString(str), start);}
|
int findAnyLast(const char * str, const int start = 0) const {return findAnyLast(PIString(str), start);}
|
||||||
|
|
||||||
//! \brief Returns number of occurrences of symbol "c"
|
//! \~english Search word "word" from symbol at index "start" and return first occur position
|
||||||
|
//! \~russian Ищет слово "word" от симола "start" и возвращает первое вхождение
|
||||||
|
int findWord(const PIString & word, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~english Search C-word "word" from symbol at index "start" and return first occur position
|
||||||
|
//! \~russian Ищет C-слово "word" от симола "start" и возвращает первое вхождение
|
||||||
|
int findCWord(const PIString & word, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~english Search range start between "start" and "end" symbols at index "start_index" and return first occur position
|
||||||
|
//! \~russian Ищет начало диапазона между символами "start" и "end" от симола "start" и возвращает первое вхождение
|
||||||
|
int findRange(const PIChar start, const PIChar end, const PIChar shield = '\\', const int start_index = 0, int * len = 0) const;
|
||||||
|
|
||||||
|
//! \~english Returns number of occurrences of symbol "c"
|
||||||
|
//! \~russian Возвращает число вхождений символа "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString(".str.0").entries("."); // 2
|
||||||
|
//! piCout << PIString(".str.0").entries("0"); // 1
|
||||||
|
//! \endcode
|
||||||
int entries(const PIChar c) const;
|
int entries(const PIChar c) const;
|
||||||
|
|
||||||
//! \brief Returns number of occurrences of symbol "c"
|
//! \~english Returns number of occurrences of symbol "c"
|
||||||
|
//! \~russian Возвращает число вхождений символа "c"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString(".str.0").entries('.'); // 2
|
||||||
|
//! piCout << PIString(".str.0").entries('0'); // 1
|
||||||
|
//! \endcode
|
||||||
int entries(char c) const {return entries(PIChar(c));}
|
int entries(char c) const {return entries(PIChar(c));}
|
||||||
|
|
||||||
//! \brief Return if string starts with "str"
|
//! \~english Returns if string starts with "str"
|
||||||
|
//! \~russian Возвращает начинается ли строка со "str"
|
||||||
bool startsWith(const PIString & str) const;
|
bool startsWith(const PIString & str) const;
|
||||||
|
|
||||||
//! \brief Return if string ends with "str"
|
//! \~english Returns if string ends with "str"
|
||||||
|
//! \~russian Возвращает оканчивается ли строка на "str"
|
||||||
bool endsWith(const PIString & str) const;
|
bool endsWith(const PIString & str) const;
|
||||||
|
|
||||||
//! \brief Return symbols length of string
|
//! \~english Returns symbols length of string
|
||||||
|
//! \~russian Возвращает длину строки в символах
|
||||||
int length() const {return size();}
|
int length() const {return size();}
|
||||||
|
|
||||||
//! \brief Return \c true if string is empty, i.e. length = 0
|
//! \~english Returns \c true if string is empty, i.e. length = 0
|
||||||
|
//! \~russian Возвращает \c true если строка пустая, т.е. длина = 0
|
||||||
bool isEmpty() const {return (size() == 0 || *this == "");}
|
bool isEmpty() const {return (size() == 0 || *this == "");}
|
||||||
|
|
||||||
|
//! \~english Returns \c true if string is not empty, i.e. length > 0
|
||||||
|
//! \~russian Возвращает \c true если строка непустая, т.е. длина > 0
|
||||||
|
bool isNotEmpty() const {return !isEmpty();}
|
||||||
|
|
||||||
//! \brief Return \c true if string equal "true", "yes", "on" or positive not null numeric value
|
|
||||||
|
//! \~english Returns \c true if string equal "true", "yes", "on" or positive not null numeric value
|
||||||
|
//! \~russian Возвращает \c true если строка равна "true", "yes", "on" или числу > 0
|
||||||
bool toBool() const;
|
bool toBool() const;
|
||||||
|
|
||||||
//! \brief Return \c char numeric value of string
|
//! \~english Returns \c char numeric value of string
|
||||||
|
//! \~russian Возвращает \c char числовое значение строки
|
||||||
char toChar() const;
|
char toChar() const;
|
||||||
|
|
||||||
//! \brief Return \c short numeric value of string in base "base"
|
//! \~english Returns \c short numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c short числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toShort(); // 123
|
||||||
|
//! piCout << PIString("123").toShort(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toShort(); // 291
|
||||||
|
//! piCout << PIString("1001").toShort(2); // 9
|
||||||
|
//! \endcode
|
||||||
short toShort(int base = -1, bool * ok = 0) const {return short(toNumberBase(*this, base, ok));}
|
short toShort(int base = -1, bool * ok = 0) const {return short(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c ushort numeric value of string in base "base"
|
//! \~english Returns \c ushort numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c ushort числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toUShort(); // 123
|
||||||
|
//! piCout << PIString("123").toUShort(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toUShort(); // 291
|
||||||
|
//! piCout << PIString("1001").toUShort(2); // 9
|
||||||
|
//! \endcode
|
||||||
ushort toUShort(int base = -1, bool * ok = 0) const {return ushort(toNumberBase(*this, base, ok));}
|
ushort toUShort(int base = -1, bool * ok = 0) const {return ushort(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c int numeric value of string in base "base"
|
//! \~english Returns \c int numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c int числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toInt(); // 123
|
||||||
|
//! piCout << PIString("123").toInt(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toInt(); // 291
|
||||||
|
//! piCout << PIString("1001").toInt(2); // 9
|
||||||
|
//! \endcode
|
||||||
int toInt(int base = -1, bool * ok = 0) const {return int(toNumberBase(*this, base, ok));}
|
int toInt(int base = -1, bool * ok = 0) const {return int(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c uint numeric value of string in base "base"
|
//! \~english Returns \c uint numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c uint числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toUInt(); // 123
|
||||||
|
//! piCout << PIString("123").toUInt(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toUInt(); // 291
|
||||||
|
//! piCout << PIString("1001").toUInt(2); // 9
|
||||||
|
//! \endcode
|
||||||
uint toUInt(int base = -1, bool * ok = 0) const {return uint(toNumberBase(*this, base, ok));}
|
uint toUInt(int base = -1, bool * ok = 0) const {return uint(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c long numeric value of string in base "base"
|
//! \~english Returns \c long numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c long числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toLong(); // 123
|
||||||
|
//! piCout << PIString("123").toLong(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toLong(); // 291
|
||||||
|
//! piCout << PIString("1001").toLong(2); // 9
|
||||||
|
//! \endcode
|
||||||
long toLong(int base = -1, bool * ok = 0) const {return long(toNumberBase(*this, base, ok));}
|
long toLong(int base = -1, bool * ok = 0) const {return long(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c ulong numeric value of string in base "base"
|
//! \~english Returns \c ulong numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c ulong числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toULong(); // 123
|
||||||
|
//! piCout << PIString("123").toULong(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toULong(); // 291
|
||||||
|
//! piCout << PIString("1001").toULong(2); // 9
|
||||||
|
//! \endcode
|
||||||
ulong toULong(int base = -1, bool * ok = 0) const {return ulong(toNumberBase(*this, base, ok));}
|
ulong toULong(int base = -1, bool * ok = 0) const {return ulong(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c llong numeric value of string in base "base"
|
//! \~english Returns \c llong numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c llong числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toLLong(); // 123
|
||||||
|
//! piCout << PIString("123").toLLong(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toLLong(); // 291
|
||||||
|
//! piCout << PIString("1001").toLLong(2); // 9
|
||||||
|
//! \endcode
|
||||||
llong toLLong(int base = -1, bool * ok = 0) const {return toNumberBase(*this, base, ok);}
|
llong toLLong(int base = -1, bool * ok = 0) const {return toNumberBase(*this, base, ok);}
|
||||||
|
|
||||||
//! \brief Return \c ullong numeric value of string in base "base"
|
//! \~english Returns \c ullong numeric value of string in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toNumber
|
//! \~russian Возвращает \c ullong числовое значение строки по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~english If "base" < 0 then base automatically select 16 if string start with "0x", therwise 10
|
||||||
|
//! \~russian Если "base" < 0 тогда основание автоматически принимается 16 если строка начинается с "0x", иначе 10
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toULLong(); // 123
|
||||||
|
//! piCout << PIString("123").toULLong(16); // 291
|
||||||
|
//! piCout << PIString("0x123").toULLong(); // 291
|
||||||
|
//! piCout << PIString("1001").toULLong(2); // 9
|
||||||
|
//! \endcode
|
||||||
ullong toULLong(int base = -1, bool * ok = 0) const {return ullong(toNumberBase(*this, base, ok));}
|
ullong toULLong(int base = -1, bool * ok = 0) const {return ullong(toNumberBase(*this, base, ok));}
|
||||||
|
|
||||||
//! \brief Return \c float numeric value of string
|
//! \~english Returns \c float numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \~russian Возвращает \c float числовое значение строки
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toFloat(); // 123
|
||||||
|
//! piCout << PIString("1.2E+2").toFloat(); // 120
|
||||||
|
//! piCout << PIString("0.01").toFloat(); // 0.01
|
||||||
|
//! \endcode
|
||||||
float toFloat() const;
|
float toFloat() const;
|
||||||
|
|
||||||
//! \brief Return \c double numeric value of string
|
//! \~english Returns \c double numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \~russian Возвращает \c double числовое значение строки
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toDouble(); // 123
|
||||||
|
//! piCout << PIString("1.2E+2").toDouble(); // 120
|
||||||
|
//! piCout << PIString("0.01").toDouble(); // 0.01
|
||||||
|
//! \endcode
|
||||||
double toDouble() const;
|
double toDouble() const;
|
||||||
|
|
||||||
//! \brief Return \c ldouble numeric value of string
|
//! \~english Returns \c ldouble numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \~russian Возвращает \c ldouble числовое значение строки
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString("123").toLDouble(); // 123
|
||||||
|
//! piCout << PIString("1.2E+2").toLDouble(); // 120
|
||||||
|
//! piCout << PIString("0.01").toLDouble(); // 0.01
|
||||||
|
//! \endcode
|
||||||
ldouble toLDouble() const;
|
ldouble toLDouble() const;
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const ushort value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const ushort value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const int value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const int value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const uint value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const uint value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const long value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const long value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const ulong value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const ulong value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const llong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const llong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value" in base "base"
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setNumber
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(123);
|
||||||
|
//! piCout << s; // 123
|
||||||
|
//! s.setNumber(123, 16);
|
||||||
|
//! piCout << s; // 7B
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const ullong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
PIString & setNumber(const ullong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value"
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setFloat
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(12.3);
|
||||||
|
//! piCout << s; // 12.30000000
|
||||||
|
//! s.setNumber(12.3, 'f', 3);
|
||||||
|
//! piCout << s; // 12.300
|
||||||
|
//! s.setNumber(12.123456, 'f', 3);
|
||||||
|
//! piCout << s; // 12.123
|
||||||
|
//! s.setNumber(123456789., 'g', 2);
|
||||||
|
//! piCout << s; // 1.2e+08
|
||||||
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
|
//! piCout << s; // 123456789
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const float value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
PIString & setNumber(const float value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value"
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setFloat
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(12.3);
|
||||||
|
//! piCout << s; // 12.30000000
|
||||||
|
//! s.setNumber(12.3, 'f', 3);
|
||||||
|
//! piCout << s; // 12.300
|
||||||
|
//! s.setNumber(12.123456, 'f', 3);
|
||||||
|
//! piCout << s; // 12.123
|
||||||
|
//! s.setNumber(123456789., 'g', 2);
|
||||||
|
//! piCout << s; // 1.2e+08
|
||||||
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
|
//! piCout << s; // 123456789
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const double & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
PIString & setNumber(const double & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to numeric representation of "value"
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setFloat
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! PIString s;
|
||||||
|
//! s.setNumber(12.3);
|
||||||
|
//! piCout << s; // 12.30000000
|
||||||
|
//! s.setNumber(12.3, 'f', 3);
|
||||||
|
//! piCout << s; // 12.300
|
||||||
|
//! s.setNumber(12.123456, 'f', 3);
|
||||||
|
//! piCout << s; // 12.123
|
||||||
|
//! s.setNumber(123456789., 'g', 2);
|
||||||
|
//! piCout << s; // 1.2e+08
|
||||||
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
|
//! piCout << s; // 123456789
|
||||||
|
//! \endcode
|
||||||
PIString & setNumber(const ldouble & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
PIString & setNumber(const ldouble & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||||
|
|
||||||
//! \brief Set string content to human readable size in B/kB/MB/GB/TB
|
//! \~english Set string content to human readable size in B/kB/MB/GB/TB/PB
|
||||||
//! \details Example: \snippet pistring.cpp PIString::setReadableSize
|
//! \~russian Устанавливает содержимое в строку с читаемым размером B/kB/MB/GB/TB/PB
|
||||||
|
//! \~\sa PIString::readableSize()
|
||||||
PIString & setReadableSize(llong bytes);
|
PIString & setReadableSize(llong bytes);
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const ushort value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
static PIString fromNumber(const ushort value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const int value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
static PIString fromNumber(const int value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const uint value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
static PIString fromNumber(const uint value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const long value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
static PIString fromNumber(const long value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const ulong value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
static PIString fromNumber(const ulong value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const llong & value, int base = 10, bool * ok = 0) {return fromNumberBaseS(value, base, ok);}
|
static PIString fromNumber(const llong & value, int base = 10, bool * ok = 0) {return fromNumberBaseS(value, base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value" in base "base"
|
//! \~english Returns string contains numeric representation of "value" in base "base"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromNumber
|
//! \~russian Возвращает строковое представление числа "value" по основанию "base"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(123); // 123
|
||||||
|
//! piCout << PIString::fromNumber(123, 16); // 7B
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const ullong & value, int base = 10, bool * ok = 0) {return fromNumberBaseU(value, base, ok);}
|
static PIString fromNumber(const ullong & value, int base = 10, bool * ok = 0) {return fromNumberBaseU(value, base, ok);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value"
|
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromFloat
|
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(12.3); // 12.30000000
|
||||||
|
//! piCout << PIString::fromNumber(12.3, 'f', 3); // 12.300
|
||||||
|
//! piCout << PIString::fromNumber(12.123456, 'f', 3); // 12.123
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const float value, char format = 'f', int precision = 8) {return ftos(value, format, precision);}
|
static PIString fromNumber(const float value, char format = 'f', int precision = 8) {return ftos(value, format, precision);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value"
|
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromFloat
|
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(12.3); // 12.30000000
|
||||||
|
//! piCout << PIString::fromNumber(12.3, 'f', 3); // 12.300
|
||||||
|
//! piCout << PIString::fromNumber(12.123456, 'f', 3); // 12.123
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const double & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
|
static PIString fromNumber(const double & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
|
||||||
|
|
||||||
//! \brief Return string contains numeric representation of "value"
|
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision"
|
||||||
//! \details Example: \snippet pistring.cpp PIString::fromFloat
|
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision"
|
||||||
|
//! \~\details
|
||||||
|
//! \~\code
|
||||||
|
//! piCout << PIString::fromNumber(12.3); // 12.30000000
|
||||||
|
//! piCout << PIString::fromNumber(12.3, 'f', 3); // 12.300
|
||||||
|
//! piCout << PIString::fromNumber(12.123456, 'f', 3); // 12.123
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
|
||||||
|
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
|
||||||
|
//! \endcode
|
||||||
static PIString fromNumber(const ldouble & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
|
static PIString fromNumber(const ldouble & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
|
||||||
|
|
||||||
//! \brief Return "true" or "false"
|
//! \~english Returns "true" or "false"
|
||||||
|
//! \~russian Возвращает "true" или "false"
|
||||||
static PIString fromBool(const bool value) {return PIString(value ? "true" : "false");}
|
static PIString fromBool(const bool value) {return PIString(value ? "true" : "false");}
|
||||||
|
|
||||||
//! \brief Return string constructed from terminal codepage
|
//! \~english Returns string constructed from terminal codepage
|
||||||
|
//! \~russian Возвращает строку созданную из кодировки консоли
|
||||||
static PIString fromConsole(const char * s);
|
static PIString fromConsole(const char * s);
|
||||||
|
|
||||||
//! \brief Return string constructed from system codepage
|
//! \~english Returns string constructed from system codepage
|
||||||
|
//! \~russian Возвращает строку созданную из кодировки системы
|
||||||
static PIString fromSystem(const char * s);
|
static PIString fromSystem(const char * s);
|
||||||
|
|
||||||
//! \brief Return string constructed from UTF-8
|
//! \~english Returns string constructed from UTF-8
|
||||||
|
//! \~russian Возвращает строку созданную из UTF-8
|
||||||
static PIString fromUTF8(const char * s);
|
static PIString fromUTF8(const char * s);
|
||||||
|
|
||||||
//! \brief Return string constructed from UTF-8
|
//! \~english Returns string constructed from UTF-8
|
||||||
static PIString fromUTF8(const PIByteArray &ba);
|
//! \~russian Возвращает строку созданную из UTF-8
|
||||||
|
static PIString fromUTF8(const PIByteArray & utf);
|
||||||
|
|
||||||
//! \brief Return string constructed from ASCII
|
//! \~english Returns string constructed from ASCII
|
||||||
|
//! \~russian Возвращает строку созданную из ASCII
|
||||||
static PIString fromAscii(const char * s);
|
static PIString fromAscii(const char * s);
|
||||||
|
|
||||||
//! \brief Return string constructed from "len" chars ASCII
|
//! \~english Returns string constructed from "len" chars ASCII
|
||||||
|
//! \~russian Возвращает строку созданную из "len" символов ASCII
|
||||||
static PIString fromAscii(const char * s, int len);
|
static PIString fromAscii(const char * s, int len);
|
||||||
|
|
||||||
//! \brief Return string constructed from "c" codepage
|
//! \~english Returns string constructed from "cp" codepage
|
||||||
static PIString fromCodepage(const char * s, const char * c);
|
//! \~russian Возвращает строку созданную из кодировки "cp"
|
||||||
|
static PIString fromCodepage(const char * s, const char * cp);
|
||||||
|
|
||||||
//! \brief Return string contains human readable size in B/kB/MB/GB/TB
|
//! \~english Returns string contains human readable size in B/kB/MB/GB/TB/PB
|
||||||
//! \details Example: \snippet pistring.cpp PIString::readableSize
|
//! \~russian Возвращает строку с читаемым размером B/kB/MB/GB/TB/PB
|
||||||
|
//! \~\sa PIString::setReadableSize()
|
||||||
static PIString readableSize(llong bytes);
|
static PIString readableSize(llong bytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -752,40 +1350,59 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PICout \brief Output operator to PICout
|
//! \relatesalso PICout
|
||||||
|
//! \~english Output operator to \a PICout
|
||||||
|
//! \~russian Оператор вывода в \a PICout
|
||||||
PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
||||||
|
|
||||||
|
//! \relatesalso PIByteArray
|
||||||
//! \relatesalso PIByteArray \brief Output operator to PIByteArray
|
//! \~english Store operator
|
||||||
|
//! \~russian Оператор сохранения
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << *(PIDeque<PIChar>*)&v; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << *(PIDeque<PIChar>*)&v; return s;}
|
||||||
|
|
||||||
//! \relatesalso PIByteArray \brief Input operator from PIByteArray
|
//! \relatesalso PIByteArray
|
||||||
|
//! \~english Restore operator
|
||||||
|
//! \~russian Оператор извлечения
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.clear(); s >> *(PIDeque<PIChar>*)&v; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.clear(); s >> *(PIDeque<PIChar>*)&v; return s;}
|
||||||
|
|
||||||
|
|
||||||
//! \brief Return concatenated string
|
//! \~english Returns concatenated string
|
||||||
|
//! \~russian Возвращает соединение строк
|
||||||
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
|
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
|
||||||
|
|
||||||
//! \brief Return concatenated string
|
//! \~english Returns concatenated string
|
||||||
|
//! \~russian Возвращает соединение строк
|
||||||
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
|
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
|
||||||
|
|
||||||
//! \brief Return concatenated string
|
//! \~english Returns concatenated string
|
||||||
|
//! \~russian Возвращает соединение строк
|
||||||
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
|
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
//! \~english Returns concatenated string
|
||||||
|
//! \~russian Возвращает соединение строк
|
||||||
inline PIString operator +(const char c, const PIString & f) {return PIChar(c) + f;}
|
inline PIString operator +(const char c, const PIString & f) {return PIChar(c) + f;}
|
||||||
|
|
||||||
//! \brief Return concatenated string
|
//! \~english Returns concatenated string
|
||||||
|
//! \~russian Возвращает соединение строк
|
||||||
inline PIString operator +(const PIString & f, const char c) {return f + PIChar(c);}
|
inline PIString operator +(const PIString & f, const char c) {return f + PIChar(c);}
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIString
|
||||||
|
//! \~english Compare two version strings in free notation and returns 0, -1 or 1
|
||||||
|
//! \~russian Сравнивает две строки с версиями в произвольной форме и возвращает 0, -1 или 1
|
||||||
int PIP_EXPORT versionCompare(const PIString & v0, const PIString & v1, int components = 6);
|
int PIP_EXPORT versionCompare(const PIString & v0, const PIString & v1, int components = 6);
|
||||||
|
|
||||||
|
//! \relatesalso PIString
|
||||||
|
//! \~english Converts version string in free notation to classic view
|
||||||
|
//! \~russian Преобразует строку с версией в произвольной форме к классическому виду
|
||||||
PIString PIP_EXPORT versionNormalize(const PIString & v);
|
PIString PIP_EXPORT versionNormalize(const PIString & v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//! \~english Returns hash of string
|
||||||
|
//! \~russian Возвращает хэш строки
|
||||||
template<> inline uint piHash(const PIString & s) {return s.hash();}
|
template<> inline uint piHash(const PIString & s) {return s.hash();}
|
||||||
|
|
||||||
template<> inline void piSwap(PIString & f, PIString & s) {f.swap(s);}
|
template<> inline void piSwap(PIString & f, PIString & s) {f.swap(s);}
|
||||||
|
|
||||||
#endif // PISTRING_H
|
#endif // PISTRING_H
|
||||||
|
|||||||
@@ -35,7 +35,11 @@
|
|||||||
//! \details
|
//! \details
|
||||||
//! \~english Example:
|
//! \~english Example:
|
||||||
//! \~russian Пример:
|
//! \~russian Пример:
|
||||||
//! \~\snippet pistring.cpp PIStringList::join
|
//! \~\code
|
||||||
|
//! PIStringList sl("1", "2");
|
||||||
|
//! sl << "3";
|
||||||
|
//! piCout << sl.join(" < "); // 1 < 2 < 3
|
||||||
|
//! \endcode
|
||||||
PIString PIStringList::join(const PIString & delim) const {
|
PIString PIStringList::join(const PIString & delim) const {
|
||||||
PIString s;
|
PIString s;
|
||||||
for (uint i = 0; i < size(); ++i) {
|
for (uint i = 0; i < size(); ++i) {
|
||||||
@@ -50,7 +54,12 @@ PIString PIStringList::join(const PIString & delim) const {
|
|||||||
//! \details
|
//! \details
|
||||||
//! \~english Example:
|
//! \~english Example:
|
||||||
//! \~russian Пример:
|
//! \~russian Пример:
|
||||||
//! \~\snippet pistring.cpp PIStringList::removeStrings
|
//! \~\code
|
||||||
|
//! PIStringList sl("1", "2");
|
||||||
|
//! sl << "1" << "2" << "3";
|
||||||
|
//! piCout << sl; // {"1", "2", "1", "2", "3"}
|
||||||
|
//! piCout << sl.removeStrings("1"); // {"2", "2", "3"}
|
||||||
|
//! \endcode
|
||||||
PIStringList & PIStringList::removeStrings(const PIString & value) {
|
PIStringList & PIStringList::removeStrings(const PIString & value) {
|
||||||
for (uint i = 0; i < size(); ++i) {
|
for (uint i = 0; i < size(); ++i) {
|
||||||
if (at(i) == value) {
|
if (at(i) == value) {
|
||||||
@@ -65,7 +74,12 @@ PIStringList & PIStringList::removeStrings(const PIString & value) {
|
|||||||
//! \details
|
//! \details
|
||||||
//! \~english Example:
|
//! \~english Example:
|
||||||
//! \~russian Пример:
|
//! \~russian Пример:
|
||||||
//! \~\snippet pistring.cpp PIStringList::removeDuplicates
|
//! \~\code
|
||||||
|
//! PIStringList sl("1", "2");
|
||||||
|
//! sl << "1" << "2" << "3";
|
||||||
|
//! piCout << sl; // {"1", "2", "1", "2", "3"}
|
||||||
|
//! piCout << sl.removeDuplicates(); // {"1", "2", "3"}
|
||||||
|
//! \endcode
|
||||||
PIStringList& PIStringList::removeDuplicates() {
|
PIStringList& PIStringList::removeDuplicates() {
|
||||||
PIStringList l;
|
PIStringList l;
|
||||||
PIString s;
|
PIString s;
|
||||||
@@ -91,7 +105,11 @@ PIStringList& PIStringList::removeDuplicates() {
|
|||||||
//! \details
|
//! \details
|
||||||
//! \~english Example:
|
//! \~english Example:
|
||||||
//! \~russian Пример:
|
//! \~russian Пример:
|
||||||
//! \~\snippet pistring.cpp PIStringList::trim
|
//! \~\code
|
||||||
|
//! PIStringList sl(" 1 ", "\t2", " 3\n");
|
||||||
|
//! piCout << sl; // {" 1 ", " 2", " 3\n"}
|
||||||
|
//! piCout << sl.trim(); // {"1", "2", "3"}
|
||||||
|
//! \endcode
|
||||||
PIStringList & PIStringList::trim() {
|
PIStringList & PIStringList::trim() {
|
||||||
for (uint i = 0; i < size(); ++i)
|
for (uint i = 0; i < size(); ++i)
|
||||||
(*this)[i].trim();
|
(*this)[i].trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user