148 lines
3.1 KiB
C++
148 lines
3.1 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TUString.h
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 通用字符串类的声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _TUSTRING_H_
|
|
#define _TUSTRING_H_
|
|
|
|
#include "TArray.h"
|
|
|
|
//通用字符串类,以NULL结尾
|
|
class TUString : public TArray<wchar_t>
|
|
{
|
|
public:
|
|
|
|
TUString(long size = 0);
|
|
|
|
TUString(const char *pszVal);
|
|
|
|
TUString(const wchar_t * format);
|
|
|
|
TUString(const TUString &string);
|
|
|
|
virtual ~TUString();
|
|
|
|
TUString& operator = (TUString &string);
|
|
|
|
TUString& operator = (const wchar_t *p);
|
|
|
|
TUString& operator << (int i);
|
|
|
|
TUString& operator << (double d);
|
|
|
|
TUString& operator << (wchar_t c);
|
|
|
|
TUString& operator << (const TUString &s);
|
|
|
|
TUString& operator << (const wchar_t *p);
|
|
|
|
TUString& Format(const wchar_t *format,...);
|
|
|
|
const TUString& operator >> (int &i) const;
|
|
|
|
const TUString& operator >> (double &d) const;
|
|
|
|
const TUString& operator >> (TUString &s) const;
|
|
|
|
const TUString& 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;
|
|
|
|
TUString operator + (const TUString &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 TUString &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 TUString &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 TUString &s, long from = 0, long to = -1) const;
|
|
|
|
long Find(const TUString &s, TQuene<long> &quene, long from = 0, long to = -1) const;
|
|
|
|
//支持通配符的查找替换
|
|
long FindEx(const TUString &sFindRule, TUString &res, int flag = 0, long from = 0, long to = -1) const;
|
|
|
|
long Replace(const TUString &s, const TUString &d, long from = 0, long to = -1);
|
|
|
|
void ReplaceEx(const TUString &sFindRule, const TUString &sReplaceRule, int flag = 0);
|
|
|
|
TUString Right(long count) const;
|
|
|
|
TUString Left(long count) const;
|
|
|
|
TUString 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;
|
|
};
|
|
|
|
#endif |