OWBI1_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 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 } // end namespace OWBI1
00328 
00329 #endif

Generated on Thu Feb 9 08:48:25 2006 for openwbem by  doxygen 1.4.6