Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

135 lines
2.6 KiB
C++

#pragma once
#include "SHArray.h"
//通用字符串类,以NULL结尾
class UString : public SHArray<wchar_t>
{
public:
UString(long size = 0);
UString(const char *pszVal);
UString(const wchar_t * format);
UString(const UString &string);
virtual ~UString();
UString& operator = (UString &string);
UString& operator = (const wchar_t *p);
UString& operator << (int i);
UString& operator << (double d);
UString& operator << (wchar_t c);
UString& operator << (const UString &s);
UString& operator << (const wchar_t *p);
UString& Format(const wchar_t *format,...);
const UString& operator >> (int &i) const;
const UString& operator >> (double &d) const;
const UString& operator >> (UString &s) const;
const UString& operator >> (wchar_t *p) const;
bool operator == (const wchar_t *p) const;
bool operator != (const wchar_t *p) const;
bool operator > (const wchar_t *p) const;
bool operator < (const wchar_t *p) const;
int operator - (const wchar_t *p) const;
UString operator + (const UString &string) const;
operator int() const;
operator float() const;
operator double() const;
operator const wchar_t*() const;
void Clear();
void FreeExtra();
void Realloc(long size,bool bCopy = true);
void Del(long i);
long Del(const UString &s);
void Del(long from, long to);
void DelLeft(long count);
void DelRight(long count);
void Insert(long i, wchar_t c);
bool Insert(long i, const UString &s);
long IsValidIndex(long index) const;
long Length() const;
long ReverseFind(wchar_t c) const;
long IsEmpty() const;
bool IsIntNumber() const;
bool IsFloatNumber() const;
//字母变大写
void MakeUpper();
void Reverse(long start = 0, long to = -1);
void CreateNextTable(long *next) const;
long Find(wchar_t c, long from = 0, long to = -1) const;
long Find(const UString &s, long from = 0, long to = -1) const;
long Find(const UString &s, SHQuene<long> &quene, long from = 0, long to = -1) const;
//支持通配符的查找替换
long FindEx(const UString &sFindRule, UString &res, int flag = 0, long from = 0, long to = -1) const;
long Replace(const UString &s, const UString &d, long from = 0, long to = -1);
void ReplaceEx(const UString &sFindRule, const UString &sReplaceRule, int flag = 0);
UString Right(long count) const;
UString Left(long count) const;
UString Mid(long from, long to) const;
protected:
void SetEnd(long index);
void SetLength(long l);
void Copy(long from, long to, long size);
void Copy(const wchar_t *p, long pos = 0);
void Copy(const wchar_t *p, long pos, long size);
protected:
long end;
};