diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_local/MLString.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Plugins/Library/ml_local/MLString.h')
-rw-r--r-- | Src/Plugins/Library/ml_local/MLString.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_local/MLString.h b/Src/Plugins/Library/ml_local/MLString.h new file mode 100644 index 00000000..ddf98e58 --- /dev/null +++ b/Src/Plugins/Library/ml_local/MLString.h @@ -0,0 +1,54 @@ +#ifndef NULLOSFT_MLSTRING_HEADER +#define NULLOSFT_MLSTRING_HEADER + +#include <windows.h> + +class MLString +{ +public: + MLString(void); + ~MLString(void); + MLString(const wchar_t* string); + MLString(unsigned int cchBuffer); +protected: + MLString(const MLString ©); + + +public: + HRESULT Set(const wchar_t* string, unsigned int cchLength); + HRESULT Append(const wchar_t* string, unsigned int cchLength); + const wchar_t* Get(void) { return (cchLen) ? buffer : NULL; } + void Clear(void) { cchLen = 0; } + unsigned int GetLength(void) { return cchLen; } + HRESULT Format(const wchar_t *format, ...); + HRESULT CopyTo(MLString *destination); + + HRESULT Set(const wchar_t* string) { return Set(string, lstrlenW(string)); } + HRESULT Append(const wchar_t* string) { return Append(string, lstrlenW(string)); } + + // buffer + HRESULT Allocate(unsigned int cchNewSize); + void Compact(void); + wchar_t* GetBuffer(void) { return buffer; } + unsigned int GetBufferLength(void) { return allocated; } + void UpdateBuffer(void) { cchLen = lstrlenW(buffer); } + + operator const wchar_t *() { return buffer; } + operator wchar_t *() { return buffer; } + wchar_t& operator [](unsigned int index) { return buffer[index]; } + MLString& operator = (const wchar_t *source) { (source) ? Set(source, lstrlenW(source)) : Clear(); return *this;} + MLString& operator + (const wchar_t *source) { if (source) Append(source, lstrlenW(source)); return *this;} + MLString& operator += (const wchar_t *source) { if (source) Append(source, lstrlenW(source)); return *this;} + MLString& operator = (MLString *source) { (source) ? source->CopyTo(this) : Clear(); return *this;} + MLString& operator + (MLString *source) { if (source) Append(source->GetBuffer(), source->GetLength()); return *this;} + MLString& operator += (MLString *source) { if (source) Append(source->GetBuffer(), source->GetLength()); return *this;} + +protected: + wchar_t *buffer; + unsigned int cchLen; + unsigned int allocated; + + static void *heap; +}; + +#endif // NULLOSFT_STRING_HEADER
\ No newline at end of file |