Files
envi-code/SourceCode/Code2026/inc/AdsXRx/UString.h
T
2026-09-28 15:28:50 +08:00

151 lines
3.0 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, SH Software Co. Ltd.
// = FileName : UString.h
// = Version : ver2.0
// = Author : zjq
// = CreateDate : 2002-09-09
// = Description: 通用字符串类的声明
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#ifndef _USTRING_H_
#define _USTRING_H_
#ifndef _ARRAY_H_
#include "Array.h"
#endif
//通用字符串类,以NULL结尾
class GEOAPI UString : public Array<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, Quene<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;
};
#endif