Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2008, 11:24:44 PM (16 years ago)
Author:
rgrieder
Message:
  • set the svn:eol-style property to all files so, that where ever you check out, you'll get the right line endings (had to change every file with mixed endings to windows in order to set the property)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/util/MultiTypeString.h

    • Property svn:eol-style set to native
    r1446 r1494  
    1 /*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
    5  *
    6  *   License notice:
    7  *
    8  *   This program is free software; you can redistribute it and/or
    9  *   modify it under the terms of the GNU General Public License
    10  *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    21  *
    22  *   Author:
    23  *      Fabian 'x3n' Landau
    24  *   Co-authors:
    25  *      ...
    26  *
    27  *   Inspiration: MultiType by Benjamin Grauer
    28  */
    29 
    30 #ifndef _MultiTypeString_H__
    31 #define _MultiTypeString_H__
    32 
    33 #include "UtilPrereqs.h"
    34 
    35 #include <string>
    36 #include <iostream>
    37 
    38 #include "MultiTypePrimitive.h"
    39 
    40 // disable annoying warning about multiple assignment operators
     1/* *   ORXONOX - the hottest 3D action shooter ever to exist *                    > www.orxonox.net < * * *   License notice: * *   This program is free software; you can redistribute it and/or *   modify it under the terms of the GNU General Public License *   as published by the Free Software Foundation; either version 2 *   of the License, or (at your option) any later version. * *   This program is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with this program; if not, write to the Free Software *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. * *   Author: *      Fabian 'x3n' Landau *   Co-authors: *      ... * *   Inspiration: MultiType by Benjamin Grauer */#ifndef _MultiTypeString_H__#define _MultiTypeString_H__#include "UtilPrereqs.h"#include <string>#include <iostream>#include "MultiTypePrimitive.h"// disable annoying warning about multiple assignment operators
    412#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    423#pragma warning(push)
    434#pragma warning(disable:4522)
    445#endif
    45 
    46 class _UtilExport MultiTypeString : public MultiTypePrimitive
    47 {
    48     public:
    49         MultiTypeString(MultiType type = MT_null);
    50         inline MultiTypeString(void*          value) : MultiTypePrimitive(value) {}
    51         inline MultiTypeString(int            value) : MultiTypePrimitive(value) {}
    52         inline MultiTypeString(unsigned int   value) : MultiTypePrimitive(value) {}
    53         inline MultiTypeString(char           value) : MultiTypePrimitive(value) {}
    54         inline MultiTypeString(unsigned char  value) : MultiTypePrimitive(value) {}
    55         inline MultiTypeString(short          value) : MultiTypePrimitive(value) {}
    56         inline MultiTypeString(unsigned short value) : MultiTypePrimitive(value) {}
    57         inline MultiTypeString(long           value) : MultiTypePrimitive(value) {}
    58         inline MultiTypeString(unsigned long  value) : MultiTypePrimitive(value) {}
    59         inline MultiTypeString(float          value) : MultiTypePrimitive(value) {}
    60         inline MultiTypeString(double         value) : MultiTypePrimitive(value) {}
    61         inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
    62         inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
    63         inline MultiTypeString(const char*             value) { this->setValue(value); }
    64         inline MultiTypeString(const std::string&      value) { this->setValue(value); }
    65         inline MultiTypeString(const MultiTypeString&    mts)  { this->setValue(mts);   }
    66         inline MultiTypeString(const MultiTypePrimitive& mtp)  { this->setValue(mtp);   }
    67         virtual inline ~MultiTypeString() {}
    68 
    69         using MultiTypePrimitive::operator=;
    70         inline MultiTypeString& operator=(const char*             value) { this->setValue(value); return *this; }
    71         inline MultiTypeString& operator=(const std::string&      value) { this->setValue(value); return *this; }
    72         inline MultiTypeString& operator=(const MultiTypeString&    mts) { this->setValue(mts);   return *this; }
    73         inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp);   return *this; }
    74 
    75         using MultiTypePrimitive::operator==;
    76         inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
    77         inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
    78         bool operator==(const MultiTypeString&    mts) const;
    79         bool operator==(const MultiTypePrimitive& mtp) const;
    80 
    81         using MultiTypePrimitive::operator!=;
    82         inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
    83         inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
    84         bool operator!=(const MultiTypeString&    mts) const;
    85         bool operator!=(const MultiTypePrimitive& mtp) const;
    86 
    87         virtual operator void*()          const;
    88         virtual operator int()            const;
    89         virtual operator unsigned int()   const;
    90         virtual operator char()           const;
    91         virtual operator unsigned char()  const;
    92         virtual operator short()          const;
    93         virtual operator unsigned short() const;
    94         virtual operator long()           const;
    95         virtual operator unsigned long()  const;
    96         virtual operator float ()         const;
    97         virtual operator double ()        const;
    98         virtual operator long double()    const;
    99         virtual operator bool()           const;
    100         virtual operator std::string()    const;
    101         virtual operator const char*()    const;
    102 
    103         using MultiTypePrimitive::setValue;
    104         inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
    105         inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
    106         void setValue(const MultiTypeString&    mts);
    107         void setValue(const MultiTypePrimitive& mtp);
    108 
    109         inline std::string getString()     const { return this->string_;         }
    110         inline const char*  getConstChar() const { return this->string_.c_str(); }
    111 
    112         inline std::string& getString()    { return this->string_;         }
    113         inline const char*  getConstChar() { return this->string_.c_str(); }
    114 
    115         using MultiTypePrimitive::getValue;
    116         inline void getValue(std::string* variable) const { (*variable) = this->string_;         }
    117         inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }
    118 
    119         virtual std::string getTypename() const;
    120 
    121         virtual std::string toString() const;
    122         virtual bool fromString(const std::string value);
    123 
    124         virtual bool assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue = MultiTypeString());
    125 
    126     protected:
    127         std::string      string_;
    128 };
    129 
    130 _UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeString& mts);
    131 
    132 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     6class _UtilExport MultiTypeString : public MultiTypePrimitive{    public:        MultiTypeString(MultiType type = MT_null);        inline MultiTypeString(void*          value) : MultiTypePrimitive(value) {}        inline MultiTypeString(int            value) : MultiTypePrimitive(value) {}        inline MultiTypeString(unsigned int   value) : MultiTypePrimitive(value) {}        inline MultiTypeString(char           value) : MultiTypePrimitive(value) {}        inline MultiTypeString(unsigned char  value) : MultiTypePrimitive(value) {}        inline MultiTypeString(short          value) : MultiTypePrimitive(value) {}        inline MultiTypeString(unsigned short value) : MultiTypePrimitive(value) {}        inline MultiTypeString(long           value) : MultiTypePrimitive(value) {}        inline MultiTypeString(unsigned long  value) : MultiTypePrimitive(value) {}        inline MultiTypeString(float          value) : MultiTypePrimitive(value) {}        inline MultiTypeString(double         value) : MultiTypePrimitive(value) {}        inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}        inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}        inline MultiTypeString(const char*             value) { this->setValue(value); }        inline MultiTypeString(const std::string&      value) { this->setValue(value); }        inline MultiTypeString(const MultiTypeString&    mts)  { this->setValue(mts);   }        inline MultiTypeString(const MultiTypePrimitive& mtp)  { this->setValue(mtp);   }        virtual inline ~MultiTypeString() {}        using MultiTypePrimitive::operator=;        inline MultiTypeString& operator=(const char*             value) { this->setValue(value); return *this; }        inline MultiTypeString& operator=(const std::string&      value) { this->setValue(value); return *this; }        inline MultiTypeString& operator=(const MultiTypeString&    mts) { this->setValue(mts);   return *this; }        inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp);   return *this; }        using MultiTypePrimitive::operator==;        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }        bool operator==(const MultiTypeString&    mts) const;        bool operator==(const MultiTypePrimitive& mtp) const;        using MultiTypePrimitive::operator!=;        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }        bool operator!=(const MultiTypeString&    mts) const;        bool operator!=(const MultiTypePrimitive& mtp) const;        virtual operator void*()          const;        virtual operator int()            const;        virtual operator unsigned int()   const;        virtual operator char()           const;        virtual operator unsigned char()  const;        virtual operator short()          const;        virtual operator unsigned short() const;        virtual operator long()           const;        virtual operator unsigned long()  const;        virtual operator float ()         const;        virtual operator double ()        const;        virtual operator long double()    const;        virtual operator bool()           const;        virtual operator std::string()    const;        virtual operator const char*()    const;        using MultiTypePrimitive::setValue;        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }        void setValue(const MultiTypeString&    mts);        void setValue(const MultiTypePrimitive& mtp);        inline std::string getString()     const { return this->string_;         }        inline const char*  getConstChar() const { return this->string_.c_str(); }        inline std::string& getString()    { return this->string_;         }        inline const char*  getConstChar() { return this->string_.c_str(); }        using MultiTypePrimitive::getValue;        inline void getValue(std::string* variable) const { (*variable) = this->string_;         }        inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }        virtual std::string getTypename() const;        virtual std::string toString() const;        virtual bool fromString(const std::string value);        virtual bool assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue = MultiTypeString());    protected:        std::string      string_;};_UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeString& mts);#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    1337#pragma warning(pop)
    134 #endif
    135 
    136 #endif /* _MultiTypeString_H__ */
     8#endif#endif /* _MultiTypeString_H__ */
Note: See TracChangeset for help on using the changeset viewer.