5 __mustr::__mustr( const char *str )
7 constructor(str, str ? strlen(str) : 0);
9 __mustr::__mustr( const wchar_t *str )
11 constructor(str, str ? wcslen(str) : 0);
13 void __mustr::constructor(const char *str, int len)
20 void __mustr::constructor(const wchar_t *str, int len)
29 if ( newbuffer ) delete[] newbuffer;
31 __mustr::operator char *()
33 if ( type == 1 ) return (char*)buffer;
34 if ( newbuffer ) return (char*)newbuffer;
38 newbuffer = new char[ length*2 + 1 ];
39 int size = WideCharToMultiByte( CP_ACP, 0, (wchar_t*)buffer, length, newbuffer, length*2, NULL, NULL );
40 newbuffer[size] = '\0';
41 return (char*)newbuffer;
43 __mustr::operator wchar_t *()
45 if ( type == 2 ) return (wchar_t*)buffer;
46 if ( newbuffer ) return (wchar_t*)newbuffer;
50 *(wchar_t**)&newbuffer = new wchar_t[ length*2 + 1 ];
51 int size = MultiByteToWideChar( CP_ACP, 0, (char*)buffer, length, (wchar_t*)newbuffer, length*2 );
52 ((wchar_t*)newbuffer)[size] = '\0';
53 return (wchar_t*)newbuffer;