//************************************************************************************************* //************************************************************************************************* // // STRING // // Developed by jief666, from 1997. // //************************************************************************************************* //************************************************************************************************* #if !defined(__XString_H__) #define __XString_H__ #include #include "XStringAbstract.h" #include "../../Include/Library/printf_lite.h" #ifndef XString16GrowByDefault #define XString16GrowByDefault 16 #endif //typedef XStringAbstract XString; class XString : public XStringAbstract { public: XString() : XStringAbstract() {}; XString(const XString& S) : XStringAbstract(S) {} template XString(const XStringAbstract &S) : XStringAbstract(S) {} XString& operator=(const XString &S) { this->XStringAbstract::operator=(S); return *this; } using XStringAbstract::operator =; protected: static void transmitSPrintf(const char* buf, unsigned int nbchar, void* context) { ((XString*)(context))->strncat(buf, nbchar); } public: void vSPrintf(const char* format, va_list va) { setEmpty(); vprintf_with_callback(format, va, transmitSPrintf, this); } void SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3))) { va_list va; va_start (va, format); vSPrintf(format, va); va_end(va); } }; class XString16 : public XStringAbstract { public: XString16() : XStringAbstract() {}; XString16(const XString16& S) : XStringAbstract(S) {} template XString16(const XStringAbstract &S) : XStringAbstract(S) {} XString16& operator=(const XString16 &S) { this->XStringAbstract::operator=(S); return *this; } using XStringAbstract::operator =; }; class XString32 : public XStringAbstract { public: XString32() : XStringAbstract() {}; XString32(const XString32& S) : XStringAbstract(S) {} template XString32(const XStringAbstract &S) : XStringAbstract(S) {} XString32& operator=(const XString32 &S) { this->XStringAbstract::operator=(S); return *this; } using XStringAbstract::operator =; }; class XStringW : public XStringAbstract { public: XStringW() : XStringAbstract() {}; XStringW(const XStringW& S) : XStringAbstract(S) {} template XStringW(const OtherXStringClass& S) : XStringAbstract(S) {} XStringW& operator=(const XStringW &S) { this->XStringAbstract::operator=(S); return *this; } using XStringAbstract::operator =; protected: static void transmitSPrintf(const wchar_t* buf, unsigned int nbchar, void* context) { ((XStringW*)(context))->strncat(buf, nbchar); } public: void vSWPrintf(const char* format, va_list va) { setEmpty(); vwprintf_with_callback(format, va, transmitSPrintf, this); } void SWPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3))) { va_list va; va_start (va, format); vSWPrintf(format, va); va_end(va); } }; XString operator"" _XS ( const char* s, size_t len); XString16 operator"" _XS16 ( const char16_t* s, size_t len); XString32 operator"" _XS32 ( const char32_t* s, size_t len); XStringW operator"" _XSW ( const char* s, size_t len); XStringW operator"" _XSW ( const wchar_t* s, size_t len); extern const XString NullXString; extern const XStringW NullXStringW; #ifdef _MSC_VER # define __attribute__(x) #endif XString SPrintf(const char* format, ...) __attribute__((__format__ (__printf__, 1, 2))); XStringW SWPrintf(const char* format, ...) __attribute__((__format__ (__printf__, 1, 2))); // //XStringAbstract SubString(const T *S, size_t pos, size_t count); //XStringAbstract CleanCtrl(const XStringAbstract &S); #endif