added more functions to StrBase
This commit is contained in:
parent
b4fd70b1e4
commit
c6d29bc9b6
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
||||
|
||||
#include <qse/cmn/StrBase.hpp>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
@ -36,24 +37,31 @@ QSE_BEGIN_NAMESPACE(QSE)
|
||||
|
||||
struct WcStringOpset
|
||||
{
|
||||
qse_size_t copy (qse_wchar_t* dst, const qse_wchar_t* src, qse_size_t ssz)
|
||||
qse_size_t copy (qse_wchar_t* dst, const qse_wchar_t* src, qse_size_t ssz) const
|
||||
{
|
||||
return qse_wcsncpy(dst, src, ssz);
|
||||
}
|
||||
|
||||
qse_size_t move (qse_wchar_t* dst, const qse_wchar_t* src, qse_size_t ssz) const
|
||||
{
|
||||
// this one doesn't insert terminating null
|
||||
qse_memmove (dst, src, ssz * QSE_SIZEOF(*dst));
|
||||
return ssz;
|
||||
}
|
||||
|
||||
// compare two strings of the same length
|
||||
int compare (const qse_wchar_t* str1, const qse_wchar_t* str2, qse_size_t len)
|
||||
int compare (const qse_wchar_t* str1, const qse_wchar_t* str2, qse_size_t len) const
|
||||
{
|
||||
return qse_wcsxncmp(str1, len, str2, len);
|
||||
}
|
||||
|
||||
// compare a length-bound string with a null-terminated string.
|
||||
int compare (const qse_wchar_t* str1, qse_size_t len, const qse_wchar_t* str2)
|
||||
int compare (const qse_wchar_t* str1, qse_size_t len, const qse_wchar_t* str2) const
|
||||
{
|
||||
return qse_wcsxcmp(str1, len, str2);
|
||||
}
|
||||
|
||||
int length (const qse_wchar_t* str)
|
||||
qse_size_t getLength (const qse_wchar_t* str) const
|
||||
{
|
||||
return qse_strlen(str);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ int main ()
|
||||
a.insert (0, 10);
|
||||
a.insert (0, 20);
|
||||
a.insert (0, 30);
|
||||
const int& t = a[2];
|
||||
const int& t = a[2u];
|
||||
printf ("%lu\n", (unsigned long int)a.getIndex(t));
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ int main ()
|
||||
h.insert (buf);
|
||||
}
|
||||
|
||||
for (int i = 0; i < h.getSize(); i++)
|
||||
for (qse_size_t i = 0; i < h.getSize(); i++)
|
||||
{
|
||||
printf ("%05d %s\n", (int)h.getIndex(h[i]), h[i].c_str());
|
||||
}
|
||||
@ -150,7 +150,7 @@ int main ()
|
||||
|
||||
while (!h.isEmpty())
|
||||
{
|
||||
printf ("%s\n", h[0].c_str());
|
||||
printf ("%s\n", h[0u].c_str());
|
||||
h.remove (0);
|
||||
}
|
||||
printf ("----------------\n");
|
||||
@ -181,9 +181,9 @@ int main ()
|
||||
{
|
||||
Container c;
|
||||
StrList::Node* node2, * node14;
|
||||
for (int i = 0; i < 20; i++)
|
||||
for (qse_size_t i = 0; i < 20; i++)
|
||||
{
|
||||
sprintf (buf, "hello %d", i);
|
||||
sprintf (buf, "hello %d", (int)i);
|
||||
|
||||
//c.insert (buf);
|
||||
|
||||
|
@ -13,7 +13,26 @@ void t1 ()
|
||||
QSE::String y (x);
|
||||
|
||||
*z = y;
|
||||
qse_printf (QSE_T("[%s]\n"), x.getBuffer());
|
||||
|
||||
//z->setCharAt (0, QSE_T('Q'));
|
||||
//z->prepend (QSE_T("ok."));
|
||||
z->append (*z);
|
||||
for (int i = 0; i < 80; i++)
|
||||
{
|
||||
z->prepend (QSE_T("ok."));
|
||||
z->insert (10, QSE_T("XXX"));
|
||||
}
|
||||
z->update (10, 2, QSE_T("ZZZZ"));
|
||||
//z->update (QSE_T("QQQ"));
|
||||
|
||||
z->replace (QSE_T("XX"), QSE_T("^"));
|
||||
//z->invert();
|
||||
|
||||
|
||||
qse_printf (QSE_T("[%s] [%c] capa=%d len=%d\n"), x.getBuffer(), x[0], (int)x.getCapacity(), (int)x.getLength());
|
||||
qse_printf (QSE_T("[%s] [%c] capa=%d len=%d\n"), z->getBuffer(), (*z)[0], (int)z->getCapacity(), (int)z->getLength());
|
||||
|
||||
qse_printf (QSE_T("%d %d\n"), (int)z->findIndex (0, QSE_T("K")), (int)z->findLastIndex (0, QSE_T("K")));
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("-----------------\n"));
|
||||
|
Loading…
Reference in New Issue
Block a user