123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- #ifndef _STRINGW_H_WASABI
- #define _STRINGW_H_WASABI
- #ifdef __cplusplus
- #include <bfc/platform/types.h>
- class StringW
- {
- public:
- StringW(const wchar_t *initial_val = NULL);
- StringW(const StringW &s);
- StringW(const StringW *s);
- ~StringW();
-
- const wchar_t *getValue() const { return val; }
- const wchar_t *v() const { return getValue(); }
- operator const wchar_t *() const { return getValue(); }
-
- const wchar_t *getValueSafe(const wchar_t *def_val = L"") const;
-
-
-
-
-
- const wchar_t *setValue(const wchar_t *newval);
-
- wchar_t *getNonConstVal() { return const_cast<wchar_t *>(getValue()); }
- const wchar_t *operator =(const wchar_t *newval) { return setValue(newval); }
- const wchar_t *operator +=(const wchar_t *addval)
- {
- return cat(addval);
- }
- const wchar_t *operator +=(wchar_t value);
- const wchar_t *operator +=(int value);
- const wchar_t *operator +=(GUID guid);
-
- StringW &operator =(const StringW &s)
- {
- if (this != &s)
- setValue(s);
- return *this;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- inline StringW operator +(const wchar_t *val)
- {
- StringW retval = *this;
- return retval += val;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- size_t len() const;
-
- int isempty() const;
-
- void toupper();
-
- void tolower();
-
- int isequal(const wchar_t *otherval) const;
-
- int iscaseequal(const wchar_t *otherval) const;
-
-
- void changeChar(wchar_t from, wchar_t to);
-
-
-
- int lastChar();
-
- const wchar_t *printf(const wchar_t *format, ...);
-
- const wchar_t *cat(const wchar_t *value);
-
- const wchar_t *catn(const wchar_t *value, size_t len);
-
- const wchar_t *catPostSeparator(const wchar_t *value, const wchar_t separator);
-
-
-
- const wchar_t *prepend(const wchar_t *value);
-
- const wchar_t *ncpy(const wchar_t *newstr, size_t numchars);
-
-
-
-
-
-
-
- size_t lFindChar(wchar_t findval);
- size_t lFindChar(const wchar_t *findval);
-
- size_t rFindChar(const wchar_t *findval);
-
-
-
-
- StringW lSplit(size_t idxval);
-
- StringW lSplitChar(const wchar_t *findval);
- StringW rSplit(size_t idxval);
-
- StringW rSplitChar(const wchar_t *findval);
-
-
- StringW lSpliceChar(const wchar_t *findval);
-
- StringW rSpliceChar(const wchar_t *findval);
-
- int replace(const wchar_t *find, const wchar_t *replace);
-
- int replaceNumericField(int value, wchar_t fieldchar = '\x24');
-
-
-
-
- void trunc(int newlen);
-
- size_t va_sprintf(const wchar_t *format, va_list args);
-
- void purge();
- void swap(StringW *);
- void swap(StringW &);
- void own(wchar_t *);
- void AppendPath(const wchar_t *path);
- void AppendFolder(const wchar_t *path);
- void AddBackslash();
- void RemovePath();
- void FixSlashes();
- protected:
- wchar_t * val;
- enum { wastage_allowed = 128 };
- };
- class StringPathCombine : public StringW
- {
- public:
- StringPathCombine(const wchar_t *path, const wchar_t *filename);
- };
- class StringPrintfW : public StringW
- {
- public:
- StringPrintfW(const wchar_t *format = NULL, ...);
- StringPrintfW(int value);
- StringPrintfW(double value);
- StringPrintfW(GUID g);
- };
- #if defined(NDEBUG) && defined(WASABI_NO_RELEASEMODE_DEBUGSTRINGS)
- #define DebugStringW __noop
- #else
- #define DebugStringW _DebugStringW
- #endif
- class _DebugStringW : public StringW
- {
- public:
- _DebugStringW(const wchar_t *format = NULL, ...);
- _DebugStringW(const StringW &s);
- _DebugStringW(const StringW *s);
- void debugPrint();
- };
- #if 0
- class StringToLower : public StringW
- {
- public:
- StringToLower(const char *val = NULL) : StringW(val)
- {
- tolower();
- }
- };
- class StringToUpper : public StringW
- {
- public:
- StringToUpper(const char *val = NULL) : StringW(val)
- {
- toupper();
- }
- };
- inline int operator ==(const char *v1, const StringW &v2)
- {
- return v2.isequal(v1);
- }
- inline int operator !=(const char *v1, const StringW &v2)
- {
- return !v2.isequal(v1);
- }
- inline int operator <(const char *v1, const StringW &v2)
- {
- return !v2.islessthan(v1);
- }
- inline int operator >(const char *v1, const StringW &v2)
- {
- return v2.islessthan(v1);
- }
- #endif
- class StringWComparator
- {
- public:
-
- static int compareItem(StringW *p1, StringW* p2);
-
- static int compareAttrib(const wchar_t *attrib, StringW *item);
- };
- #endif
- #endif
|