68 while (u8It.hasNext() ==
true) u8It.next();
79 if (idx < 0 || idx >=
data.size())
return 0;
89 return u8It.hasNext() ==
true?u8It.next():-1;
131 data.insert(binaryIdx, 1, c);
165 data.insert(binaryIdx, s);
233 auto negative =
false;
238 while (
true ==
true) {
239 auto remainder = i % 10;
241 insert(idx,
static_cast<char>((
'0' + remainder)));
246 if (negative ==
true) {
284 auto integer =
static_cast<int>(f);
285 for (
auto i = 0; i < decimals; i++) {
286 auto integerDecimal =
static_cast<int>(((f - integer) * Math::pow(10.0f,
static_cast<float>(i) + 1.0f))) - (10 *
static_cast<int>(((f - integer) * Math::pow(10.0f,
static_cast<float>(i)))));
287 insert(idx + i, Math::abs(integerDecimal));
290 insert(idx, Math::abs(integer));
291 if (f < 0.0)
insert(idx,
'-');
305 u8It.seekCharacterPosition(idx);
306 auto binaryStartIdx = u8It.getBinaryPosition();
307 for (
auto i = 0; u8It.hasNext() ==
true &&i < count; i++) {
310 auto binaryEndIdx = u8It.getBinaryPosition();
311 data.erase(binaryStartIdx, binaryEndIdx - binaryStartIdx);
313 if (binaryCount !=
nullptr) *binaryCount = binaryEndIdx - binaryStartIdx;
342 inline void replace(
const string& what,
const string& by,
int beginIndex = 0) {
344 string result =
data;
345 if (what.empty())
return;
346 while ((beginIndex = result.find(what, beginIndex)) != std::string::npos) {
347 result.replace(beginIndex, what.length(), by);
348 beginIndex += by.length();
367 inline bool equals(
const string& s2)
const {
401 u8It.seekCharacterPosition(idx);
402 return u8It.getBinaryPosition();
412 u8It.seekBinaryPosition(idx);
413 return u8It.getCharacterPosition();
Mutable utf8 aware string class.
MutableString & append(char c)
Append character.
MutableString & insert(int32_t idx, float f, int32_t decimals=3)
Insert float at idx.
MutableString(const string &s)
Public constructor.
MutableString & insert(int32_t idx, const string &s)
Insert string at idx.
bool equals(const string &s2) const
Equals.
char getCharAt(int32_t idx) const
Get char at given binary index.
MutableString & insert(int32_t idx, int32_t i)
Insert integer at idx.
MutableString & append(const string &s)
Append string.
int getUtf8CharacterIndex(int idx) const
MutableString & append(const MutableString &s)
Append mutable string.
const UTF8CharacterIterator getUTF8CharacterIterator() const
MutableString & insert(int32_t idx, const MutableString &s)
Insert mutable string at idx.
MutableString & set(int32_t i)
Set integer.
int getUtf8BinaryIndex(int idx) const
MutableString & remove(int32_t idx, int32_t count, int *binaryCount=nullptr)
Remove characters at idx with given length.
MutableString & set(const MutableString &s)
Set mutable string.
MutableString & set(const string &s)
Set string.
MutableString & set(float f, int32_t decimals=3)
Set float.
MutableString & append(int32_t i)
Append integer.
MutableString()
Public default constructor.
MutableString clone()
Clone.
UTF8CharacterIterator::UTF8PositionCache cache
MutableString & append(float f, int32_t decimals=3)
Append float with given decimals.
const string & getString() const
MutableString & set(char c)
Set character.
MutableString & reset()
Reset.
MutableString(int i)
Public constructor.
MutableString & insert(int32_t idx, char c)
Insert character c at idx.
int32_t indexOf(const MutableString &s, int32_t idx) const
Returns the character index where string s have been found or -1 if not found.
void removeCache(int binaryIdx, int characterIdx)
Remove from cache by binary index.
void replace(const string &what, const string &by, int beginIndex=0)
Replace string with another string.
int32_t indexOf(const MutableString &s) const
Returns the character index where string s have been found or -1 if not found.
MutableString(float f, int32_t decimals=3)
Public constructor.
bool equals(const MutableString &s2) const
Equals.
int getUTF8CharAt(int32_t idx) const
void removeCache()
Remove cache.
UTF8 string character iterator.