Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core/src/util/MultiTypeString.h @ 792

Last change on this file since 792 was 792, checked in by landauf, 16 years ago

upload of the work i did before the exams (not yet finished nor working)

File size: 3.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 *   Inspiration: MultiType by Benjamin Grauer
27 */
28
29#ifndef _MultiTypeString_H__
30#define _MultiTypeString_H__
31
32#include <string>
33
34#include "UtilPrereqs.h"
35
36#include "MultiTypePrimitive.h"
37
38class _UtilExport MultiTypeString : public MultiTypePrimitive
39{
40    public:
41        MultiTypeString(MultiType      type = MT_null);
42        MultiTypeString(int            value) : MultiTypePrimitive(value) {}
43        MultiTypeString(unsigned int   value) : MultiTypePrimitive(value) {}
44        MultiTypeString(char           value) : MultiTypePrimitive(value) {}
45        MultiTypeString(unsigned char  value) : MultiTypePrimitive(value) {}
46        MultiTypeString(short          value) : MultiTypePrimitive(value) {}
47        MultiTypeString(unsigned short value) : MultiTypePrimitive(value) {}
48        MultiTypeString(long           value) : MultiTypePrimitive(value) {}
49        MultiTypeString(unsigned long  value) : MultiTypePrimitive(value) {}
50        MultiTypeString(float          value) : MultiTypePrimitive(value) {}
51        MultiTypeString(double         value) : MultiTypePrimitive(value) {}
52        MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
53        MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
54        MultiTypeString(const char*        value) { this->setValue(value); }
55        MultiTypeString(const std::string& value) { this->setValue(value); }
56        MultiTypeString(const MultiTypeString& mtp);
57
58        MultiTypeString& operator=(const char*        value) { this->setValue(value); return *this; }
59        MultiTypeString& operator=(const std::string& value) { this->setValue(value); return *this; }
60        MultiTypeString& operator=(const MultiTypeString& mtp);
61
62        bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
63        bool operator==(const std::string& value) const { return (this->string_ == value); }
64        bool operator==(const MultiTypeString& mtp) const;
65
66        bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
67        bool operator!=(const std::string& value) const { return (this->string_ != value); }
68        bool operator!=(const MultiTypeString& mtp) const;
69
70        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
71        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value; }
72        void setValue(const MultiTypeString& mtp);
73
74        inline std::string& getString() { return this->string_; }
75
76        inline void getValue(std::string* variable) const { (*variable) = std::string(this->string_); }
77
78    protected:
79        std::string string_;
80};
81
82#endif /* _MultiTypeString_H__ */
Note: See TracBrowser for help on using the repository browser.