OW_Char16.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
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; // in 3.1.0
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 } // end namespace OW_NAMESPACE
00334 
00335 #endif

Generated on Thu Feb 9 08:47:52 2006 for openwbem by  doxygen 1.4.6