version 4.2.0
move toStdFunction() to pibase.h refactor PIParseHelper, now it much more abstract and useful fix PIIODevice::createFromFullPath() when whitespaces at start or end are presence PIStreamPacker add events for start and end packet receive PIClientServer::ClientBase add virtual methods for start and end packet receive. also one can enable diagnostics with enableDiagnostics() method PICout now call flush() on each end of output add PIString::entries(const PIString & str)
This commit is contained in:
@@ -1197,6 +1197,17 @@ int PIString::entries(const PIChar c) const {
|
||||
}
|
||||
|
||||
|
||||
int PIString::entries(const PIString & str) const {
|
||||
int sz = size_s(), ssz = str.size_s();
|
||||
if (ssz == 0 || sz < ssz) return 0;
|
||||
int btc = str.size_s() * sizeof(PIChar), ret = 0;
|
||||
for (int i = 0; i < sz - ssz + 1; ++i) {
|
||||
if (piCompareBinary(d.data(i), str.d.data(0), btc)) ++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool PIString::startsWith(const PIChar c) const {
|
||||
if (isEmpty()) return false;
|
||||
return front() == c;
|
||||
|
||||
@@ -1271,6 +1271,16 @@ public:
|
||||
//! piCout << PIString(".str.0").entries("0"); // 1
|
||||
//! \endcode
|
||||
int entries(const PIChar c) const;
|
||||
int entries(char c) const { return entries(PIChar(c)); }
|
||||
|
||||
//! \~english Returns number of occurrences of string "str".
|
||||
//! \~russian Возвращает число вхождений строк "str".
|
||||
//! \~\details
|
||||
//! \~\code
|
||||
//! piCout << PIString("hello locale").entries("lo"); // 2
|
||||
//! piCout << PIString("hello locale").entries("lo lo"); // 1
|
||||
//! \endcode
|
||||
int entries(const PIString & str) const;
|
||||
|
||||
//! \~english Returns if string starts with "c".
|
||||
//! \~russian Возвращает начинается ли строка с "c".
|
||||
|
||||
Reference in New Issue
Block a user