libcdos-fw
CFByteArray.h
1 #ifndef __CF_BYTEARRAY_H__
2 #define __CF_BYTEARRAY_H__
3 
8 #include <Core/CFTypes.h>
9 #include <Core/CFList.h>
10 
16 class CFByteArray {
17 
18 public:
22  CFByteArray();
23 
39  CFByteArray(const CFChar* str, int size = -1);
40 
56  CFByteArray(const CFUChar* str, int size = -1);
57 
62  CFByteArray(const CFByteArray& other);
63 
69  virtual ~CFByteArray();
70 
78  CFUInt size();
79 
89  CFUChar* data();
90 
100  const CFUChar* data() const;
101 
112  CFList<CFByteArray> split(CFUChar sep);
113 
123  CFByteArray sub(CFUInt pos, CFInt len);
124 
134  CFInt indexOf(CFUChar chr, int from = 0, bool caseSensitive = true);
135 
145  CFInt indexOf(const CFByteArray& str, int from = 0, bool caseSensitive = true);
146 
152  bool isEmpty() const;
153 
161  bool equal(const CFByteArray& other);
162 
172  CFInt compare(const CFByteArray& other);
173 
174  void display();
175 
176 public:
177  friend CFByteArray operator+(const CFByteArray& str1, const CFByteArray& str2);
178  friend CFByteArray operator+(const CFByteArray& str1, const CFUChar* str2);
179  friend CFByteArray operator+(const CFUChar* str1, const CFByteArray& str2);
180  friend CFByteArray operator+(const CFByteArray& str1, const CFChar* str2);
181  friend CFByteArray operator+(const CFChar* str1, const CFByteArray& str2);
182  // friend CFByteArray operator+(const CFUChar* str1, const CFUChar* str2);
183 
184  CFByteArray& operator=(const CFByteArray& str1);
185  CFByteArray& operator+=(const CFByteArray& str1);
186 
187  bool operator==(const CFByteArray& other);
188  bool operator!=(const CFByteArray& other);
189  bool operator>(const CFByteArray& other);
190  bool operator>=(const CFByteArray& other);
191  bool operator<(const CFByteArray& other);
192  bool operator<=(const CFByteArray& other);
193 
194 private:
195  CFUInt getUTF8length();
196  void create(const CFUChar* strdata, int size = -1);
197 
198  CFUInt dataLength(const CFUChar* strdata);
199  bool charEqual(CFUChar destChr, CFUChar srcChr, bool caseSensitive = true);
200 
201 private:
202  CFUChar* m_data;
203  CFUInt m_strLen;
204 };
205 
206 #endif // __CF_BYTEARRAY_H__
CFList 容器类.
Definition: CFList.h:15
CFList< CFByteArray > split(CFUChar sep)
使用sep对CFByteArray进行分割。
CFInt compare(const CFByteArray &other)
比较两个CFByteArray。
CFByteArray sub(CFUInt pos, CFInt len)
CFByteArray截取。
CFByteArray 字节数组.
Definition: CFByteArray.h:16
结构与枚举类型定义.
bool isEmpty() const
判断是否为空CFByteArray.
CFInt indexOf(CFUChar chr, int from=0, bool caseSensitive=true)
CFByteArray查找。
CFByteArray()
默认构造函数.
CFUInt size()
获取字节数组中数据的长度。
bool equal(const CFByteArray &other)
判断CFByteArray是否与 other CFByteArray相同.
virtual ~CFByteArray()
析构函数.
CFUChar * data()
获取字节数组中指向数据的指针。