added String.cpp
This commit is contained in:
parent
c090a950c7
commit
b15016a997
@ -590,6 +590,31 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int format (const CHAR_TYPE* fmt, va_list ap)
|
||||
{
|
||||
int n;
|
||||
qse_va_list save_ap;
|
||||
|
||||
QSE_VA_COPY (save_ap, ap);
|
||||
qse_size_t n = this->_opset.format (QSE_NULL, 0, fmt, ap);
|
||||
if (n == (qse_size_t)-1)
|
||||
{
|
||||
// there's conversion error.
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n > this->getCapacity()) this->possess_data (n);
|
||||
else if (this->_item->isShared()) this->possess_data ();
|
||||
|
||||
QSE_VA_COPY (ap, save_ap);
|
||||
this->_opset.format (this->_item->buffer, this->_item->capacity + 1, fmt, ap);
|
||||
|
||||
this->_item->size = n;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void update (const CHAR_TYPE* str, qse_size_t size)
|
||||
{
|
||||
this->clear ();
|
||||
@ -714,7 +739,7 @@ public:
|
||||
loop_findIndex:
|
||||
while (i <= max && p[i] != first) i++;
|
||||
if (i > max) return INVALID_INDEX;
|
||||
|
||||
|
||||
qse_size_t j = i + 1;
|
||||
qse_size_t end = j + size - 1;
|
||||
qse_size_t k = offset + 1;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <qse/cmn/StrBase.hpp>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
@ -175,8 +176,60 @@ struct MbStringOpset
|
||||
}
|
||||
};
|
||||
|
||||
typedef StrBase<qse_wchar_t, QSE_WT('\0'), WcStringOpset > WcString;
|
||||
typedef StrBase<qse_mchar_t, QSE_MT('\0'), MbStringOpset > MbString;
|
||||
// It's a pain to inherit StrBase<>. i do this not to have various va_xxx calls
|
||||
// in the header file of StrBase.
|
||||
|
||||
class WcString: public StrBase<qse_wchar_t, QSE_WT('\0'), WcStringOpset>
|
||||
{
|
||||
public:
|
||||
typedef StrBase<qse_wchar_t, QSE_WT('\0'), WcStringOpset> ParentType;
|
||||
|
||||
WcString (): ParentType() {}
|
||||
WcString (Mmgr* mmgr): ParentType(mmgr) {}
|
||||
WcString (qse_size_t capacity): ParentType(capacity) {}
|
||||
WcString (Mmgr* mmgr, qse_size_t capacity): ParentType(mmgr, capacity) {}
|
||||
WcString (const qse_wchar_t* str): ParentType(str) {}
|
||||
WcString (Mmgr* mmgr, const qse_wchar_t* str): ParentType(mmgr, str) {}
|
||||
WcString (const qse_wchar_t* str, qse_size_t size): ParentType(str, size) {}
|
||||
WcString (Mmgr* mmgr, const qse_wchar_t* str, qse_size_t size): ParentType(mmgr, str, size) {}
|
||||
WcString (qse_wchar_t c, qse_size_t size): ParentType(c, size) {}
|
||||
WcString (Mmgr* mmgr, qse_wchar_t c, qse_size_t size): ParentType(mmgr, c, size) {}
|
||||
|
||||
WcString (const WcString& str): ParentType(str) {}
|
||||
|
||||
WcString& operator= (const WcString& str) { ParentType::operator=(str); return *this; }
|
||||
WcString& operator= (const qse_wchar_t* str) { ParentType::operator=(str); return *this; }
|
||||
WcString& operator= (const qse_wchar_t c) { ParentType::operator=(c); return *this; }
|
||||
|
||||
int format (const qse_wchar_t* fmt, ...);
|
||||
int formatv (const qse_wchar_t* fmt, va_list ap);
|
||||
};
|
||||
|
||||
class MbString: public StrBase<qse_mchar_t, QSE_MT('\0'), MbStringOpset>
|
||||
{
|
||||
public:
|
||||
typedef StrBase<qse_mchar_t, QSE_MT('\0'), MbStringOpset> ParentType;
|
||||
|
||||
MbString (): ParentType() {}
|
||||
MbString (Mmgr* mmgr): ParentType(mmgr) {}
|
||||
MbString (qse_size_t capacity): ParentType(capacity) {}
|
||||
MbString (Mmgr* mmgr, qse_size_t capacity): ParentType(mmgr, capacity) {}
|
||||
MbString (const qse_mchar_t* str): ParentType(str) {}
|
||||
MbString (Mmgr* mmgr, const qse_mchar_t* str): ParentType(mmgr, str) {}
|
||||
MbString (const qse_mchar_t* str, qse_size_t size): ParentType(str, size) {}
|
||||
MbString (Mmgr* mmgr, const qse_mchar_t* str, qse_size_t size): ParentType(mmgr, str, size) {}
|
||||
MbString (qse_mchar_t c, qse_size_t size): ParentType(c, size) {}
|
||||
MbString (Mmgr* mmgr, qse_mchar_t c, qse_size_t size): ParentType(mmgr, c, size) {}
|
||||
|
||||
MbString (const MbString& str): ParentType(str) {}
|
||||
|
||||
MbString& operator= (const MbString& str) { ParentType::operator=(str); return *this; }
|
||||
MbString& operator= (const qse_mchar_t* str) { ParentType::operator=(str); return *this; }
|
||||
MbString& operator= (const qse_mchar_t c) { ParentType::operator=(c); return *this; }
|
||||
|
||||
int format (const qse_mchar_t* fmt, ...);
|
||||
int formatv (const qse_mchar_t* fmt, va_list ap);
|
||||
};
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
typedef MbString String;
|
||||
@ -184,7 +237,6 @@ typedef StrBase<qse_mchar_t, QSE_MT('\0'), MbStringOpset > MbString;
|
||||
typedef WcString String;
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
@ -141,7 +141,7 @@ if ENABLE_CXX
|
||||
|
||||
lib_LTLIBRARIES += libqsecmnxx.la
|
||||
libqsecmnxx_la_SOURCES = \
|
||||
Mmgr.cpp StdMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp
|
||||
Mmgr.cpp StdMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp String.cpp
|
||||
libqsecmnxx_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
libqsecmnxx_la_LIBADD =
|
||||
|
||||
|
@ -150,9 +150,9 @@ libqsecmn_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(libqsecmn_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
libqsecmnxx_la_DEPENDENCIES =
|
||||
am__libqsecmnxx_la_SOURCES_DIST = Mmgr.cpp StdMmgr.cpp HeapMmgr.cpp \
|
||||
Mmged.cpp Mpool.cpp
|
||||
Mmged.cpp Mpool.cpp String.cpp
|
||||
@ENABLE_CXX_TRUE@am_libqsecmnxx_la_OBJECTS = Mmgr.lo StdMmgr.lo \
|
||||
@ENABLE_CXX_TRUE@ HeapMmgr.lo Mmged.lo Mpool.lo
|
||||
@ENABLE_CXX_TRUE@ HeapMmgr.lo Mmged.lo Mpool.lo String.lo
|
||||
libqsecmnxx_la_OBJECTS = $(am_libqsecmnxx_la_OBJECTS)
|
||||
libqsecmnxx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
@ -435,7 +435,7 @@ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \
|
||||
libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS)
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \
|
||||
@ENABLE_CXX_TRUE@ Mmgr.cpp StdMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp
|
||||
@ENABLE_CXX_TRUE@ Mmgr.cpp StdMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp String.cpp
|
||||
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_LIBADD =
|
||||
@ -521,6 +521,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mmgr.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mpool.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StdMmgr.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/String.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alg-base64.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alg-rand.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alg-search.Plo@am__quote@
|
||||
|
@ -88,6 +88,8 @@ void t2()
|
||||
{
|
||||
QSE::MbString x(QSE_MT("this is a string"));
|
||||
qse_printf (QSE_T("x: [%hs] %d %d\n"), x.getBuffer(), (int)x.getCapacity(), (int)x.getLength());
|
||||
x.format (QSE_MT("what is this %d %d"), 10, 20);
|
||||
qse_printf (QSE_T("x: [%hs] %d %d\n"), x.getBuffer(), (int)x.getCapacity(), (int)x.getLength());
|
||||
}
|
||||
|
||||
int main ()
|
||||
|
Loading…
Reference in New Issue
Block a user