00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #ifndef OW_CHAR16_HPP_INCLUDE_GUARD_
00037 #define OW_CHAR16_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_ArrayFwd.hpp"
00040 #include "OW_Types.hpp"
00041 #include "OW_Bool.hpp"
00042 #include "OW_CommonFwd.hpp"
00043 #include <iosfwd>
00044
00045 namespace OW_NAMESPACE
00046 {
00047
00048 class String;
00052 class OW_COMMON_API Char16
00053 {
00054 public:
00058 Char16() : m_value(0) {}
00063 Char16(const Char16& arg) : m_value(arg.m_value) {}
00068 explicit Char16(char c) : m_value(c) {}
00074 explicit Char16(const String& x);
00081 Char16(UInt16 val) : m_value(val) {}
00086 explicit Char16(Int16 val) : m_value(val) {}
00091 explicit Char16(UInt8 val) : m_value(val) {}
00096 explicit Char16(Int8 val) : m_value(val) {}
00101 explicit Char16(UInt32 val) : m_value(val) {}
00106 explicit Char16(Int32 val) : m_value(val) {}
00111 explicit Char16(UInt64 val) : m_value(static_cast<UInt16>(val)) {}
00116 explicit Char16(Int64 val) : m_value(static_cast<UInt16>(val)) {}
00121 explicit Char16(Real32 val) : m_value(static_cast<UInt16>(val)) {}
00126 explicit Char16(Real64 val) : m_value(static_cast<UInt16>(val)) {}
00131 explicit Char16(Bool val) : m_value(val) {}
00135 UInt16 getValue() const { return m_value; }
00139 operator UInt16() const { return getValue(); }
00145 Char16& operator= (const Char16& arg)
00146 {
00147 m_value = arg.m_value;
00148 return *this;
00149 }
00155 bool operator== (const Char16& arg) const
00156 {
00157 return m_value == arg.m_value;
00158 }
00164 bool operator!= (const Char16& arg) const
00165 {
00166 return m_value != arg.m_value;
00167 }
00173 bool operator< (const Char16& arg) const
00174 {
00175 return m_value < arg.m_value;
00176 }
00183 bool operator<= (const Char16& arg) const
00184 {
00185 return m_value <= arg.m_value;
00186 }
00192 bool operator> (const Char16& arg) const
00193 {
00194 return m_value > arg.m_value;
00195 }
00202 bool operator>= (const Char16& arg) const
00203 {
00204 return m_value >= arg.m_value;
00205 }
00211 Char16& operator+= (const Char16& arg)
00212 {
00213 m_value += arg.m_value;
00214 return *this;
00215 }
00221 Char16& operator-= (const Char16& arg)
00222 {
00223 m_value -= arg.m_value;
00224 return *this;
00225 }
00231 Char16& operator*= (const Char16& arg)
00232 {
00233 m_value *= arg.m_value;
00234 return *this;
00235 }
00241 Char16& operator/= (const Char16& arg)
00242 {
00243 m_value /= arg.m_value;
00244 return *this;
00245 }
00246
00247 typedef UInt16 Char16::*safe_bool;
00248 operator safe_bool () const
00249 { return m_value ? &Char16::m_value : 0; }
00250 bool operator!() const
00251 { return !m_value; }
00255 String toUTF8() const OW_DEPRECATED;
00259 String toString() const;
00264 void writeObject(std::ostream& ostrm) const;
00269 void readObject(std::istream& istrm);
00270 private:
00271 UInt16 m_value;
00272 };
00273 OW_EXPORT_TEMPLATE(OW_COMMON_API, Array, Char16);
00274
00275 inline bool operator== (char c, const Char16& arg)
00276 {
00277 return Char16(c) == arg;
00278 }
00279 inline bool operator== (const Char16& arg, int v)
00280 {
00281 return (arg.getValue() == v);
00282 }
00283 inline bool operator== (int v, const Char16& arg)
00284 {
00285 return (arg.getValue() == v);
00286 }
00287 inline bool operator!= (const Char16& arg, int v)
00288 {
00289 return (arg.getValue() != v);
00290 }
00291 inline bool operator!= (int v, const Char16& arg)
00292 {
00293 return (arg.getValue() != v);
00294 }
00295 inline bool operator!= (char c, const Char16& arg)
00296 {
00297 return Char16(c) != arg;
00298 }
00299 inline bool operator< (char c, const Char16& arg)
00300 {
00301 return Char16(c) < arg;
00302 }
00303 inline bool operator<= (char c, const Char16& arg)
00304 {
00305 return Char16(c) <= arg;
00306 }
00307 inline bool operator> (char c, const Char16& arg)
00308 {
00309 return Char16(c) > arg;
00310 }
00311 inline bool operator>= (char c, const Char16& arg)
00312 {
00313 return Char16(c) >= arg;
00314 }
00315 inline Char16 operator+ (const Char16& arg1, const Char16& arg2)
00316 {
00317 return Char16(UInt16(arg1.getValue() + arg2.getValue()));
00318 }
00319 inline Char16 operator- (const Char16& arg1, const Char16& arg2)
00320 {
00321 return Char16(UInt16(arg1.getValue() - arg2.getValue()));
00322 }
00323 inline Char16 operator* (const Char16& arg1, const Char16& arg2)
00324 {
00325 return Char16(UInt16(arg1.getValue() * arg2.getValue()));
00326 }
00327 inline Char16 operator/ (const Char16& arg1, const Char16& arg2)
00328 {
00329 return Char16(UInt16(arg1.getValue() / arg2.getValue()));
00330 }
00331 OW_COMMON_API std::ostream& operator<< (std::ostream& ostrm, const Char16& arg);
00332
00333 }
00334
00335 #endif