ulib  1.0
S.W. Lee's essential C++ library
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
ustring.h
Go to the documentation of this file.
1 
12 #ifndef ___ustring___
13 #define ___ustring___
14 
15 #ifndef UNDEFINE
16 #define UNDEFINE -1
17 #endif
18 #ifndef NOT_FOUND
19 #define NOT_FOUND -1
20 #endif
21 
22 #ifndef ERR1
23 #define ERR1 -2
24 #endif
25 #ifndef ERR2
26 #define ERR2 -3
27 #endif
28 #ifndef DEF_BUFF_SIZE
29 #define DEF_BUFF_SIZE 1024
30 #endif
31 
32 #include <string.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <math.h>
36 
37 namespace ulib
38 {
39 
58  class CUString {
59  public:
60  CUString();
61  CUString( char arg_str[] );
62  CUString( const char arg_str[] );
63  CUString( const CUString &rhs );
64  ~CUString();
65  char operator[](int nIndex);
66  void operator+=( char rhs[]);
67  void operator+=( CUString rhs);
68  CUString & operator=( char[]);
70  CUString operator+( char[]);
72  bool operator==( CUString rhs );
73  bool operator!=( CUString rhs );
74 
75 
76  // The String as an Array
77  bool IsEmpty(); //
78  void Empty(); //
79  char GetAt( int nIndex ); //
80  void SetAt( int nIndex, char ch ); //
81  int GetLength(); //
82 
83  // Extraction
84  CUString Left( int nCount ); //
85  CUString Right( int nCount ); //
86  CUString Mid( int nFirst ); //
87  CUString Mid( int nFirst, int nCount ); //
88 
89  // Searching
90  int Find( CUString &find, int pos = 0 ); //
91  int Find( char find, int pos = 0 ); //
92  int Find( char find[], int pos = 0 ); //
93  int FindCasefree( CUString &find, int pos = 0 );
94  int FindCasefree( char find, int pos = 0 );
95  int FindCasefree( char find[], int pos = 0 );
96  int ReverseFind( char ch );
97 
98 
99  // Other Conversion
100  void MakeToUpper(); //
101  void MakeToLower(); //
102  char MakeToUpperChar(char ch);
103  char MakeToLowerChar(char ch);
104  int Replace( char chOld[], char chNew[], bool caseFree = false ); //
105  int Delete( int nIndex, int nCount ); //
106  int DeleteStr( char chStr[], bool caseFree = false ); //
107  int DeleteBoundTag( char chStart[], char chEnd[] ); //
108  void Trim( char chTarget[] =" \t\n\r" ); //
109  void TrimLeft( char chTarget[] = " \t\n\r" ); //
110  void TrimRight( char chTarget[] = " \t\n\r" ); //
111 
112  // 직접 구현한것 (MFC엔 없음)
113  char* GetStr(); //
114  CUString GetColorStr( char *color ); //
115  void SetStr( char arg_str[]); //
116  void SetStr( CUString arg_str); //
117  CUString SubStr( int start, int end ); //
118  unsigned int Count( char find );
119  unsigned int Count( char find[] );
120  bool IsNumber();
121  bool IsAlpha();
122  bool IsASCII();
123  void Print( FILE *fp = stdout );
124  void SetColor( char color[] );
125  static void NumberFormat( unsigned long size, CUString &str );
126  static void FileSizeFormat( unsigned long num, CUString &str);
127 
128  void Remove( char *str );
129  void Remove( CUString &str );
130 
131 
132 
133  // 한글 처리
134  int GetCharLength();
135  int CharToIdx( int nIndex );
136  CUString GetChar( int nIndex );
137  CUString GetChars( int nIndex, int nCount );
138  int DeleteChars( int nIndex, int nCount );
139 
140 
141  private:
142  char *str;
143  int len;
144  int char_len;
145 
146 
147  };
148 
149 }
150 
151 #endif
152