tufao  1.3.0
An asynchronous web framework for C++ built on top of Qt
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 
51 class TUFAO_EXPORT IByteArray : public QByteArray
52 {
53 public:
54  IByteArray();
55  IByteArray(const QByteArray &ba);
56  IByteArray(const char *str);
57  IByteArray(const char *data, int size);
58  IByteArray(int size, char ch);
59 
60  IByteArray &operator =(const QByteArray &ba);
61 };
62 
63 inline IByteArray::IByteArray()
64 {}
65 
66 inline IByteArray::IByteArray(const QByteArray &ba) :
67  QByteArray(ba)
68 {}
69 
70 inline IByteArray::IByteArray(const char *str) :
71  QByteArray(str)
72 {}
73 
74 inline IByteArray::IByteArray(const char *data, int size) :
75  QByteArray(data, size)
76 {}
77 
78 inline IByteArray::IByteArray(int size, char ch) :
79  QByteArray(size, ch)
80 {}
81 
82 inline IByteArray &IByteArray::operator =(const QByteArray &ba)
83 {
84  static_cast<QByteArray&>(*this) = ba;
85  return *this;
86 }
87 
88 // Non-member functions:
89 
90 inline bool operator !=(const IByteArray &lhs, const IByteArray &rhs)
91 {
92  return qstricmp(lhs.constData(), rhs.constData()) != 0;
93 }
94 
95 inline bool operator <(const IByteArray &lhs, const IByteArray &rhs)
96 {
97  return qstricmp(lhs.constData(), rhs.constData()) < 0;
98 }
99 
100 inline bool operator <=(const IByteArray &lhs, const IByteArray &rhs)
101 {
102  return qstricmp(lhs.constData(), rhs.constData()) <= 0;
103 }
104 
105 inline bool operator ==(const IByteArray &lhs, const IByteArray &rhs)
106 {
107  return qstricmp(lhs.constData(), rhs.constData()) == 0;
108 }
109 
110 inline bool operator >(const IByteArray &lhs, const IByteArray &rhs)
111 {
112  return qstricmp(lhs.constData(), rhs.constData()) > 0;
113 }
114 
115 inline bool operator >=(const IByteArray &lhs, const IByteArray &rhs)
116 {
117  return qstricmp(lhs.constData(), rhs.constData()) >= 0;
118 }
119 
120 inline uint qHash(const IByteArray &key)
121 {
122  return qHash(key.toLower());
123 }
124 
125 } // namespace Tufao
126 
127 #endif // TUFAO_IBYTEARRAY_H
This class provides a case insensitive QByteArray.
Definition: ibytearray.h:51
This is the namespace where all Tufão facilities are grouped.
Definition: abstracthttpserverrequesthandler.h:30