10#if !defined(OWL_STRING_H)
14#if defined(BI_HAS_PRAGMA_ONCE)
41 int operator !()
const {
return P == 0;}
42 operator const BSTR()
const {
return P;}
43 operator BSTR() {
return P;}
54 void*
operator new(size_t)
noexcept {
return nullptr;}
55 void operator delete(
void*) {}
92 TString& operator =(
const char * s);
94 TString& operator =(
const wchar_t* s);
95 TString& operator =(
wchar_t* s);
100 operator const char *()
const;
102 operator const wchar_t*()
const;
128# define OleStr(s) ::owl::TString(s)
129# define OleText(s) L##s
157 static TUString*
Create(
const char * str);
158 static TUString*
Create(
char* str);
159 static TUString*
Create(
const wchar_t* str);
160 static TUString*
Create(
wchar_t* str);
162 static TUString*
Create(BSTR str,
bool loan,
TLangId lang = 0);
165 TUString*
Assign(
const TUString& s);
167 TUString*
Assign(
const char * s);
168 TUString*
Assign(
char* s);
169 TUString*
Assign(
const wchar_t* s);
170 TUString*
Assign(
wchar_t* s);
172 operator const char *()
const;
174 operator const wchar_t*()
const;
177 TUString& operator ++();
178 TUString& operator --();
188 static wchar_t*
ConvertAtoW(
const char* src,
size_t len = (
size_t)-1);
189 static char*
ConvertWtoA(
const wchar_t* src,
size_t len = (
size_t)-1);
193#if defined(BI_COMP_MSC)
198 ~TUString() {Free();}
212 const tstring& GetOWLString()
const;
213 void AllocOWLString(
const tstring& as);
215 char* ChangeToCopy();
216 wchar_t* ChangeToWCopy();
234 const wchar_t* WConst;
237 char StringMem[
sizeof(
tstring)];
241 TUString() : Lang(0),Kind(isNull),RefCnt(1),Const(0) {}
399inline TString::operator
const char *()
const
401 return S->operator
const char *();
407inline TString::operator
char*()
409 return S->operator
char*();
415inline TString::operator
const wchar_t*()
const
417 return S->operator
const wchar_t*();
423inline TString::operator
wchar_t*()
425 return S->operator
wchar_t*();
516 return Kind == isNull;
524 return Kind == isWConst || Kind == isWCopy || Kind == isBstr || Kind == isExtBstr;
527inline tstring& TUString::GetOWLString()
529 CHECK(Kind == isString);
530 return *
reinterpret_cast<tstring*
>(StringMem);
533inline const tstring& TUString::GetOWLString()
const
535 CHECK(Kind == isString);
536 return *
reinterpret_cast<const tstring*
>(StringMem);
539inline void TUString::AllocOWLString(
const tstring& as)
delay loading OLEAUT32.DLL/OLE2DISP.DLL
static HRESULT SysFreeString(BSTR)
static BSTR SysAllocString(const OLECHAR *)
tchar * Relinquish() const
Return a pointer (tchar*) to a copy of the string.
BSTR RelinquishSysStr() const
Return a pointer (BSTR) to a copy of the string.
char * RelinquishNarrow() const
Return a pointer (char*) to a copy of the string.
wchar_t * RelinquishWide() const
Return a pointer (wchar_t*) to a copy of the string.
int Length() const
The length in characters of this string.
TString(const char *s=0)
Construct a TString from any type of string.
TString & operator=(const TString &s)
Copy contents of TString s into this string.
BSTR AsBSTR() const
Return a BSTR object owned by 'this' (not by the caller).
bool IsWide() const
Are the string contents any kind of wide?
bool IsNull() const
Is the string NULL?
TLangId GetLangId()
Get Language Id of this string.
void SetLangId(TLangId id)
Set Language Id of this string.
System string (BSTR) encapsulation.
TSysStr(const TSysStr &src)
Privately used by TString to manage string pointers This is a reference counted union of various stri...
static BSTR ConvertAtoBSTR(const char *src)
static char * ConvertWtoA(const wchar_t *src, size_t len=(size_t) -1)
static TUString * Create(const char *str)
TUString & operator--()
Predecrement operator only.
TUString & operator++()
Preincrement operator only.
bool IsNull() const
Is the string a null string?
int Length() const
Return appropriate string length.
TUString * Assign(const TUString &s)
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)
bool IsWide() const
Are the string contents any kind of wide?
void RevokeBstr(BSTR s)
Used to restore if Created with loan==true.
TLocaleString - localized name support.
Reliable platform independent header for common memory and string functions.
char * strnewdup(const char *s, size_t minAllocSize=0)
Definition of class TModule.
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)