-
Notifications
You must be signed in to change notification settings - Fork 0
/
astring.h
61 lines (48 loc) · 1.91 KB
/
astring.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __AString_H__
#define __AString_H__
////////////////////////////////////////////////////////////////////////////////
// Title : AString(Alphabet-String) Class.
// Author : [email protected]
// Date : 2006.9.6
////////////////////////////////////////////////////////////////////////////////
class AString
{
public:
AString();
AString(const AString &);
AString(const char *const);
AString(const char);
~AString();
AString & operator= (const AString &);
void operator+=(const AString &);
// void operator+=(const char);
AString operator+(const AString &);
// AString operator+(const char ch);
friend AString operator+(const AString&, const AString&);
// friend AString operator+(const char ch, const AString&);
bool operator==( const AString & rhs ) const;
bool operator!=( const AString & rhs ) const { return !(*this==rhs); }
char & operator[](int);
char operator[](int p) const { return GetAt(p); };
int GetLen() const { return itsLength; }
const char * GetStr() const { return itsString; }
char * GetStrP() const { return itsString; }
char GetAt(int offset) const
{ return ( offset >= itsLength || offset < 0 )? '\0' : itsString[offset]; }
bool SetAt(int , const char );
bool IsEmpty() const { return !itsLength; }
void Clear();
AString Left( int nCount ) const { return SubStr( 0, nCount-1 ); }
AString Right( int nCount ) const { return SubStr( itsLength-nCount, itsLength-1 ); }
AString Mid( int nFirst ) const { return SubStr( nFirst, itsLength-1 ); }
AString Mid( int nFirst, int nCount ) const { return SubStr( nFirst, nFirst+nCount-1 ); }
AString SubStr( int start, int end ) const;
int Find( char , int position = 0 ) const;
int Find( AString , int position = 0 ) const;
AString Delete( int nIndex, int nCount = 1 ) const
{ return ( nCount >= itsLength )? *this : Left( nIndex ) + Mid( nIndex+nCount ); }
protected :
char * itsString;
int itsLength;
};
#endif