tufao  0.8.1
An asynchronous web framework for C++ built on top of Qt
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
ibytearray.h
1 /*
2  Copyright (c) 2012 Vinícius dos Santos Oliveira
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in all
12  copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  SOFTWARE.
21  */
22 
23 #ifndef TUFAO_IBYTEARRAY_H
24 #define TUFAO_IBYTEARRAY_H
25 
26 #include <QtCore/QByteArray>
27 #include "tufao_global.h"
28 
29 namespace Tufao {
30 
38 class TUFAO_EXPORT IByteArray : public QByteArray
39 {
40 public:
41  IByteArray();
42  IByteArray(const QByteArray &ba);
43  IByteArray(const char *str);
44  IByteArray(const char *data, int size);
45  IByteArray(int size, char ch);
46  operator QByteArray() const;
47 
48  bool operator !=(const IByteArray &ba) const;
49  bool operator <(const IByteArray &ba) const;
50  bool operator <=(const IByteArray &ba) const;
51  IByteArray &operator =(const IByteArray &ba);
52  bool operator == (const IByteArray &ba) const;
53  bool operator >(const IByteArray &ba) const;
54  bool operator >=(const IByteArray &ba) const;
55 
56  bool operator !=(const QByteArray &ba) const;
57  bool operator <(const QByteArray &ba) const;
58  bool operator <=(const QByteArray &ba) const;
59  IByteArray &operator =(const QByteArray &ba);
60  bool operator == (const QByteArray &ba) const;
61  bool operator >(const QByteArray &ba) const;
62  bool operator >=(const QByteArray &ba) const;
63 };
64 
65 inline IByteArray::IByteArray()
66 {}
67 
68 inline IByteArray::IByteArray(const QByteArray &ba) :
69  QByteArray(ba)
70 {}
71 
72 inline IByteArray::IByteArray(const char *str) :
73  QByteArray(str)
74 {}
75 
76 inline IByteArray::IByteArray(const char *data, int size) :
77  QByteArray(data, size)
78 {}
79 
80 inline IByteArray::IByteArray(int size, char ch) :
81  QByteArray(size, ch)
82 {}
83 
84 inline IByteArray::operator QByteArray() const
85 {
86  return QByteArray(*this);
87 }
88 
89 inline bool IByteArray::operator !=(const IByteArray &ba) const
90 {
91  return qstricmp(constData(), ba.constData()) != 0;
92 }
93 
94 inline bool IByteArray::operator <(const IByteArray &ba) const
95 {
96  return qstricmp(constData(), ba.constData()) < 0;
97 }
98 
99 inline bool IByteArray::operator <=(const IByteArray &ba) const
100 {
101  return qstricmp(constData(), ba.constData()) <= 0;
102 }
103 
104 inline IByteArray &IByteArray::operator =(const IByteArray &ba)
105 {
106  static_cast<QByteArray&>(*this) = ba;
107  return *this;
108 }
109 
110 inline bool IByteArray::operator ==(const IByteArray &ba) const
111 {
112  return qstricmp(constData(), ba.constData()) == 0;
113 }
114 
115 inline bool IByteArray::operator >(const IByteArray &ba) const
116 {
117  return qstricmp(constData(), ba.constData()) > 0;
118 }
119 
120 inline bool IByteArray::operator >=(const IByteArray &ba) const
121 {
122  return qstricmp(constData(), ba.constData()) >= 0;
123 }
124 
125 inline bool IByteArray::operator !=(const QByteArray &ba) const
126 {
127  return qstricmp(constData(), ba.constData()) != 0;
128 }
129 
130 inline bool IByteArray::operator <(const QByteArray &ba) const
131 {
132  return qstricmp(constData(), ba.constData()) < 0;
133 }
134 
135 inline bool IByteArray::operator <=(const QByteArray &ba) const
136 {
137  return qstricmp(constData(), ba.constData()) <= 0;
138 }
139 
140 inline IByteArray &IByteArray::operator =(const QByteArray &ba)
141 {
142  static_cast<QByteArray&>(*this) = ba;
143  return *this;
144 }
145 
146 inline bool IByteArray::operator ==(const QByteArray &ba) const
147 {
148  return qstricmp(constData(), ba.constData()) == 0;
149 }
150 
151 inline bool IByteArray::operator >(const QByteArray &ba) const
152 {
153  return qstricmp(constData(), ba.constData()) > 0;
154 }
155 
156 inline bool IByteArray::operator >=(const QByteArray &ba) const
157 {
158  return qstricmp(constData(), ba.constData()) >= 0;
159 }
160 
161 } // namespace Tufao
162 
163 #endif // TUFAO_IBYTEARRAY_H
This class provides a case insensitive QByteArray.
Definition: ibytearray.h:38