Add function string::insert.
(more overloads for it can be added later). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5788 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
a336e62fca
commit
31652f6577
|
@ -1,5 +1,6 @@
|
||||||
--------------------------
|
--------------------------
|
||||||
Changes in 1.9 (not yet released)
|
Changes in 1.9 (not yet released)
|
||||||
|
- Add function string::insert.
|
||||||
- EditBox now still allows overwriting characters when the text-length is at max.
|
- EditBox now still allows overwriting characters when the text-length is at max.
|
||||||
- Bugfix: CMatrix4::transformPlane was calculating the wrong plane-normal before.
|
- Bugfix: CMatrix4::transformPlane was calculating the wrong plane-normal before.
|
||||||
- SViewFrustum::recalculateBoundingBox no longer includes camera position in the bounding-box. Only using frustum corners now. Thx @DevSH for bugreport & patch.
|
- SViewFrustum::recalculateBoundingBox no longer includes camera position in the bounding-box. Only using frustum corners now. Thx @DevSH for bugreport & patch.
|
||||||
|
|
|
@ -730,6 +730,32 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Insert a certain amount of characters into the string before the given index
|
||||||
|
//\param pos Insert the characters before this index
|
||||||
|
//\param s String to insert. Must be at least of size n
|
||||||
|
//\param n Number of characters from string s to use.
|
||||||
|
string<T,TAlloc>& insert(u32 pos, const char* s, u32 n)
|
||||||
|
{
|
||||||
|
if ( pos < used )
|
||||||
|
{
|
||||||
|
reserve(used+n);
|
||||||
|
|
||||||
|
// move stuff behind insert point
|
||||||
|
const u32 end = used+n-1;
|
||||||
|
for (u32 i=0; i<used-pos; ++i)
|
||||||
|
{
|
||||||
|
array[end-i] = array[end-(i+n)];
|
||||||
|
}
|
||||||
|
used += n;
|
||||||
|
|
||||||
|
for (u32 i=0; i<n; ++i)
|
||||||
|
{
|
||||||
|
array[pos+i] = s[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! Reserves some memory.
|
//! Reserves some memory.
|
||||||
/** \param count: Amount of characters to reserve. */
|
/** \param count: Amount of characters to reserve. */
|
||||||
|
|
|
@ -180,6 +180,29 @@ bool testAppendStringc()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool testInsert()
|
||||||
|
{
|
||||||
|
core::stringc str;
|
||||||
|
|
||||||
|
str.insert(0, "something", 4);
|
||||||
|
if (str != "some")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
str.insert(4, "thing", 5);
|
||||||
|
if (str != "something")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
str.insert(0, "is ", 3);
|
||||||
|
if (str != "is something")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
str.insert(3, "there ", 6);
|
||||||
|
if (str != "is there something")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool testLowerUpper()
|
bool testLowerUpper()
|
||||||
{
|
{
|
||||||
irr::core::array <irr::core::stringc> stringsOrig, targetLower, targetUpper;
|
irr::core::array <irr::core::stringc> stringsOrig, targetLower, targetUpper;
|
||||||
|
@ -356,6 +379,8 @@ bool testIrrString(void)
|
||||||
}
|
}
|
||||||
allExpected &= testAppendStringc();
|
allExpected &= testAppendStringc();
|
||||||
|
|
||||||
|
allExpected &= testInsert();
|
||||||
|
|
||||||
logTestString("Test io::path\n");
|
logTestString("Test io::path\n");
|
||||||
{
|
{
|
||||||
// Only test that this type exists, it's one from above
|
// Only test that this type exists, it's one from above
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Tests finished. 1 test of 1 passed.
|
Tests finished. 1 test of 1 passed.
|
||||||
Compiled as DEBUG
|
Compiled as DEBUG
|
||||||
Test suite pass at GMT Fri Feb 22 17:53:28 2019
|
Test suite pass at GMT Fri Mar 15 13:00:55 2019
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue