16TUString TUString::Null;
34 wchar_t w=
src[
i]-0x10000;
49 if (
len != (
size_t)-1)
64 if (
len != (
size_t)-1)
84 if (
len != (
size_t)-1)
93 wchar_t*
pWide = (
wchar_t*)
alloca(
sizeof(
wchar_t)*(size+1));
96 return ::SysAllocString(
pWide);
103char* TUString::ChangeToCopy()
106 const char *
src = 0;
131 src = GetOWLString().c_str();
132 len = GetOWLString().length();
151wchar_t* TUString::ChangeToWCopy()
154 const wchar_t*
src = 0;
178 src = GetOWLString().c_str();
179 len = GetOWLString().length();
223 CHECK(!
"Unexpected Kind of TUString");
238inline TUString::TUString(
const char & str)
240 Lang(0), Kind(isConst), RefCnt(1), Const(&str)
245inline TUString::TUString(
char& str)
247 Lang(0),Kind(isCopy), RefCnt(1)
255inline TUString::TUString(
const wchar_t& str)
257 Lang(0), Kind(isWConst), RefCnt(1), WConst(&str)
262inline TUString::TUString(
wchar_t& str)
264 Lang(0), Kind(isWCopy), RefCnt(1)
274 Kind(
loan ? isExtBstr : isBstr),
284 Kind(
loan ? isExtBstr : isBstr),
294inline TUString::TUString(
const tstring& str)
296 Lang(0), Kind(isString), RefCnt(1)
309 return str ?
new TUString(*str) : &++Null;
315 return str ?
new TUString(*str) : &++Null;
321 return str ?
new TUString(*str) : &++Null;
327 return str ?
new TUString(*str) : &++Null;
349 return str.length() ?
new TUString(str) : &++Null;
359 if (RefCnt == 1 && Kind != isNull && Kind != isExtBstr)
371 if (s.length() && RefCnt == 1 && Kind != isNull && Kind != isExtBstr)
388 if (s && *s && RefCnt == 1 && Kind != isNull && Kind != isExtBstr) {
403 if (s && *s && RefCnt == 1 && Kind != isNull && Kind != isExtBstr) {
419 if (s && *s && RefCnt == 1 && Kind != isNull && Kind != isExtBstr) {
434 if (s && *s && RefCnt == 1 && Kind != isNull && Kind != isExtBstr) {
450 if (RefCnt==1 && Kind != isNull && Kind != isExtBstr) {
469TUString::operator
const char *()
const
472 case isNull:
return 0;
473 case isConst:
return Const;
474 case isCopy:
return Copy;
478 case isString:
return GetOWLString().c_str();
490TUString::operator
char*()
492 return ChangeToCopy();
496TUString::operator
const wchar_t*()
const
499 case isNull:
return 0;
500 case isWConst:
return WConst;
501 case isWCopy:
return WCopy;
503 case isExtBstr:
return Bstr;
508 case isString:
return GetOWLString().c_str();
517TUString::operator
wchar_t*()
519 return ChangeToWCopy();
530 case isNull:
return 0;
535 case isConst:
return static_cast<int>(
strlen(
Const));
536 case isCopy:
return static_cast<int>(
strlen(
Copy));
537 case isString:
return static_cast<int>(GetOWLString().length());
550 if (Kind != isExtBstr ||
Bstr != s)
565 if (Kind == isExtBstr &&
Bstr == s) {
580 case isCopy:
delete[]
Copy;
break;
581 case isWCopy:
delete[]
WCopy;
break;
583 case isString: GetOWLString().~tstring();
break;
static UINT SysStringLen(BSTR)
static HRESULT SysFreeString(BSTR)
System string (BSTR) encapsulation.
Privately used by TString to manage string pointers This is a reference counted union of various stri...
static BSTR ConvertAtoBSTR(const char *src)
const wchar_t * WConst
Unicode version of Const (Win32)
static char * ConvertWtoA(const wchar_t *src, size_t len=(size_t) -1)
static TUString * Create(const char *str)
int Length() const
Return appropriate string length.
TUString * Assign(const TUString &s)
const char * Const
Passed-in string, NOT owned here, read-only.
void ReleaseBstr(BSTR s)
Used to unhook if Created with loan==true.
static wchar_t * ConvertAtoW(const char *src, size_t len=(size_t) -1)
wchar_t * WCopy
Unicode version of Copy (Win32)
BSTR Bstr
Copy of pointer, owned here.
char * Copy
Local copy, must be deleted, read-write.
void RevokeBstr(BSTR s)
Used to restore if Created with loan==true.
size_t __stdcall wcslen(const wchar_t *str)
wchar_t *__stdcall wcscpy(wchar_t *dst, const wchar_t *src)
Reliable platform independent header for common memory and string functions.
Object Windows Library (OWLNext Core)
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
BSTR SysAllocString(const char *str)
General definitions used by all ObjectWindows programs.
#define CONST_CAST(targetType, object)
Definition of class TString, a flexible universal string envelope class.
Classes for window system structure and type encapsulation.