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 OWBI1_CHAR16_HPP_INCLUDE_GUARD_
00037 #define OWBI1_CHAR16_HPP_INCLUDE_GUARD_
00038 #include "OWBI1_config.h"
00039 #include "OWBI1_ArrayFwd.hpp"
00040 #include "OWBI1_Types.hpp"
00041 #include "OWBI1_Bool.hpp"
00042 #include "OWBI1_CommonFwd.hpp"
00043 #include <iosfwd>
00044
00045 namespace OWBI1
00046 {
00047
00048 class String;
00052 class OWBI1_OWBI1PROVIFC_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 toString() const;
00260 void writeObject(std::ostream& ostrm) const;
00265 void readObject(std::istream& istrm);
00266 private:
00267 UInt16 m_value;
00268 };
00269 inline bool operator== (char c, const Char16& arg)
00270 {
00271 return Char16(c) == arg;
00272 }
00273 inline bool operator== (const Char16& arg, int v)
00274 {
00275 return (arg.getValue() == v);
00276 }
00277 inline bool operator== (int v, const Char16& arg)
00278 {
00279 return (arg.getValue() == v);
00280 }
00281 inline bool operator!= (const Char16& arg, int v)
00282 {
00283 return (arg.getValue() != v);
00284 }
00285 inline bool operator!= (int v, const Char16& arg)
00286 {
00287 return (arg.getValue() != v);
00288 }
00289 inline bool operator!= (char c, const Char16& arg)
00290 {
00291 return Char16(c) != arg;
00292 }
00293 inline bool operator< (char c, const Char16& arg)
00294 {
00295 return Char16(c) < arg;
00296 }
00297 inline bool operator<= (char c, const Char16& arg)
00298 {
00299 return Char16(c) <= arg;
00300 }
00301 inline bool operator> (char c, const Char16& arg)
00302 {
00303 return Char16(c) > arg;
00304 }
00305 inline bool operator>= (char c, const Char16& arg)
00306 {
00307 return Char16(c) >= arg;
00308 }
00309 inline Char16 operator+ (const Char16& arg1, const Char16& arg2)
00310 {
00311 return Char16(UInt16(arg1.getValue() + arg2.getValue()));
00312 }
00313 inline Char16 operator- (const Char16& arg1, const Char16& arg2)
00314 {
00315 return Char16(UInt16(arg1.getValue() - arg2.getValue()));
00316 }
00317 inline Char16 operator* (const Char16& arg1, const Char16& arg2)
00318 {
00319 return Char16(UInt16(arg1.getValue() * arg2.getValue()));
00320 }
00321 inline Char16 operator/ (const Char16& arg1, const Char16& arg2)
00322 {
00323 return Char16(UInt16(arg1.getValue() / arg2.getValue()));
00324 }
00325 OWBI1_OWBI1PROVIFC_API std::ostream& operator<< (std::ostream& ostrm, const Char16& arg);
00326
00327 }
00328
00329 #endif