handle NULL string pointers

svn path=/trunk/; revision=7011
This commit is contained in:
Martin Fuchs 2003-12-14 10:45:11 +00:00
parent 78f6e71be8
commit 13ba729805

View file

@ -580,7 +580,7 @@ struct String
#endif #endif
String() {} String() {}
String(LPCTSTR s) : super(s) {} String(LPCTSTR s) {if (s) super::assign(s);}
String(LPCTSTR s, int l) : super(s, l) {} String(LPCTSTR s, int l) : super(s, l) {}
String(const super& other) : super(other) {} String(const super& other) : super(other) {}
String(const String& other) : super(other) {} String(const String& other) : super(other) {}
@ -590,18 +590,18 @@ struct String
String(LPCSTR s, int l) {assign(s, l);} String(LPCSTR s, int l) {assign(s, l);}
String(const string& other) {assign(other.c_str());} String(const string& other) {assign(other.c_str());}
String& operator=(LPCSTR s) {assign(s); return *this;} String& operator=(LPCSTR s) {assign(s); return *this;}
void assign(LPCSTR s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));} void assign(LPCSTR s) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));} else erase();}
void assign(LPCSTR s, int l) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, BUFFER_LEN));} void assign(LPCSTR s, int l) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, BUFFER_LEN));} else erase();}
#else #else
String(LPCWSTR s) {assign(s);} String(LPCWSTR s) {assign(s);}
String(LPCWSTR s, int l) {assign(s, l);} String(LPCWSTR s, int l) {assign(s, l);}
String(const wstring& other) {assign(other.c_str());} String(const wstring& other) {assign(other.c_str());}
String& operator=(LPCWSTR s) {assign(s); return *this;} String& operator=(LPCWSTR s) {assign(s); return *this;}
void assign(LPCWSTR s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0));} void assign(LPCWSTR s) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0));} else erase();}
void assign(LPCWSTR s, int l) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} void assign(LPCWSTR s, int l) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} else erase();}
#endif #endif
String& operator=(LPCTSTR s) {super::assign(s); return *this;} String& operator=(LPCTSTR s) {if (s) super::assign(s); else erase(); return *this;}
String& operator=(const super& s) {super::assign(s); return *this;} String& operator=(const super& s) {super::assign(s); return *this;}
operator LPCTSTR() const {return c_str();} operator LPCTSTR() const {return c_str();}