Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2008, 11:24:44 PM (17 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)
Location:
code/branches/network/src/util
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/util/ArgReader.cc

    • Property svn:eol-style set to native
    r1062 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
  • code/branches/network/src/util/ArgReader.h

    • Property svn:eol-style set to native
    r1062 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  *      Benjamin Knecht <beni_at_orxonox.net>
    24  *   Co-authors:
    25  *      ...
    26  *
    27  */
    28 
    29 /**
     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: *      Benjamin Knecht <beni_at_orxonox.net> *   Co-authors: *      ... * *//**
    302 @file  Argreader.h
    313 @brief reads arguments
     
    368#define _ArgReader_H__
    379
    38 #include "UtilPrereqs.h"
    39 
    40 #include <string>
    41 
     10#include "UtilPrereqs.h"#include <string>
    4211class _UtilExport ArgReader
    4312{
  • code/branches/network/src/util/CMakeLists.txt

    • Property svn:eol-style set to native
  • code/branches/network/src/util/Clipboard.cc

    • Property svn:eol-style set to native
  • code/branches/network/src/util/Clipboard.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/Convert.h

    • Property svn:eol-style set to native
    r1446 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    2221 *   Author:
    2322 *      Benjamin Grauer
    24  *      Fabian 'x3n' Landau
    25  *   Co-authors:
    26  *      ...
     23 *      Fabian 'x3n' Landau *   Co-authors: *      ...
    2724 */
    2825
     
    4946#pragma warning(disable:4100 4800)
    5047#endif
    51 
    52 
    53 //////////
    54 // MAIN //
    55 //////////
    56 
    57 // Enum to declare the wanted conversion preference in case of equal type-levels
    58 enum ConversionPreference
    59 {
    60     CP_PreferToType,
    61     CP_PreferFromType,
    62 };
    63 
    64 // Helper classes to determine the preferred partial template specialization
    65 class _ToType_   {};
    66 class _FromType_ {};
    67 class _Explicit_ {};
    68 
    69 
    70 // The default convert functions
    71 template <class FromType, class ToType, class Type>
    72 struct ConverterSpecialized
    73 {
    74     enum { specialized = false };
    75     static bool convert(ToType* output, const FromType& input)
    76     { return false; }
    77 };
    78 
    79 
    80 // The default convert function if both types are the same
    81 template <class BothTypes>
    82 struct ConverterSpecialized<BothTypes, BothTypes, _Explicit_>
    83 {
    84     enum { specialized = true };
    85     static bool convert(BothTypes* output, const BothTypes& input)
    86     { (*output) = input; return true; }
    87 };
    88 
    89 
    90 // The possible levels
    91 #define __low__  0 // Everything that is or behaves like a primitive type (an can be converted with a typecast to every other low-level type)
    92 #define __mid__  1 // Everything that has overloaded << and >> operators to operate on a std::stream
    93 #define __high__ 2 // Everything that doesn't fullfill the lowerlevel-requirements and therefore needs specialized conversions
    94 
    95 // Defines the levels of all types: Default is __high__ so you don't have to define every high-level type
    96 template <class T> struct ConverterLevel           { enum { level = __high__ }; };
    97 template <> struct ConverterLevel<std::string>     { enum { level = __mid__ }; };
    98 template <> struct ConverterLevel<orxonox::Radian> { enum { level = __mid__ }; };
    99 template <> struct ConverterLevel<orxonox::Degree> { enum { level = __mid__ }; };
    100 template <> struct ConverterLevel<int>             { enum { level = __low__ }; };
    101 template <> struct ConverterLevel<unsigned int>    { enum { level = __low__ }; };
    102 template <> struct ConverterLevel<char>            { enum { level = __low__ }; };
    103 template <> struct ConverterLevel<unsigned char>   { enum { level = __low__ }; };
    104 template <> struct ConverterLevel<short>           { enum { level = __low__ }; };
    105 template <> struct ConverterLevel<unsigned short>  { enum { level = __low__ }; };
    106 template <> struct ConverterLevel<long>            { enum { level = __low__ }; };
    107 template <> struct ConverterLevel<unsigned long>   { enum { level = __low__ }; };
    108 template <> struct ConverterLevel<float>           { enum { level = __low__ }; };
    109 template <> struct ConverterLevel<double>          { enum { level = __low__ }; };
    110 template <> struct ConverterLevel<long double>     { enum { level = __low__ }; };
    111 template <> struct ConverterLevel<bool>            { enum { level = __low__ }; };
    112 
    113 
    114 // Calculates the preference based on the levels of FromType and ToType
    115 template <int from, int to>
    116 struct ConverterPreference
    117 {
    118     enum
    119     {
    120         // The maximum of both levels: element of {0, 1, 2}
    121         // max 0: Both types are primitives or have a similar behaviour
    122         // max 1: At least one type is not a primitive, but both can be put on a std::stream
    123         // max 2: There is at least one generic type that needs specialized conversions
    124         max = (from > to) ? from : to,
    125 
    126         // The difference between both levels limited to +-1: element of {-1, 0, 1}
    127         // diff -1: The FromType has higher level than the ToType
    128         // diff  0: Both types have the same level
    129         // diff  1: The ToType has higher level than the FromType
    130         diff = ((to - from) > 1) ? 1 : (((to - from) < -1) ? -1 : to - from)
    131     };
    132 };
    133 
    134 
    135 // The default conversion: This usually does nothing
    136 template <int max, class FromType, class ToType>
    137 struct ConverterDefault
    138 {
    139     static bool convert(ToType* output, const FromType& input)
    140     {
    141         return false;
    142     }
    143 };
    144 // The default conversion for primitives: A typecast (defined over two partial specialized templates to exclude all non-primitive types and classes)    template <int max, class FromType, class ToType>
    145 template <class FromType, class ToType>
    146 struct ConverterDefault<0, FromType, ToType>
    147 {
    148     static bool convert(ToType* output, const FromType& input)
    149     {
    150         (*output) = (ToType)input;
    151         return true;
    152     }
    153 };
    154 
    155 
    156 // Converter: Converts input of FromType into output of ToType
    157 template <int diff, int max, class FromType, class ToType, ConversionPreference pref>
    158 struct Converter
    159 {
    160     static bool convert(ToType* output, const FromType& input)
    161     {
    162         return false;
    163     }
    164 };
    165 // Converter: level{FromType} > level{ToType}
    166 template <int max, class FromType, class ToType, ConversionPreference pref>
    167 struct Converter<-1, max, FromType, ToType, pref>
    168 {   static bool convert(ToType* output, const FromType& input)
    169     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    170 // Converter: level{FromType} < level{ToType}
    171 template <int max, class FromType, class ToType, ConversionPreference pref>
    172 struct Converter<1, max, FromType, ToType, pref>
    173 {   static bool convert(ToType* output, const FromType& input)
    174     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    175 // Converter: level{FromType} = level{ToType}
    176 // CP_PreferToType
    177 template <int max, class FromType, class ToType>
    178 struct Converter<0, max, FromType, ToType, CP_PreferToType>
    179 {   static bool convert(ToType* output, const FromType& input)
    180     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    181 // CP_PreferFromType
    182 template <int max, class FromType, class ToType>
    183 struct Converter<0, max, FromType, ToType, CP_PreferFromType>
    184 {   static bool convert(ToType* output, const FromType& input)
    185     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    186 
    187 
    188 // Calls the Converter::convertValue function with the correct template type parameters calculated by ConverterPreference
    189 template <class FromType, class ToType>
    190 static bool convertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
    191 {
    192     return (preference == CP_PreferToType) ?
    193            Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
    194                      ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
    195                      FromType,
    196                      ToType,
    197                      CP_PreferToType>::convert(output, input)
    198          : Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
    199                      ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
    200                      FromType,
    201                      ToType,
    202                      CP_PreferFromType>::convert(output, input);
    203 }
    204 
    205 
    206 //////////////////////
    207 // HELPER FUNCTIONS //
    208 //////////////////////
    209 
    210 // Helper function: Calls convertValue with and without default value and returns true if the conversion was successful
    211 template<class FromType, class ToType>
    212 static bool ConvertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
    213 {
    214     return convertValue(output, input, preference);
    215 }
    216 template<class FromType, class ToType>
    217 static bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
    218 {
    219     if (convertValue(output, input, preference))
    220         return true;
    221 
    222     (*output) = fallback;
    223     return false;
    224 }
    225 
    226 // Helper function: Calls convertValue with and without default value and returns the converted value
    227 template<class FromType, class ToType>
    228 static ToType getConvertedValue(const FromType& input, ConversionPreference preference = CP_PreferToType)
    229 {
    230     ToType output = ToType();
    231     ConvertValue(&output, input, preference);
    232     return output;
    233 }
    234 template<class FromType, class ToType>
    235 static ToType getConvertedValue(const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
    236 {
    237     ToType output = fallback;
    238     ConvertValue(&output, input, fallback, preference);
    239     return output;
    240 }
    241 
    242 
     48//////////// MAIN ////////////// Enum to declare the wanted conversion preference in case of equal type-levelsenum ConversionPreference{    CP_PreferToType,    CP_PreferFromType,};// Helper classes to determine the preferred partial template specializationclass _ToType_   {};class _FromType_ {};class _Explicit_ {};// The default convert functionstemplate <class FromType, class ToType, class Type>struct ConverterSpecialized{    enum { specialized = false };    static bool convert(ToType* output, const FromType& input)    { return false; }};// The default convert function if both types are the sametemplate <class BothTypes>struct ConverterSpecialized<BothTypes, BothTypes, _Explicit_>{    enum { specialized = true };    static bool convert(BothTypes* output, const BothTypes& input)    { (*output) = input; return true; }};// The possible levels#define __low__  0 // Everything that is or behaves like a primitive type (an can be converted with a typecast to every other low-level type)#define __mid__  1 // Everything that has overloaded << and >> operators to operate on a std::stream#define __high__ 2 // Everything that doesn't fullfill the lowerlevel-requirements and therefore needs specialized conversions// Defines the levels of all types: Default is __high__ so you don't have to define every high-level typetemplate <class T> struct ConverterLevel           { enum { level = __high__ }; };template <> struct ConverterLevel<std::string>     { enum { level = __mid__ }; };template <> struct ConverterLevel<orxonox::Radian> { enum { level = __mid__ }; };template <> struct ConverterLevel<orxonox::Degree> { enum { level = __mid__ }; };template <> struct ConverterLevel<int>             { enum { level = __low__ }; };template <> struct ConverterLevel<unsigned int>    { enum { level = __low__ }; };template <> struct ConverterLevel<char>            { enum { level = __low__ }; };template <> struct ConverterLevel<unsigned char>   { enum { level = __low__ }; };template <> struct ConverterLevel<short>           { enum { level = __low__ }; };template <> struct ConverterLevel<unsigned short>  { enum { level = __low__ }; };template <> struct ConverterLevel<long>            { enum { level = __low__ }; };template <> struct ConverterLevel<unsigned long>   { enum { level = __low__ }; };template <> struct ConverterLevel<float>           { enum { level = __low__ }; };template <> struct ConverterLevel<double>          { enum { level = __low__ }; };template <> struct ConverterLevel<long double>     { enum { level = __low__ }; };template <> struct ConverterLevel<bool>            { enum { level = __low__ }; };// Calculates the preference based on the levels of FromType and ToTypetemplate <int from, int to>struct ConverterPreference{    enum    {        // The maximum of both levels: element of {0, 1, 2}        // max 0: Both types are primitives or have a similar behaviour        // max 1: At least one type is not a primitive, but both can be put on a std::stream        // max 2: There is at least one generic type that needs specialized conversions        max = (from > to) ? from : to,        // The difference between both levels limited to +-1: element of {-1, 0, 1}        // diff -1: The FromType has higher level than the ToType        // diff  0: Both types have the same level        // diff  1: The ToType has higher level than the FromType        diff = ((to - from) > 1) ? 1 : (((to - from) < -1) ? -1 : to - from)    };};// The default conversion: This usually does nothingtemplate <int max, class FromType, class ToType>struct ConverterDefault{    static bool convert(ToType* output, const FromType& input)    {        return false;    }};// The default conversion for primitives: A typecast (defined over two partial specialized templates to exclude all non-primitive types and classes)    template <int max, class FromType, class ToType>template <class FromType, class ToType>struct ConverterDefault<0, FromType, ToType>{    static bool convert(ToType* output, const FromType& input)    {        (*output) = (ToType)input;        return true;    }};// Converter: Converts input of FromType into output of ToTypetemplate <int diff, int max, class FromType, class ToType, ConversionPreference pref>struct Converter{    static bool convert(ToType* output, const FromType& input)    {        return false;    }};// Converter: level{FromType} > level{ToType}template <int max, class FromType, class ToType, ConversionPreference pref>struct Converter<-1, max, FromType, ToType, pref>{   static bool convert(ToType* output, const FromType& input)    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };// Converter: level{FromType} < level{ToType}template <int max, class FromType, class ToType, ConversionPreference pref>struct Converter<1, max, FromType, ToType, pref>{   static bool convert(ToType* output, const FromType& input)    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };// Converter: level{FromType} = level{ToType}// CP_PreferToTypetemplate <int max, class FromType, class ToType>struct Converter<0, max, FromType, ToType, CP_PreferToType>{   static bool convert(ToType* output, const FromType& input)    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };// CP_PreferFromTypetemplate <int max, class FromType, class ToType>struct Converter<0, max, FromType, ToType, CP_PreferFromType>{   static bool convert(ToType* output, const FromType& input)    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };// Calls the Converter::convertValue function with the correct template type parameters calculated by ConverterPreferencetemplate <class FromType, class ToType>static bool convertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType){    return (preference == CP_PreferToType) ?           Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,                     ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,                     FromType,                     ToType,                     CP_PreferToType>::convert(output, input)         : Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,                     ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,                     FromType,                     ToType,                     CP_PreferFromType>::convert(output, input);}//////////////////////// HELPER FUNCTIONS ////////////////////////// Helper function: Calls convertValue with and without default value and returns true if the conversion was successfultemplate<class FromType, class ToType>static bool ConvertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType){    return convertValue(output, input, preference);}template<class FromType, class ToType>static bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType){    if (convertValue(output, input, preference))        return true;    (*output) = fallback;    return false;}// Helper function: Calls convertValue with and without default value and returns the converted valuetemplate<class FromType, class ToType>static ToType getConvertedValue(const FromType& input, ConversionPreference preference = CP_PreferToType){    ToType output = ToType();    ConvertValue(&output, input, preference);    return output;}template<class FromType, class ToType>static ToType getConvertedValue(const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType){    ToType output = fallback;    ConvertValue(&output, input, fallback, preference);    return output;}
    24349/////////////////////
    24450// SPECIALIZATIONS //
    24551/////////////////////
    246 
    247 /////////////
    248 // SAMPLES //
    249 /////////////
    250 /*
    251 // convert everything to xyz
    252 template <class FromType>
    253 struct ConverterSpecialized<FromType, xyz, _ToType_>
    254 {
    255     enum { specialized = true };
    256     static bool convert(xyz* output, const FromType& input)
    257     { return ...; }
    258 };
    259 
    260 // convert xyz to everything
    261 template <class ToType>
    262 struct ConverterSpecialized<xyz, ToType, _FromType_>
    263 {
    264     enum { specialized = true };
    265     static bool convert(ToType* output, const xyz& input)
    266     { return ...; }
    267 };
    268 
    269 // convert abc to xyz
    270 template <>
    271 struct ConverterSpecialized<abc, xyz, _Explicit_>
    272 {
    273     enum { specialized = true };
    274     static bool convert(xyz* output, const abc& input)
    275     { return ...; }
    276 };
    277 */
    278 
    279 ////////////
    280 // STRING //
    281 ////////////
    282 
    283 // convert to string
    284 template <class FromType>
    285 struct ConverterSpecialized<FromType, std::string, _ToType_>
    286 {
    287     enum { specialized = true };
    288     static bool convert(std::string* output, const FromType& input)
    289     {
    290         std::ostringstream oss;
    291         if (oss << input)
    292         {
    293             (*output) = oss.str();
    294             return true;
    295         }
    296         else
    297             return false;
    298     }
    299 };
    300 
    301 // convert from string
    302 template <class ToType>
    303 struct ConverterSpecialized<std::string, ToType, _FromType_>
    304 {
    305     enum { specialized = true };
    306     static bool convert(ToType* output, const std::string& input)
    307     {
    308         std::istringstream iss(input);
    309         if (iss >> (*output))
    310             return true;
    311         else
    312             return false;
    313     }
    314 };
    315 
    316 
    317 ////////////////
    318 // MULTITYPES //
    319 ////////////////
    320 
    321 // convert from MultiTypePrimitive
    322 template <class ToType>
    323 struct ConverterSpecialized<MultiTypePrimitive, ToType, _FromType_>
    324 {
    325     enum { specialized = true };
    326     static bool convert(ToType* output, const MultiTypePrimitive& input)
    327     {
    328         if (input.getType() == MT_void)
    329             return ConvertValue(output, input.getVoid());
    330         else if (input.getType() == MT_int)
    331             return ConvertValue(output, input.getInt());
    332         else if (input.getType() == MT_uint)
    333             return ConvertValue(output, input.getUnsignedInt());
    334         else if (input.getType() == MT_char)
    335             return ConvertValue(output, input.getChar());
    336         else if (input.getType() == MT_uchar)
    337             return ConvertValue(output, input.getUnsignedChar());
    338         else if (input.getType() == MT_short)
    339             return ConvertValue(output, input.getShort());
    340         else if (input.getType() == MT_ushort)
    341             return ConvertValue(output, input.getUnsignedShort());
    342         else if (input.getType() == MT_long)
    343             return ConvertValue(output, input.getLong());
    344         else if (input.getType() == MT_ulong)
    345             return ConvertValue(output, input.getUnsignedLong());
    346         else if (input.getType() == MT_float)
    347             return ConvertValue(output, input.getFloat());
    348         else if (input.getType() == MT_double)
    349             return ConvertValue(output, input.getDouble());
    350         else if (input.getType() == MT_longdouble)
    351             return ConvertValue(output, input.getLongDouble());
    352         else if (input.getType() == MT_bool)
    353             return ConvertValue(output, input.getBool());
    354         else
    355             return false;
    356     }
    357 };
    358 
    359 // convert from MultiTypeString
    360 template <class ToType>
    361 struct ConverterSpecialized<MultiTypeString, ToType, _FromType_>
    362 {
    363     enum { specialized = true };
    364     static bool convert(ToType* output, const MultiTypeString& input)
    365     {
    366         if (input.getType() == MT_constchar)
    367             return ConvertValue(output, input.getConstChar());
    368         else if (input.getType() == MT_string)
    369             return ConvertValue(output, input.getString());
    370         else
    371             return ConvertValue(output, (MultiTypePrimitive)input);
    372     }
    373 };
    374 
    375 // convert from MultiTypeMath
    376 template <class ToType>
    377 struct ConverterSpecialized<MultiTypeMath, ToType, _FromType_>
    378 {
    379     enum { specialized = true };
    380     static bool convert(ToType* output, const MultiTypeMath& input)
    381     {
    382         if (input.getType() == MT_vector2)
    383             return ConvertValue(output, input.getVector2());
    384         else if (input.getType() == MT_vector3)
    385             return ConvertValue(output, input.getVector3());
    386         else if (input.getType() == MT_vector4)
    387             return ConvertValue(output, input.getVector4());
    388         else if (input.getType() == MT_quaternion)
    389             return ConvertValue(output, input.getQuaternion());
    390         else if (input.getType() == MT_colourvalue)
    391             return ConvertValue(output, input.getColourValue());
    392         else if (input.getType() == MT_radian)
    393             return ConvertValue(output, input.getRadian());
    394         else if (input.getType() == MT_degree)
    395             return ConvertValue(output, input.getDegree());
    396         else
    397             return ConvertValue(output, (MultiTypeString)input);
    398     }
    399 };
    400 
    401 
     52/////////////// SAMPLES ////////////////*// convert everything to xyztemplate <class FromType>struct ConverterSpecialized<FromType, xyz, _ToType_>{    enum { specialized = true };    static bool convert(xyz* output, const FromType& input)    { return ...; }};// convert xyz to everythingtemplate <class ToType>struct ConverterSpecialized<xyz, ToType, _FromType_>{    enum { specialized = true };    static bool convert(ToType* output, const xyz& input)    { return ...; }};// convert abc to xyztemplate <>struct ConverterSpecialized<abc, xyz, _Explicit_>{    enum { specialized = true };    static bool convert(xyz* output, const abc& input)    { return ...; }};*/////////////// STRING //////////////// convert to stringtemplate <class FromType>struct ConverterSpecialized<FromType, std::string, _ToType_>{    enum { specialized = true };    static bool convert(std::string* output, const FromType& input)    {        std::ostringstream oss;        if (oss << input)        {            (*output) = oss.str();            return true;        }        else            return false;    }};// convert from stringtemplate <class ToType>struct ConverterSpecialized<std::string, ToType, _FromType_>{    enum { specialized = true };    static bool convert(ToType* output, const std::string& input)    {        std::istringstream iss(input);        if (iss >> (*output))            return true;        else            return false;    }};////////////////// MULTITYPES //////////////////// convert from MultiTypePrimitivetemplate <class ToType>struct ConverterSpecialized<MultiTypePrimitive, ToType, _FromType_>{    enum { specialized = true };    static bool convert(ToType* output, const MultiTypePrimitive& input)    {        if (input.getType() == MT_void)            return ConvertValue(output, input.getVoid());        else if (input.getType() == MT_int)            return ConvertValue(output, input.getInt());        else if (input.getType() == MT_uint)            return ConvertValue(output, input.getUnsignedInt());        else if (input.getType() == MT_char)            return ConvertValue(output, input.getChar());        else if (input.getType() == MT_uchar)            return ConvertValue(output, input.getUnsignedChar());        else if (input.getType() == MT_short)            return ConvertValue(output, input.getShort());        else if (input.getType() == MT_ushort)            return ConvertValue(output, input.getUnsignedShort());        else if (input.getType() == MT_long)            return ConvertValue(output, input.getLong());        else if (input.getType() == MT_ulong)            return ConvertValue(output, input.getUnsignedLong());        else if (input.getType() == MT_float)            return ConvertValue(output, input.getFloat());        else if (input.getType() == MT_double)            return ConvertValue(output, input.getDouble());        else if (input.getType() == MT_longdouble)            return ConvertValue(output, input.getLongDouble());        else if (input.getType() == MT_bool)            return ConvertValue(output, input.getBool());        else            return false;    }};// convert from MultiTypeStringtemplate <class ToType>struct ConverterSpecialized<MultiTypeString, ToType, _FromType_>{    enum { specialized = true };    static bool convert(ToType* output, const MultiTypeString& input)    {        if (input.getType() == MT_constchar)            return ConvertValue(output, input.getConstChar());        else if (input.getType() == MT_string)            return ConvertValue(output, input.getString());        else            return ConvertValue(output, (MultiTypePrimitive)input);    }};// convert from MultiTypeMathtemplate <class ToType>struct ConverterSpecialized<MultiTypeMath, ToType, _FromType_>{    enum { specialized = true };    static bool convert(ToType* output, const MultiTypeMath& input)    {        if (input.getType() == MT_vector2)            return ConvertValue(output, input.getVector2());        else if (input.getType() == MT_vector3)            return ConvertValue(output, input.getVector3());        else if (input.getType() == MT_vector4)            return ConvertValue(output, input.getVector4());        else if (input.getType() == MT_quaternion)            return ConvertValue(output, input.getQuaternion());        else if (input.getType() == MT_colourvalue)            return ConvertValue(output, input.getColourValue());        else if (input.getType() == MT_radian)            return ConvertValue(output, input.getRadian());        else if (input.getType() == MT_degree)            return ConvertValue(output, input.getDegree());        else            return ConvertValue(output, (MultiTypeString)input);    }};
    40253////////////////////
    40354// MATH TO STRING //
    40455////////////////////
    405 
    406 // Vector2 to std::string
    407 template <>
    408 struct ConverterSpecialized<orxonox::Vector2, std::string, _Explicit_>
    409 {
    410     enum { specialized = true };
    411     static bool convert(std::string* output, const orxonox::Vector2& input)
    412     {
    413         std::ostringstream ostream;
    414         if (ostream << input.x << "," << input.y)
    415         {
    416             (*output) = ostream.str();
    417             return true;
    418         }
    419         return false;
    420     }
    421 };
    422 
    423 // Vector3 to std::string
    424 template <>
    425 struct ConverterSpecialized<orxonox::Vector3, std::string, _Explicit_>
    426 {
    427     enum { specialized = true };
    428     static bool convert(std::string* output, const orxonox::Vector3& input)
    429     {
    430         std::ostringstream ostream;
    431         if (ostream << input.x << "," << input.y << "," << input.z)
    432         {
    433             (*output) = ostream.str();
    434             return true;
    435         }
    436         return false;
    437     }
    438 };
    439 
    440 // Vector4 to std::string
    441 template <>
    442 struct ConverterSpecialized<orxonox::Vector4, std::string, _Explicit_>
    443 {
    444     enum { specialized = true };
    445     static bool convert(std::string* output, const orxonox::Vector4& input)
    446     {
    447         std::ostringstream ostream;
    448         if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
    449         {
    450             (*output) = ostream.str();
    451             return true;
    452         }
    453         return false;
    454     }
    455 };
    456 
    457 // Quaternion to std::string
    458 template <>
    459 struct ConverterSpecialized<orxonox::Quaternion, std::string, _Explicit_>
    460 {
    461     enum { specialized = true };
    462     static bool convert(std::string* output, const orxonox::Quaternion& input)
    463     {
    464         std::ostringstream ostream;
    465         if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
    466         {
    467             (*output) = ostream.str();
    468             return true;
    469         }
    470         return false;
    471     }
    472 };
    473 
    474 // ColourValue to std::string
    475 template <>
    476 struct ConverterSpecialized<orxonox::ColourValue, std::string, _Explicit_>
    477 {
    478     enum { specialized = true };
    479     static bool convert(std::string* output, const orxonox::ColourValue& input)
    480     {
    481         std::ostringstream ostream;
    482         if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
    483         {
    484             (*output) = ostream.str();
    485             return true;
    486         }
    487         return false;
    488     }
    489 };
    490 
    491 
    492 ////////////////////
     56// Vector2 to std::stringtemplate <>struct ConverterSpecialized<orxonox::Vector2, std::string, _Explicit_>{    enum { specialized = true };    static bool convert(std::string* output, const orxonox::Vector2& input)    {        std::ostringstream ostream;        if (ostream << input.x << "," << input.y)        {            (*output) = ostream.str();            return true;        }        return false;    }};// Vector3 to std::stringtemplate <>struct ConverterSpecialized<orxonox::Vector3, std::string, _Explicit_>{    enum { specialized = true };    static bool convert(std::string* output, const orxonox::Vector3& input)    {        std::ostringstream ostream;        if (ostream << input.x << "," << input.y << "," << input.z)        {            (*output) = ostream.str();            return true;        }        return false;    }};// Vector4 to std::stringtemplate <>struct ConverterSpecialized<orxonox::Vector4, std::string, _Explicit_>{    enum { specialized = true };    static bool convert(std::string* output, const orxonox::Vector4& input)    {        std::ostringstream ostream;        if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)        {            (*output) = ostream.str();            return true;        }        return false;    }};// Quaternion to std::stringtemplate <>struct ConverterSpecialized<orxonox::Quaternion, std::string, _Explicit_>{    enum { specialized = true };    static bool convert(std::string* output, const orxonox::Quaternion& input)    {        std::ostringstream ostream;        if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)        {            (*output) = ostream.str();            return true;        }        return false;    }};// ColourValue to std::stringtemplate <>struct ConverterSpecialized<orxonox::ColourValue, std::string, _Explicit_>{    enum { specialized = true };    static bool convert(std::string* output, const orxonox::ColourValue& input)    {        std::ostringstream ostream;        if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)        {            (*output) = ostream.str();            return true;        }        return false;    }};////////////////////
    49357// STRING TO MATH //
    49458////////////////////
    495 
    496 // std::string to Vector2
    497 template <>
    498 struct ConverterSpecialized<std::string, orxonox::Vector2, _Explicit_>
    499 {
    500     enum { specialized = true };
    501     static bool convert(orxonox::Vector2* output, const std::string& input)
    502     {
    503         unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
    504         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    505 
    506         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    507         if (tokens.size() >= 2)
    508         {
    509             if (!ConvertValue(&(output->x), tokens[0]))
    510                 return false;
    511             if (!ConvertValue(&(output->y), tokens[1]))
    512                 return false;
    513 
    514             return true;
    515         }
    516         return false;
    517     }
    518 };
    519 
    520 // std::string to Vector3
    521 template <>
    522 struct ConverterSpecialized<std::string, orxonox::Vector3, _Explicit_>
    523 {
    524     enum { specialized = true };
    525     static bool convert(orxonox::Vector3* output, const std::string& input)
    526     {
    527         unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
    528         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    529 
    530         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    531         if (tokens.size() >= 3)
    532         {
    533             if (!ConvertValue(&(output->x), tokens[0]))
    534                 return false;
    535             if (!ConvertValue(&(output->y), tokens[1]))
    536                 return false;
    537             if (!ConvertValue(&(output->z), tokens[2]))
    538                 return false;
    539 
    540             return true;
    541         }
    542         return false;
    543     }
    544 };
    545 
    546 // std::string to Vector4
    547 template <>
    548 struct ConverterSpecialized<std::string, orxonox::Vector4, _Explicit_>
    549 {
    550     enum { specialized = true };
    551     static bool convert(orxonox::Vector4* output, const std::string& input)
    552     {
    553         unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
    554         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    555 
    556         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    557         if (tokens.size() >= 4)
    558         {
    559             if (!ConvertValue(&(output->x), tokens[0]))
    560                 return false;
    561             if (!ConvertValue(&(output->y), tokens[1]))
    562                 return false;
    563             if (!ConvertValue(&(output->z), tokens[2]))
    564                 return false;
    565             if (!ConvertValue(&(output->w), tokens[3]))
    566                 return false;
    567 
    568             return true;
    569         }
    570         return false;
    571     }
    572 };
    573 
    574 // std::string to Quaternion
    575 template <>
    576 struct ConverterSpecialized<std::string, orxonox::Quaternion, _Explicit_>
    577 {
    578     enum { specialized = true };
    579     static bool convert(orxonox::Quaternion* output, const std::string& input)
    580     {
    581         unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
    582         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    583 
    584         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    585         if (tokens.size() >= 4)
    586         {
    587             if (!ConvertValue(&(output->w), tokens[0]))
    588                 return false;
    589             if (!ConvertValue(&(output->x), tokens[1]))
    590                 return false;
    591             if (!ConvertValue(&(output->y), tokens[2]))
    592                 return false;
    593             if (!ConvertValue(&(output->z), tokens[3]))
    594                 return false;
    595 
    596             return true;
    597         }
    598         return false;
    599     }
    600 };
    601 
    602 // std::string to ColourValue
    603 template <>
    604 struct ConverterSpecialized<std::string, orxonox::ColourValue, _Explicit_>
    605 {
    606     enum { specialized = true };
    607     static bool convert(orxonox::ColourValue* output, const std::string& input)
    608     {
    609         unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
    610         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    611 
    612         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    613         if (tokens.size() >= 4)
    614         {
    615             if (!ConvertValue(&(output->r), tokens[0]))
    616                 return false;
    617             if (!ConvertValue(&(output->g), tokens[1]))
    618                 return false;
    619             if (!ConvertValue(&(output->b), tokens[2]))
    620                 return false;
    621             if (!ConvertValue(&(output->a), tokens[3]))
    622                 return false;
    623 
    624             return true;
    625         }
    626         return false;
    627     }
    628 };
    629 
    630 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     59// std::string to Vector2template <>struct ConverterSpecialized<std::string, orxonox::Vector2, _Explicit_>{    enum { specialized = true };    static bool convert(orxonox::Vector2* output, const std::string& input)    {        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');        if (tokens.size() >= 2)        {            if (!ConvertValue(&(output->x), tokens[0]))                return false;            if (!ConvertValue(&(output->y), tokens[1]))                return false;            return true;        }        return false;    }};// std::string to Vector3template <>struct ConverterSpecialized<std::string, orxonox::Vector3, _Explicit_>{    enum { specialized = true };    static bool convert(orxonox::Vector3* output, const std::string& input)    {        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');        if (tokens.size() >= 3)        {            if (!ConvertValue(&(output->x), tokens[0]))                return false;            if (!ConvertValue(&(output->y), tokens[1]))                return false;            if (!ConvertValue(&(output->z), tokens[2]))                return false;            return true;        }        return false;    }};// std::string to Vector4template <>struct ConverterSpecialized<std::string, orxonox::Vector4, _Explicit_>{    enum { specialized = true };    static bool convert(orxonox::Vector4* output, const std::string& input)    {        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');        if (tokens.size() >= 4)        {            if (!ConvertValue(&(output->x), tokens[0]))                return false;            if (!ConvertValue(&(output->y), tokens[1]))                return false;            if (!ConvertValue(&(output->z), tokens[2]))                return false;            if (!ConvertValue(&(output->w), tokens[3]))                return false;            return true;        }        return false;    }};// std::string to Quaterniontemplate <>struct ConverterSpecialized<std::string, orxonox::Quaternion, _Explicit_>{    enum { specialized = true };    static bool convert(orxonox::Quaternion* output, const std::string& input)    {        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');        if (tokens.size() >= 4)        {            if (!ConvertValue(&(output->w), tokens[0]))                return false;            if (!ConvertValue(&(output->x), tokens[1]))                return false;            if (!ConvertValue(&(output->y), tokens[2]))                return false;            if (!ConvertValue(&(output->z), tokens[3]))                return false;            return true;        }        return false;    }};// std::string to ColourValuetemplate <>struct ConverterSpecialized<std::string, orxonox::ColourValue, _Explicit_>{    enum { specialized = true };    static bool convert(orxonox::ColourValue* output, const std::string& input)    {        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');        if (tokens.size() >= 4)        {            if (!ConvertValue(&(output->r), tokens[0]))                return false;            if (!ConvertValue(&(output->g), tokens[1]))                return false;            if (!ConvertValue(&(output->b), tokens[2]))                return false;            if (!ConvertValue(&(output->a), tokens[3]))                return false;            return true;        }        return false;    }};#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    63160#pragma warning(pop)
    63261#endif
    633 
    63462#endif /* _Convert_H__ */
  • code/branches/network/src/util/ExprParser.cc

    • Property svn:eol-style set to native
    r1120 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    3130  @brief Declaration of FloatParser
    3231*/
    33 
    34 #include "ExprParser.h"
    35 #include <cmath>
    36 #include <cstring>
    37 
    38 // macros for easier if, else statements
    39 #define CASE_1(var) if (!strcmp(SWITCH,var))
    40 #define CASE(var) else if (!strcmp(SWITCH,var))
    41 #define CASE_ELSE else
    42 
    43 //! skip white spaces
    44 #define PARSE_BLANKS while (*reading_stream == ' ') ++reading_stream;
    45 
    46 ExprParser::ExprParser(const std::string& str)
    47 {
    48   this->failed_ = false;
    49   this->reading_stream = str.c_str();
    50   if (str.size() == 0 || *reading_stream == '\0')
    51   {
    52     this->failed_ = true;
    53     this->result_ = 0.0;
    54   }
    55   else
    56   {
    57     this->result_ = parse_expr_8();
    58     this->remains_ = reading_stream;
    59   }
    60 }
    61 
    62 //Private functions:
    63 /******************/
    64 double ExprParser::parse_argument()
    65 {
    66    double value = parse_expr_8();
    67    if (*reading_stream == ',')
    68    {
    69       ++reading_stream;
    70       return value;
    71    }
    72    else
    73    {
    74      this->failed_ = true;
    75      return 0;
    76    }
    77 }
    78 
    79 double ExprParser::parse_last_argument()
    80 {
    81    double value = parse_expr_8();
    82    if (*reading_stream == ')')
    83    {
    84       ++reading_stream;
    85       return value;
    86    }
    87    else
    88    {
    89      this->failed_ = true;
    90      return 0;
    91    }
    92 }
    93 
    94 double ExprParser::parse_expr_8()
    95 {
    96    double value = parse_expr_7();
    97    for(;;)
    98    {
    99       switch (op)
    100       {
    101          case oder:
    102             value = parse_expr_7() || value;
    103             break;
    104          default: return value;
    105       }
    106    };
    107 }
    108 
    109 
    110 double ExprParser::parse_expr_7()
    111 {
    112    double value = parse_expr_6();
    113    for(;;)
    114    {
    115       switch (op)
    116       {
    117          case und:
    118             value = value && parse_expr_6();
    119             break;
    120          default: return value;
    121       }
    122    };
    123 }
    124 
    125 double ExprParser::parse_expr_6()
    126 {
    127    double value = parse_expr_5();
    128    for(;;)
    129    {
    130       switch (op)
    131       {
    132          case gleich:
    133             value = (value == parse_expr_5());
    134             break;
    135          case ungleich:
    136             value = (value != parse_expr_5());
    137             break;
    138          default:
    139             return value;
    140       }
    141    };
    142 }
    143 
    144 double ExprParser::parse_expr_5()
    145 {
    146    double value = parse_expr_4();
    147    for(;;)
    148    {
    149       switch (op)
    150       {
    151          case kleiner:
    152             value = (value < parse_expr_4());
    153             break;
    154          case kleinergleich:
    155             value = (value <= parse_expr_4());
    156             break;
    157          case groesser:
    158             value = (value > parse_expr_4());
    159             break;
    160          case groessergleich:
    161             value = (value >= parse_expr_4());
    162             break;
    163          default:
    164             return value;
    165       }
    166    };
    167 }
    168 
    169 double ExprParser::parse_expr_4()
    170 {
    171    double value = parse_expr_3();
    172    for(;;)
    173    {
    174       switch (op)
    175       {
    176          case b_plus:
    177             value += parse_expr_3();
    178             break;
    179          case b_minus:
    180             value -= parse_expr_3();
    181             break;
    182          default:
    183             return value;
    184       }
    185    };
    186 }
    187 
    188 double ExprParser::parse_expr_3()
    189 {
    190    double value = parse_expr_2();
    191    for(;;)
    192    {
    193       switch (op)
    194       {
    195          case mal:
    196             value *= parse_expr_2();
    197             break;
    198          case durch:
    199             value /= parse_expr_2();
    200             break;
    201          case modulo:
    202          {
    203             double temp = parse_expr_2();
    204             value = value - floor(value/temp)*temp;
    205             break;
    206          }
    207          default:
    208             return value;
    209       }
    210    };
    211 }
    212 
    213 double ExprParser::parse_expr_2()
    214 {
    215    double value = parse_expr_1();
    216    while (*reading_stream != '\0')
    217    {
    218       op = parse_binary_operator();
    219       switch (op)
    220       {
    221          case hoch:
    222             value = pow(value,parse_expr_1());
    223             break;
    224          default:
    225             return value;
    226       }
    227    };
    228    op = undef;
    229    return value;
    230 }
    231 
    232 double ExprParser::parse_expr_1()
    233 {
    234    PARSE_BLANKS
    235    double value;
    236 
    237    unary_operator op = parse_unary_operator();
    238    PARSE_BLANKS
    239 
    240    if (*reading_stream == '\0')
    241    {
    242      // end of string
    243      this->failed_ = true;
    244      return 0;
    245    }
    246    else if (*reading_stream > 47 && *reading_stream < 59 || *reading_stream == 46)
    247    {  // number
    248       value = strtod(reading_stream, const_cast<char**>(&reading_stream));
    249    }
    250    else if (*reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
    251    {  // variable or function
    252       char* word = new char[256];
    253       parse_word(word);
    254       PARSE_BLANKS
    255       if (*reading_stream == '(')
    256       {
    257          ++reading_stream;
    258 #define SWITCH word
    259          CASE_1("sin")
    260             value = sin(parse_last_argument());
    261          CASE("asin")
    262             value = asin(parse_last_argument());
    263          CASE("sinh")
    264             value = sinh(parse_last_argument());
    265          CASE("asinh")
    266          {
    267             value = parse_last_argument();
    268             value = log(sqrt(pow(value, 2) + 1) + value);
    269          }
    270          CASE("cos")
    271             value = cos(parse_last_argument());
    272          CASE("acos")
    273             value = acos(parse_last_argument());
    274          CASE("cosh")
    275             value = cosh(parse_last_argument());
    276          CASE("acosh")
    277          {
    278             value = parse_last_argument();
    279             value = log(sqrt(pow(value, 2) - 1) + value);
    280          }
    281          CASE("tan")
    282             value = tan(parse_last_argument());
    283          CASE("atan")
    284             value = atan(parse_last_argument());
    285          CASE("atan2")
    286             value = atan2(parse_argument(),parse_last_argument());
    287          CASE("tanh")
    288             value = tanh(parse_last_argument());
    289          CASE("atanh")
    290          {
    291             value = parse_last_argument();
    292             value = 0.5*log((value + 1)/(value - 1));
    293          }
    294          CASE("int")
    295             value = floor(parse_last_argument());
    296          CASE("floor")
    297             value = floor(parse_last_argument());
    298          CASE("ceil")
    299             value = ceil(parse_last_argument());
    300          CASE("abs")
    301             value = fabs(parse_last_argument());
    302          CASE("exp")
    303             value = exp(parse_last_argument());
    304          CASE("log")
    305             value = log10(parse_last_argument());
    306          CASE("ln")
    307             value = log(parse_last_argument());
    308          CASE("sign")
    309          {
    310             value = parse_last_argument();
    311             value = (value>0 ? 1 : (value<0 ? -1 : 0));
    312          }
    313          CASE("sqrt")
    314             value = sqrt(parse_last_argument());
    315          CASE("degrees")
    316             value = parse_last_argument()*180/3.1415926535897932;
    317          CASE("radians")
    318             value = parse_last_argument()*3.1415926535897932/180;
    319          CASE("mod")
    320          {
    321             value = parse_argument();
    322             double value2 = parse_last_argument();
    323             value = value - floor(value/value2)*value2;
    324          }
    325          CASE("pow")
    326             value = pow(parse_argument(),parse_last_argument());
    327          CASE("div")
    328             value = floor(parse_argument()/parse_last_argument());
    329          CASE("max")
    330            value = std::max(parse_argument(),parse_last_argument());
    331          CASE("min")
    332            value = std::min(parse_argument(),parse_last_argument());
    333          CASE_ELSE
    334          {
    335            this->failed_ = true;
    336            delete[] word;
    337            return 0;
    338          }
    339       }
    340       else
    341       {
    342 #define SWITCH word
    343          CASE_1("pi")
    344            value = 3.1415926535897932;
    345          CASE("e")
    346            value = 2.7182818284590452;
    347          CASE_ELSE
    348          {
    349            this->failed_ = true;
    350            delete[] word;
    351            return 0;
    352          }
    353       }
    354       delete[] word;
    355    }
    356    else if (*reading_stream == 40)
    357    {  // expresion in paranthesis
    358       ++reading_stream;
    359       value = parse_last_argument();
    360    }
    361    else
    362    {
    363      this->failed_ = true;
    364      return 0;
    365    }
    366 
    367    PARSE_BLANKS
    368    switch (op)
    369    {
    370       case u_nicht: return !value;
    371       case u_plus:  return  value;
    372       case u_minus: return -value;
    373       default:
    374         {
    375           this->failed_ = true;
    376           return 0;
    377         }
    378    }
    379 }
    380 
    381 char* ExprParser::parse_word(char* str)
    382 {
    383    char* word = str;
    384    int counter = 0;
    385    while (*reading_stream > 47 && *reading_stream < 58 || *reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
    386    {
    387       *word++ = *reading_stream++;
    388       counter++;
    389       if (counter > 255)
    390       {
    391         this->failed_ = true;
    392         return '\0';
    393       }
    394    };
    395    *word = '\0';
    396    return str;
    397 }
    398 
    399 ExprParser::binary_operator ExprParser::parse_binary_operator()
    400 {
    401    binary_operator op;
    402    switch (*reading_stream)
    403    {
    404       case '+': op = b_plus; break;
    405       case '-': op = b_minus; break;
    406       case '*': op = mal; break;
    407       case '/': op = durch; break;
    408       case '^': op = hoch; break;
    409       case '%': op = modulo; break;
    410       case '&': op = und; break;
    411       case '|': op = oder; break;
    412       case '=': op = gleich; break;
    413       case '!': op = b_nicht; break;
    414       case '<': op = kleiner; break;
    415       case '>': op = groesser; break;
    416       default: return undef;
    417    }
    418    if (*++reading_stream == '=')
    419    {
    420       if (op > 9)
    421       {
    422          ++reading_stream;
    423          return (binary_operator)(op + 3);
    424       }
    425       else
    426       {
    427          --reading_stream;
    428          return undef;
    429       }
    430    }
    431    else
    432       return op;
    433 }
    434 
    435 ExprParser::unary_operator ExprParser::parse_unary_operator()
    436 {
    437    switch (*reading_stream)
    438    {
    439       case '!':
    440          ++reading_stream;
    441          return u_nicht;
    442       case '+':
    443          ++reading_stream;
    444          return u_plus;
    445       case '-':
    446          ++reading_stream;
    447          return u_minus;
    448       default :
    449          return u_plus;
    450    }
    451 }
     32#include "ExprParser.h"#include <cmath>#include <cstring>// macros for easier if, else statements#define CASE_1(var) if (!strcmp(SWITCH,var))#define CASE(var) else if (!strcmp(SWITCH,var))#define CASE_ELSE else//! skip white spaces#define PARSE_BLANKS while (*reading_stream == ' ') ++reading_stream;ExprParser::ExprParser(const std::string& str){  this->failed_ = false;  this->reading_stream = str.c_str();  if (str.size() == 0 || *reading_stream == '\0')  {    this->failed_ = true;    this->result_ = 0.0;  }  else  {    this->result_ = parse_expr_8();    this->remains_ = reading_stream;  }}//Private functions:/******************/double ExprParser::parse_argument(){   double value = parse_expr_8();   if (*reading_stream == ',')   {      ++reading_stream;      return value;   }   else   {     this->failed_ = true;     return 0;   }}double ExprParser::parse_last_argument(){   double value = parse_expr_8();   if (*reading_stream == ')')   {      ++reading_stream;      return value;   }   else   {     this->failed_ = true;     return 0;   }}double ExprParser::parse_expr_8(){   double value = parse_expr_7();   for(;;)   {      switch (op)      {         case oder:            value = parse_expr_7() || value;            break;         default: return value;      }   };}double ExprParser::parse_expr_7(){   double value = parse_expr_6();   for(;;)   {      switch (op)      {         case und:            value = value && parse_expr_6();            break;         default: return value;      }   };}double ExprParser::parse_expr_6(){   double value = parse_expr_5();   for(;;)   {      switch (op)      {         case gleich:            value = (value == parse_expr_5());            break;         case ungleich:            value = (value != parse_expr_5());            break;         default:            return value;      }   };}double ExprParser::parse_expr_5(){   double value = parse_expr_4();   for(;;)   {      switch (op)      {         case kleiner:            value = (value < parse_expr_4());            break;         case kleinergleich:            value = (value <= parse_expr_4());            break;         case groesser:            value = (value > parse_expr_4());            break;         case groessergleich:            value = (value >= parse_expr_4());            break;         default:            return value;      }   };}double ExprParser::parse_expr_4(){   double value = parse_expr_3();   for(;;)   {      switch (op)      {         case b_plus:            value += parse_expr_3();            break;         case b_minus:            value -= parse_expr_3();            break;         default:            return value;      }   };}double ExprParser::parse_expr_3(){   double value = parse_expr_2();   for(;;)   {      switch (op)      {         case mal:            value *= parse_expr_2();            break;         case durch:            value /= parse_expr_2();            break;         case modulo:         {            double temp = parse_expr_2();            value = value - floor(value/temp)*temp;            break;         }         default:            return value;      }   };}double ExprParser::parse_expr_2(){   double value = parse_expr_1();   while (*reading_stream != '\0')   {      op = parse_binary_operator();      switch (op)      {         case hoch:            value = pow(value,parse_expr_1());            break;         default:            return value;      }   };   op = undef;   return value;}double ExprParser::parse_expr_1(){   PARSE_BLANKS   double value;   unary_operator op = parse_unary_operator();   PARSE_BLANKS   if (*reading_stream == '\0')   {     // end of string     this->failed_ = true;     return 0;   }   else if (*reading_stream > 47 && *reading_stream < 59 || *reading_stream == 46)   {  // number      value = strtod(reading_stream, const_cast<char**>(&reading_stream));   }   else if (*reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)   {  // variable or function      char* word = new char[256];      parse_word(word);      PARSE_BLANKS      if (*reading_stream == '(')      {         ++reading_stream;#define SWITCH word         CASE_1("sin")            value = sin(parse_last_argument());         CASE("asin")            value = asin(parse_last_argument());         CASE("sinh")            value = sinh(parse_last_argument());         CASE("asinh")         {            value = parse_last_argument();            value = log(sqrt(pow(value, 2) + 1) + value);         }         CASE("cos")            value = cos(parse_last_argument());         CASE("acos")            value = acos(parse_last_argument());         CASE("cosh")            value = cosh(parse_last_argument());         CASE("acosh")         {            value = parse_last_argument();            value = log(sqrt(pow(value, 2) - 1) + value);         }         CASE("tan")            value = tan(parse_last_argument());         CASE("atan")            value = atan(parse_last_argument());         CASE("atan2")            value = atan2(parse_argument(),parse_last_argument());         CASE("tanh")            value = tanh(parse_last_argument());         CASE("atanh")         {            value = parse_last_argument();            value = 0.5*log((value + 1)/(value - 1));         }         CASE("int")            value = floor(parse_last_argument());         CASE("floor")            value = floor(parse_last_argument());         CASE("ceil")            value = ceil(parse_last_argument());         CASE("abs")            value = fabs(parse_last_argument());         CASE("exp")            value = exp(parse_last_argument());         CASE("log")            value = log10(parse_last_argument());         CASE("ln")            value = log(parse_last_argument());         CASE("sign")         {            value = parse_last_argument();            value = (value>0 ? 1 : (value<0 ? -1 : 0));         }         CASE("sqrt")            value = sqrt(parse_last_argument());         CASE("degrees")            value = parse_last_argument()*180/3.1415926535897932;         CASE("radians")            value = parse_last_argument()*3.1415926535897932/180;         CASE("mod")         {            value = parse_argument();            double value2 = parse_last_argument();            value = value - floor(value/value2)*value2;         }         CASE("pow")            value = pow(parse_argument(),parse_last_argument());         CASE("div")            value = floor(parse_argument()/parse_last_argument());         CASE("max")           value = std::max(parse_argument(),parse_last_argument());         CASE("min")           value = std::min(parse_argument(),parse_last_argument());         CASE_ELSE         {           this->failed_ = true;           delete[] word;           return 0;         }      }      else      {#define SWITCH word         CASE_1("pi")           value = 3.1415926535897932;         CASE("e")           value = 2.7182818284590452;         CASE_ELSE         {           this->failed_ = true;           delete[] word;           return 0;         }      }      delete[] word;   }   else if (*reading_stream == 40)   {  // expresion in paranthesis      ++reading_stream;      value = parse_last_argument();   }   else   {     this->failed_ = true;     return 0;   }   PARSE_BLANKS   switch (op)   {      case u_nicht: return !value;      case u_plus:  return  value;      case u_minus: return -value;      default:        {          this->failed_ = true;          return 0;        }   }}char* ExprParser::parse_word(char* str){   char* word = str;   int counter = 0;   while (*reading_stream > 47 && *reading_stream < 58 || *reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)   {      *word++ = *reading_stream++;      counter++;      if (counter > 255)      {        this->failed_ = true;        return '\0';      }   };   *word = '\0';   return str;}ExprParser::binary_operator ExprParser::parse_binary_operator(){   binary_operator op;   switch (*reading_stream)   {      case '+': op = b_plus; break;      case '-': op = b_minus; break;      case '*': op = mal; break;      case '/': op = durch; break;      case '^': op = hoch; break;      case '%': op = modulo; break;      case '&': op = und; break;      case '|': op = oder; break;      case '=': op = gleich; break;      case '!': op = b_nicht; break;      case '<': op = kleiner; break;      case '>': op = groesser; break;      default: return undef;   }   if (*++reading_stream == '=')   {      if (op > 9)      {         ++reading_stream;         return (binary_operator)(op + 3);      }      else      {         --reading_stream;         return undef;      }   }   else      return op;}ExprParser::unary_operator ExprParser::parse_unary_operator(){   switch (*reading_stream)   {      case '!':         ++reading_stream;         return u_nicht;      case '+':         ++reading_stream;         return u_plus;      case '-':         ++reading_stream;         return u_minus;      default :         return u_plus;   }}
  • code/branches/network/src/util/ExprParser.h

    • Property svn:eol-style set to native
    r1120 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    3130  @brief Declaration of FloatParser
    3231*/
    33 
    34 #ifndef _FloatParser_H__
    35 #define _FloatParser_H__
    36 
    37 #include "UtilPrereqs.h"
    38 #include <string>
    39 
    40 class _UtilExport ExprParser
    41 {
    42 public:
    43   enum binary_operator
    44   {
    45     b_plus,
    46     b_minus,
    47     mal,
    48     durch,
    49     modulo,
    50     hoch,
    51     undef,
    52     oder,
    53     und,
    54     gleich,
    55     b_nicht,
    56     kleiner,
    57     groesser,
    58     ungleich,
    59     kleinergleich,
    60     groessergleich
    61   };
    62 
    63   enum unary_operator
    64   {
    65     u_plus,
    66     u_minus,
    67     u_nicht
    68   };
    69 
    70 
    71   ExprParser(const std::string& str);
    72   std::string& getRemains() { return  this->remains_; }
    73   double       getResult()  { return  this->result_; }
    74   bool         getSuccess() { return !this->failed_; }
    75 
    76 private:
    77   double parse_expr_1();
    78   double parse_expr_2();
    79   double parse_expr_3();
    80   double parse_expr_4();
    81   double parse_expr_5();
    82   double parse_expr_6();
    83   double parse_expr_7();
    84   double parse_expr_8();
    85   char* parse_word(char* str);
    86   binary_operator parse_binary_operator();
    87   unary_operator parse_unary_operator();
    88 
    89   double parse_argument();
    90   double parse_last_argument();
    91 
    92   binary_operator op;
    93   const char* reading_stream;
    94   bool failed_;
    95   double result_;
    96   std::string remains_;
    97 
    98 };
    99 
    100 //Endzeichen für float expression: ')', '}', ']', ',', ';'
    101 _UtilExport bool parse_float(char* const, char**, double*);
    102 //Endzeichen angegeben
    103 _UtilExport bool parse_float(char* const, char**, char, double*);
    104 //Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen)
    105 _UtilExport bool parse_vector_float(char* const, char**, bool, double*);
    106 
    107 #endif /* _FloatParser_H__ */
     32#ifndef _FloatParser_H__#define _FloatParser_H__#include "UtilPrereqs.h"#include <string>class _UtilExport ExprParser{public:  enum binary_operator  {    b_plus,    b_minus,    mal,    durch,    modulo,    hoch,    undef,    oder,    und,    gleich,    b_nicht,    kleiner,    groesser,    ungleich,    kleinergleich,    groessergleich  };  enum unary_operator  {    u_plus,    u_minus,    u_nicht  };  ExprParser(const std::string& str);  std::string& getRemains() { return  this->remains_; }  double       getResult()  { return  this->result_; }  bool         getSuccess() { return !this->failed_; }private:  double parse_expr_1();  double parse_expr_2();  double parse_expr_3();  double parse_expr_4();  double parse_expr_5();  double parse_expr_6();  double parse_expr_7();  double parse_expr_8();  char* parse_word(char* str);  binary_operator parse_binary_operator();  unary_operator parse_unary_operator();  double parse_argument();  double parse_last_argument();  binary_operator op;  const char* reading_stream;  bool failed_;  double result_;  std::string remains_;};//Endzeichen für float expression: ')', '}', ']', ',', ';'_UtilExport bool parse_float(char* const, char**, double*);//Endzeichen angegeben_UtilExport bool parse_float(char* const, char**, char, double*);//Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen)_UtilExport bool parse_vector_float(char* const, char**, bool, double*);#endif /* _FloatParser_H__ */
  • code/branches/network/src/util/Math.cc

    • Property svn:eol-style set to native
  • code/branches/network/src/util/Math.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/MultiType.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/MultiTypeMath.cc

    • Property svn:eol-style set to native
  • code/branches/network/src/util/MultiTypeMath.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 _MultiTypeMath_H__
    31 #define _MultiTypeMath_H__
    32 
    33 #include "UtilPrereqs.h"
    34 
    35 #include "MultiTypeString.h"
    36 #include "Math.h"
    37 
    38 // 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 _MultiTypeMath_H__#define _MultiTypeMath_H__#include "UtilPrereqs.h"#include "MultiTypeString.h"#include "Math.h"// disable annoying warning about multiple assignment operators
    392#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    403#pragma warning(push)
    414#pragma warning(disable:4522)
    425#endif
    43 
    44 class _UtilExport MultiTypeMath : public MultiTypeString
    45 {
    46     public:
    47         MultiTypeMath(MultiType type = MT_null);
    48         inline MultiTypeMath(void*          value) : MultiTypeString(value) {}
    49         inline MultiTypeMath(int            value) : MultiTypeString(value) {}
    50         inline MultiTypeMath(unsigned int   value) : MultiTypeString(value) {}
    51         inline MultiTypeMath(char           value) : MultiTypeString(value) {}
    52         inline MultiTypeMath(unsigned char  value) : MultiTypeString(value) {}
    53         inline MultiTypeMath(short          value) : MultiTypeString(value) {}
    54         inline MultiTypeMath(unsigned short value) : MultiTypeString(value) {}
    55         inline MultiTypeMath(long           value) : MultiTypeString(value) {}
    56         inline MultiTypeMath(unsigned long  value) : MultiTypeString(value) {}
    57         inline MultiTypeMath(float          value) : MultiTypeString(value) {}
    58         inline MultiTypeMath(double         value) : MultiTypeString(value) {}
    59         inline MultiTypeMath(long double    value) : MultiTypeString(value) {}
    60         inline MultiTypeMath(bool           value) : MultiTypeString(value) {}
    61         inline MultiTypeMath(const char*             value) : MultiTypeString(value) {}
    62         inline MultiTypeMath(const std::string&      value) : MultiTypeString(value) {}
    63         inline MultiTypeMath(const orxonox::Vector2&     value) { this->setValue(value); }
    64         inline MultiTypeMath(const orxonox::Vector3&     value) { this->setValue(value); }
    65         inline MultiTypeMath(const orxonox::Vector4&     value) { this->setValue(value); }
    66         inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); }
    67         inline MultiTypeMath(const orxonox::Quaternion&  value) { this->setValue(value); }
    68         inline MultiTypeMath(const orxonox::Radian&      value) { this->setValue(value); }
    69         inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
    70         inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
    71         inline MultiTypeMath(const MultiTypeString& mts)        { this->setValue(mts);   }
    72         inline MultiTypeMath(const MultiTypePrimitive& mtp)     { this->setValue(mtp);   }
    73         virtual inline ~MultiTypeMath() {}
    74 
    75         using MultiTypeString::operator=;
    76         inline MultiTypeMath& operator=(const orxonox::Vector2&     value) { this->setValue(value); return *this; }
    77         inline MultiTypeMath& operator=(const orxonox::Vector3&     value) { this->setValue(value); return *this; }
    78         inline MultiTypeMath& operator=(const orxonox::Vector4&     value) { this->setValue(value); return *this; }
    79         inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; }
    80         inline MultiTypeMath& operator=(const orxonox::Quaternion&  value) { this->setValue(value); return *this; }
    81         inline MultiTypeMath& operator=(const orxonox::Radian&      value) { this->setValue(value); return *this; }
    82         inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }
    83         inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }
    84         inline MultiTypeMath& operator=(const MultiTypeString& mts)        { this->setValue(mts);   return *this; }
    85         inline MultiTypeMath& operator=(const MultiTypePrimitive mtp)      { this->setValue(mtp);   return *this; }
    86 
    87         using MultiTypeString::operator==;
    88         inline bool operator==(const orxonox::Vector2&     value) const { return (this->vector2_     == value); }
    89         inline bool operator==(const orxonox::Vector3&     value) const { return (this->vector3_     == value); }
    90         inline bool operator==(const orxonox::Vector4&     value) const { return (this->vector4_     == value); }
    91         inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); }
    92         inline bool operator==(const orxonox::Quaternion&  value) const { return (this->quaternion_  == value); }
    93         inline bool operator==(const orxonox::Radian&      value) const { return (this->radian_      == value); }
    94         inline bool operator==(const orxonox::Degree&      value) const { return (this->degree_      == value); }
    95         bool operator==(const MultiTypeMath& mtm) const;
    96         bool operator==(const MultiTypeString& mts) const;
    97         bool operator==(const MultiTypePrimitive& mtp) const;
    98 
    99         using MultiTypeString::operator!=;
    100         inline bool operator!=(const orxonox::Vector2&     value) const { return (this->vector2_     != value); }
    101         inline bool operator!=(const orxonox::Vector3&     value) const { return (this->vector3_     != value); }
    102         inline bool operator!=(const orxonox::Vector4&     value) const { return (this->vector4_     != value); }
    103         inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); }
    104         inline bool operator!=(const orxonox::Quaternion&  value) const { return (this->quaternion_  != value); }
    105         inline bool operator!=(const orxonox::Radian&      value) const { return (this->radian_      != value); }
    106         inline bool operator!=(const orxonox::Degree&      value) const { return (this->degree_      != value); }
    107         bool operator!=(const MultiTypeMath& mtm) const;
    108         bool operator!=(const MultiTypeString& mts) const;
    109         bool operator!=(const MultiTypePrimitive& mtp) const;
    110 
    111         virtual operator void*()                const;
    112         virtual operator int()                  const;
    113         virtual operator unsigned int()         const;
    114         virtual operator char()                 const;
    115         virtual operator unsigned char()        const;
    116         virtual operator short()                const;
    117         virtual operator unsigned short()       const;
    118         virtual operator long()                 const;
    119         virtual operator unsigned long()        const;
    120         virtual operator float ()               const;
    121         virtual operator double ()              const;
    122         virtual operator long double()          const;
    123         virtual operator bool()                 const;
    124         virtual operator std::string()          const;
    125         virtual operator const char*()          const;
    126         virtual operator orxonox::Vector2()     const;
    127         virtual operator orxonox::Vector3()     const;
    128         virtual operator orxonox::Vector4()     const;
    129         virtual operator orxonox::ColourValue() const;
    130         virtual operator orxonox::Quaternion()  const;
    131         virtual operator orxonox::Radian()      const;
    132         virtual operator orxonox::Degree()      const;
    133 
    134         using MultiTypeString::setValue;
    135         inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
    136         inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }
    137         inline void setValue(const orxonox::Vector4&     value) { this->type_ = MT_vector4;     this->vector4_     = value; }
    138         inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }
    139         inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }
    140         inline void setValue(const orxonox::Radian&      value) { this->type_ = MT_radian;      this->radian_      = value; }
    141         inline void setValue(const orxonox::Degree&      value) { this->type_ = MT_degree;      this->degree_      = value; }
    142         void setValue(const MultiTypeMath& mtm);
    143         void setValue(const MultiTypeString& mts);
    144         void setValue(const MultiTypePrimitive& mtp);
    145 
    146         inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }
    147         inline orxonox::Vector3     getVector3()     const { return this->vector3_;     }
    148         inline orxonox::Vector4     getVector4()     const { return this->vector4_;     }
    149         inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; }
    150         inline orxonox::Quaternion  getQuaternion()  const { return this->quaternion_;  }
    151         inline orxonox::Radian      getRadian()      const { return this->radian_;      }
    152         inline orxonox::Degree      getDegree()      const { return this->degree_;      }
    153 
    154         inline orxonox::Vector2&     getVector2()     { return this->vector2_;     }
    155         inline orxonox::Vector3&     getVector3()     { return this->vector3_;     }
    156         inline orxonox::Vector4&     getVector4()     { return this->vector4_;     }
    157         inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; }
    158         inline orxonox::Quaternion&  getQuaternion()  { return this->quaternion_;  }
    159         inline orxonox::Radian&      getRadian()      { return this->radian_;      }
    160         inline orxonox::Degree&      getDegree()      { return this->degree_;      }
    161 
    162         using MultiTypeString::getValue;
    163         inline void getValue(orxonox::Vector2*     variable) const { (*variable) = orxonox::Vector2     (this->vector2_);     }
    164         inline void getValue(orxonox::Vector3*     variable) const { (*variable) = orxonox::Vector3     (this->vector3_);     }
    165         inline void getValue(orxonox::Vector4*     variable) const { (*variable) = orxonox::Vector4     (this->vector4_);     }
    166         inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); }
    167         inline void getValue(orxonox::Quaternion*  variable) const { (*variable) = orxonox::Quaternion  (this->quaternion_);  }
    168         inline void getValue(orxonox::Radian*      variable) const { (*variable) = orxonox::Radian      (this->radian_);      }
    169         inline void getValue(orxonox::Degree*      variable) const { (*variable) = orxonox::Degree      (this->degree_);      }
    170 
    171         virtual std::string getTypename() const;
    172 
    173         virtual std::string toString() const;
    174         virtual bool fromString(const std::string value);
    175 
    176         virtual bool assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue = MultiTypeMath());
    177 
    178     protected:
    179         orxonox::Vector2      vector2_;
    180         orxonox::Vector3      vector3_;
    181         orxonox::Vector4      vector4_;
    182         orxonox::ColourValue  colourvalue_;
    183         orxonox::Quaternion   quaternion_;
    184         orxonox::Radian       radian_;
    185         orxonox::Degree       degree_;
    186 };
    187 
    188 _UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm);
    189 
    190 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     6class _UtilExport MultiTypeMath : public MultiTypeString{    public:        MultiTypeMath(MultiType type = MT_null);        inline MultiTypeMath(void*          value) : MultiTypeString(value) {}        inline MultiTypeMath(int            value) : MultiTypeString(value) {}        inline MultiTypeMath(unsigned int   value) : MultiTypeString(value) {}        inline MultiTypeMath(char           value) : MultiTypeString(value) {}        inline MultiTypeMath(unsigned char  value) : MultiTypeString(value) {}        inline MultiTypeMath(short          value) : MultiTypeString(value) {}        inline MultiTypeMath(unsigned short value) : MultiTypeString(value) {}        inline MultiTypeMath(long           value) : MultiTypeString(value) {}        inline MultiTypeMath(unsigned long  value) : MultiTypeString(value) {}        inline MultiTypeMath(float          value) : MultiTypeString(value) {}        inline MultiTypeMath(double         value) : MultiTypeString(value) {}        inline MultiTypeMath(long double    value) : MultiTypeString(value) {}        inline MultiTypeMath(bool           value) : MultiTypeString(value) {}        inline MultiTypeMath(const char*             value) : MultiTypeString(value) {}        inline MultiTypeMath(const std::string&      value) : MultiTypeString(value) {}        inline MultiTypeMath(const orxonox::Vector2&     value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::Vector3&     value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::Vector4&     value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::Quaternion&  value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::Radian&      value) { this->setValue(value); }        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }        inline MultiTypeMath(const MultiTypeString& mts)        { this->setValue(mts);   }        inline MultiTypeMath(const MultiTypePrimitive& mtp)     { this->setValue(mtp);   }        virtual inline ~MultiTypeMath() {}        using MultiTypeString::operator=;        inline MultiTypeMath& operator=(const orxonox::Vector2&     value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::Vector3&     value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::Vector4&     value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::Quaternion&  value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::Radian&      value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }        inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }        inline MultiTypeMath& operator=(const MultiTypeString& mts)        { this->setValue(mts);   return *this; }        inline MultiTypeMath& operator=(const MultiTypePrimitive mtp)      { this->setValue(mtp);   return *this; }        using MultiTypeString::operator==;        inline bool operator==(const orxonox::Vector2&     value) const { return (this->vector2_     == value); }        inline bool operator==(const orxonox::Vector3&     value) const { return (this->vector3_     == value); }        inline bool operator==(const orxonox::Vector4&     value) const { return (this->vector4_     == value); }        inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); }        inline bool operator==(const orxonox::Quaternion&  value) const { return (this->quaternion_  == value); }        inline bool operator==(const orxonox::Radian&      value) const { return (this->radian_      == value); }        inline bool operator==(const orxonox::Degree&      value) const { return (this->degree_      == value); }        bool operator==(const MultiTypeMath& mtm) const;        bool operator==(const MultiTypeString& mts) const;        bool operator==(const MultiTypePrimitive& mtp) const;        using MultiTypeString::operator!=;        inline bool operator!=(const orxonox::Vector2&     value) const { return (this->vector2_     != value); }        inline bool operator!=(const orxonox::Vector3&     value) const { return (this->vector3_     != value); }        inline bool operator!=(const orxonox::Vector4&     value) const { return (this->vector4_     != value); }        inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); }        inline bool operator!=(const orxonox::Quaternion&  value) const { return (this->quaternion_  != value); }        inline bool operator!=(const orxonox::Radian&      value) const { return (this->radian_      != value); }        inline bool operator!=(const orxonox::Degree&      value) const { return (this->degree_      != value); }        bool operator!=(const MultiTypeMath& mtm) const;        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;        virtual operator orxonox::Vector2()     const;        virtual operator orxonox::Vector3()     const;        virtual operator orxonox::Vector4()     const;        virtual operator orxonox::ColourValue() const;        virtual operator orxonox::Quaternion()  const;        virtual operator orxonox::Radian()      const;        virtual operator orxonox::Degree()      const;        using MultiTypeString::setValue;        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }        inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }        inline void setValue(const orxonox::Vector4&     value) { this->type_ = MT_vector4;     this->vector4_     = value; }        inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }        inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }        inline void setValue(const orxonox::Radian&      value) { this->type_ = MT_radian;      this->radian_      = value; }        inline void setValue(const orxonox::Degree&      value) { this->type_ = MT_degree;      this->degree_      = value; }        void setValue(const MultiTypeMath& mtm);        void setValue(const MultiTypeString& mts);        void setValue(const MultiTypePrimitive& mtp);        inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }        inline orxonox::Vector3     getVector3()     const { return this->vector3_;     }        inline orxonox::Vector4     getVector4()     const { return this->vector4_;     }        inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; }        inline orxonox::Quaternion  getQuaternion()  const { return this->quaternion_;  }        inline orxonox::Radian      getRadian()      const { return this->radian_;      }        inline orxonox::Degree      getDegree()      const { return this->degree_;      }        inline orxonox::Vector2&     getVector2()     { return this->vector2_;     }        inline orxonox::Vector3&     getVector3()     { return this->vector3_;     }        inline orxonox::Vector4&     getVector4()     { return this->vector4_;     }        inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; }        inline orxonox::Quaternion&  getQuaternion()  { return this->quaternion_;  }        inline orxonox::Radian&      getRadian()      { return this->radian_;      }        inline orxonox::Degree&      getDegree()      { return this->degree_;      }        using MultiTypeString::getValue;        inline void getValue(orxonox::Vector2*     variable) const { (*variable) = orxonox::Vector2     (this->vector2_);     }        inline void getValue(orxonox::Vector3*     variable) const { (*variable) = orxonox::Vector3     (this->vector3_);     }        inline void getValue(orxonox::Vector4*     variable) const { (*variable) = orxonox::Vector4     (this->vector4_);     }        inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); }        inline void getValue(orxonox::Quaternion*  variable) const { (*variable) = orxonox::Quaternion  (this->quaternion_);  }        inline void getValue(orxonox::Radian*      variable) const { (*variable) = orxonox::Radian      (this->radian_);      }        inline void getValue(orxonox::Degree*      variable) const { (*variable) = orxonox::Degree      (this->degree_);      }        virtual std::string getTypename() const;        virtual std::string toString() const;        virtual bool fromString(const std::string value);        virtual bool assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue = MultiTypeMath());    protected:        orxonox::Vector2      vector2_;        orxonox::Vector3      vector3_;        orxonox::Vector4      vector4_;        orxonox::ColourValue  colourvalue_;        orxonox::Quaternion   quaternion_;        orxonox::Radian       radian_;        orxonox::Degree       degree_;};_UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm);#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    1917#pragma warning(pop)
    192 #endif
    193 
    194 #endif /* _MultiTypeMath_H__ */
     8#endif#endif /* _MultiTypeMath_H__ */
  • code/branches/network/src/util/MultiTypePrimitive.cc

    • Property svn:eol-style set to native
  • code/branches/network/src/util/MultiTypePrimitive.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/MultiTypeString.cc

    • Property svn:eol-style set to native
  • 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__ */
  • code/branches/network/src/util/OrxonoxPlatform.h

    • Property svn:eol-style set to native
    r1414 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    2625 *
    2726 */
    28 
    2927/**
    3028 @file
     
    3230        copy of the file found in the Ogre source code (OgrePlatform.h).
    3331 */
    34 
    35 #ifndef _OrxonoxPlatform_H__
    36 #define _OrxonoxPlatform_H__
    37 
    38 /* Initial platform/compiler-related stuff to set.
    39 */
    40 #define ORXONOX_PLATFORM_WIN32 1
    41 #define ORXONOX_PLATFORM_LINUX 2
    42 #define ORXONOX_PLATFORM_APPLE 3
    43 
    44 #define ORXONOX_COMPILER_MSVC 1
    45 #define ORXONOX_COMPILER_GNUC 2
    46 #define ORXONOX_COMPILER_BORL 3
    47 
    48 #define ORXONOX_ENDIAN_LITTLE 1
    49 #define ORXONOX_ENDIAN_BIG 2
    50 
    51 #define ORXONOX_ARCHITECTURE_32 1
    52 #define ORXONOX_ARCHITECTURE_64 2
    53 
    54 /* Finds the compiler type and version.
    55 */
    56 #if defined( _MSC_VER )
    57 #  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC
    58 #  define ORXONOX_COMP_VER _MSC_VER
    59 
    60 #elif defined( __GNUC__ )
    61 #  define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC
    62 #  define ORXONOX_COMP_VER (((__GNUC__)*100) + \
    63         (__GNUC_MINOR__*10) + \
    64         __GNUC_PATCHLEVEL__)
    65 
    66 #elif defined( __BORLANDC__ )
    67 #  define ORXONOX_COMPILER ORXONOX_COMPILER_BORL
    68 #  define ORXONOX_COMP_VER __BCPLUSPLUS__
    69 
    70 #else
    71 #  pragma error "No known compiler. Abort! Abort!"
    72 
    73 #endif
    74 
    75 /* See if we can use __forceinline or if we need to use __inline instead */
    76 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    77 #  if ORXONOX_COMP_VER >= 1200
    78 #    define FORCEINLINE __forceinline
    79 #  endif
    80 #elif defined(__MINGW32__)
    81 #  if !defined(FORCEINLINE)
    82 #    define FORCEINLINE __inline
    83 #  endif
    84 #else
    85 #  define FORCEINLINE __inline
    86 #endif
    87 
    88 /* Finds the current platform */
    89 
    90 #if defined( __WIN32__ ) || defined( _WIN32 )
    91 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32
    92 
    93 #elif defined( __APPLE_CC__)
    94 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE
    95 
    96 #else
    97 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX
    98 #endif
    99 
    100     /* Find the arch type */
    101 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
    102 #  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64
    103 #else
    104 #  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32
    105 #endif
    106 
    107 // For generating compiler warnings - should work on any compiler
    108 // As a side note, if you start your message with 'Warning: ', the MSVC
    109 // IDE actually does catch a warning :)
    110 // FIXME: Try this on linux box. Doesn't work with msvc
    111 //#define ORXONOX_QUOTE_INPLACE(x) # x
    112 //#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x)
    113 //#define ORXONOX_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
    114 
    115 //----------------------------------------------------------------------------
    116 // Windows Settings
    117 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    118 
    119 // Win32 compilers use _DEBUG for specifying debug builds.
    120 #  ifdef _DEBUG
    121 #    define ORXONOX_DEBUG_MODE 1
    122 #  else
    123 #    define ORXONOX_DEBUG_MODE 0
    124 #  endif
    125 
    126 // Disable unicode support on MingW at the moment, poorly supported in stdlibc++
    127 // STLPORT fixes this though so allow if found
    128 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h
    129 #  if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION)
    130 #    include<_mingw.h>
    131 #    if defined(__MINGW32_TOOLBOX_UNICODE__)
    132 #      define ORXONOX_UNICODE_SUPPORT 1
    133 #    else
    134 #      define ORXONOX_UNICODE_SUPPORT 0
    135 #    endif
    136 #  else
    137 #    define ORXONOX_UNICODE_SUPPORT 1
    138 #  endif
    139 
    140 #endif /* Platform Win32 */
    141 //----------------------------------------------------------------------------
    142 
    143 //----------------------------------------------------------------------------
    144 // Linux/Apple Settings
    145 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    146 
    147 
    148 // A quick define to overcome different names for the same function
    149 #  define stricmp strcasecmp
    150 
    151 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
    152 // specifying a debug build.
    153 // (??? this is wrong, on Linux debug builds aren't marked in any way unless
    154 // you mark it yourself any way you like it -- zap ???)
    155 #  ifdef DEBUG
    156 #    define ORXONOX_DEBUG_MODE 1
    157 #  else
    158 #    define ORXONOX_DEBUG_MODE 0
    159 #  endif
    160 
    161 /* FIXME: Check what this actually is and whether we need it or not
    162 #  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    163 #    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"
    164 #  else
    165 // ORXONOX_PLATFORM_LINUX
    166 #    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
    167 #  endif
    168 */
    169 
    170 // Always enable unicode support for the moment
    171 // Perhaps disable in old versions of gcc if necessary
    172 #  define ORXONOX_UNICODE_SUPPORT 1
    173 
    174 #endif /* Patform Linux/Apple */
    175 
    176 //For apple, we always have a custom config.h file
    177 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    178 #  include "config.h"
    179 #endif
    180 
    181 //----------------------------------------------------------------------------
    182 
    183 //----------------------------------------------------------------------------
    184 // Endian Settings
    185 // check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly
    186 #ifdef ORXONOX_CONFIG_BIG_ENDIAN
    187 #  define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG
    188 #else
    189 #  define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE
    190 #endif
    191 
    192 //-----------------------------------------------------------------------
     32#ifndef _OrxonoxPlatform_H__#define _OrxonoxPlatform_H__/* Initial platform/compiler-related stuff to set.*/#define ORXONOX_PLATFORM_WIN32 1#define ORXONOX_PLATFORM_LINUX 2#define ORXONOX_PLATFORM_APPLE 3#define ORXONOX_COMPILER_MSVC 1#define ORXONOX_COMPILER_GNUC 2#define ORXONOX_COMPILER_BORL 3#define ORXONOX_ENDIAN_LITTLE 1#define ORXONOX_ENDIAN_BIG 2#define ORXONOX_ARCHITECTURE_32 1#define ORXONOX_ARCHITECTURE_64 2/* Finds the compiler type and version.*/#if defined( _MSC_VER )#  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC#  define ORXONOX_COMP_VER _MSC_VER#elif defined( __GNUC__ )#  define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC#  define ORXONOX_COMP_VER (((__GNUC__)*100) + \        (__GNUC_MINOR__*10) + \        __GNUC_PATCHLEVEL__)#elif defined( __BORLANDC__ )#  define ORXONOX_COMPILER ORXONOX_COMPILER_BORL#  define ORXONOX_COMP_VER __BCPLUSPLUS__#else#  pragma error "No known compiler. Abort! Abort!"#endif/* See if we can use __forceinline or if we need to use __inline instead */#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC#  if ORXONOX_COMP_VER >= 1200#    define FORCEINLINE __forceinline#  endif#elif defined(__MINGW32__)#  if !defined(FORCEINLINE)#    define FORCEINLINE __inline#  endif#else#  define FORCEINLINE __inline#endif/* Finds the current platform */#if defined( __WIN32__ ) || defined( _WIN32 )#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32#elif defined( __APPLE_CC__)#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE#else#  define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX#endif    /* Find the arch type */#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64#else#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32#endif// For generating compiler warnings - should work on any compiler// As a side note, if you start your message with 'Warning: ', the MSVC// IDE actually does catch a warning :)// FIXME: Try this on linux box. Doesn't work with msvc//#define ORXONOX_QUOTE_INPLACE(x) # x//#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x)//#define ORXONOX_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )//----------------------------------------------------------------------------// Windows Settings#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32// Win32 compilers use _DEBUG for specifying debug builds.#  ifdef _DEBUG#    define ORXONOX_DEBUG_MODE 1#  else#    define ORXONOX_DEBUG_MODE 0#  endif// Disable unicode support on MingW at the moment, poorly supported in stdlibc++// STLPORT fixes this though so allow if found// MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h#  if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION)#    include<_mingw.h>#    if defined(__MINGW32_TOOLBOX_UNICODE__)#      define ORXONOX_UNICODE_SUPPORT 1#    else#      define ORXONOX_UNICODE_SUPPORT 0#    endif#  else#    define ORXONOX_UNICODE_SUPPORT 1#  endif#endif /* Platform Win32 *///----------------------------------------------------------------------------//----------------------------------------------------------------------------// Linux/Apple Settings#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE// A quick define to overcome different names for the same function#  define stricmp strcasecmp// Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when// specifying a debug build.// (??? this is wrong, on Linux debug builds aren't marked in any way unless// you mark it yourself any way you like it -- zap ???)#  ifdef DEBUG#    define ORXONOX_DEBUG_MODE 1#  else#    define ORXONOX_DEBUG_MODE 0#  endif/* FIXME: Check what this actually is and whether we need it or not#  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE#    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"#  else// ORXONOX_PLATFORM_LINUX#    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"#  endif*/// Always enable unicode support for the moment// Perhaps disable in old versions of gcc if necessary#  define ORXONOX_UNICODE_SUPPORT 1#endif /* Patform Linux/Apple *///For apple, we always have a custom config.h file#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE#  include "config.h"#endif//----------------------------------------------------------------------------//----------------------------------------------------------------------------// Endian Settings// check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly#ifdef ORXONOX_CONFIG_BIG_ENDIAN#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG#else#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE#endif//-----------------------------------------------------------------------
    19333// fixed width integers
    19434//-----------------------------------------------------------------------
    195 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    196 typedef __int8            int8_t;
     35#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVCtypedef __int8            int8_t;
    19736typedef __int16           int16_t;
    19837typedef __int32           int32_t;
     
    20241typedef unsigned __int32  uint32_t;
    20342typedef unsigned __int64  uint64_t;
    204 #else
    205 # include "inttypes.h"
    206 #endif
    207 
    208 namespace orxonox {
    209 #ifdef ORXONOX_DOUBLE_PRECISION
    210 typedef double Real;
    211 #else
    212 typedef float Real;
    213 #endif
    214 }
    215 
    216 
    217 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    218 // Turn off warnings generated by long std templates
    219 // This warns about truncation to 255 characters in debug/browse info
    220 //#   pragma warning (disable : 4786)
    221 
    222 // Turn off warnings generated by long std templates
    223 // This warns about truncation to 255 characters in debug/browse info
    224 //#   pragma warning (disable : 4503)
    225 
    226 // disable: conversion from 'double' to 'float', possible loss of data
    227 // disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
    228 // This has been dealt with in base_properties of the solution since the
    229 // warning primarily occurs in library header files (which are mostly
    230 // included before OrxonoxPlatform.h is)
    231 //#   pragma warning (disable : 4244)
    232 
    233 // disable: "conversion from 'size_t' to 'unsigned int', possible loss of data
    234 //#   pragma warning (disable : 4267)
    235 
    236 // disable: "truncation from 'double' to 'float'
    237 //#   pragma warning (disable : 4305)
    238 
    239 // set to level 4: "<type> needs to have dll-interface to be used by clients'
    240 // Happens on STL member variables which are not public therefore is ok
    241 #   pragma warning (disable : 4251)
    242 
    243 // disable: 'MultiTypeString' : multiple assignment operators specified
    244 // Used in MultiType and works fine so far
    245 //#   pragma warning (disable : 4522)
    246 
    247 // disable: "non dll-interface class used as base for dll-interface class"
    248 // Happens when deriving from Singleton because bug in compiler ignores
    249 // template export
    250 //#   pragma warning (disable : 4275)
    251 
    252 // disable: "C++ Exception Specification ignored"
    253 // This is because MSVC 6 did not implement all the C++ exception
    254 // specifications in the ANSI C++ draft.
    255 //#   pragma warning( disable : 4290 )
    256 
    257 // disable: "no suitable definition provided for explicit template
    258 // instantiation request" Occurs in VC7 for no justifiable reason on all
    259 // #includes of Singleton
    260 //#   pragma warning( disable: 4661)
    261 
    262 // disable: deprecation warnings when using CRT calls in VC8
    263 // These show up on all C runtime lib code in VC8, disable since they clutter
    264 // the warnings with things we may not be able to do anything about (e.g.
    265 // generated code from nvparse etc). I doubt very much that these calls
    266 // will ever be actually removed from VC anyway, it would break too much code.
    267 //#     pragma warning( disable: 4996)
    268 
    269 // disable: "conditional expression constant", always occurs on
    270 // ORXONOX_MUTEX_CONDITIONAL when no threading enabled
    271 //#   pragma warning (disable : 201)
    272 
    273 
    274 // Define the english written operators like and, or, xor
    275 #include <iso646.h>
    276 
    277 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */
    278 
    279 // include visual leak detector to search for memory leaks
    280 //#include <vld.h>
    281 
    282 #endif /* _OrxonoxPlatform_H__ */
     43#else# include "inttypes.h"#endifnamespace orxonox {#ifdef ORXONOX_DOUBLE_PRECISIONtypedef double Real;#elsetypedef float Real;#endif}#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC// Turn off warnings generated by long std templates// This warns about truncation to 255 characters in debug/browse info//#   pragma warning (disable : 4786)// Turn off warnings generated by long std templates// This warns about truncation to 255 characters in debug/browse info//#   pragma warning (disable : 4503)// disable: conversion from 'double' to 'float', possible loss of data// disable: conversion from 'ogg_int64_t' to 'long', possible loss of data// This has been dealt with in base_properties of the solution since the// warning primarily occurs in library header files (which are mostly// included before OrxonoxPlatform.h is)//#   pragma warning (disable : 4244)// disable: "conversion from 'size_t' to 'unsigned int', possible loss of data//#   pragma warning (disable : 4267)// disable: "truncation from 'double' to 'float'//#   pragma warning (disable : 4305)// set to level 4: "<type> needs to have dll-interface to be used by clients'// Happens on STL member variables which are not public therefore is ok#   pragma warning (disable : 4251)// disable: 'MultiTypeString' : multiple assignment operators specified// Used in MultiType and works fine so far//#   pragma warning (disable : 4522)// disable: "non dll-interface class used as base for dll-interface class"// Happens when deriving from Singleton because bug in compiler ignores// template export//#   pragma warning (disable : 4275)// disable: "C++ Exception Specification ignored"// This is because MSVC 6 did not implement all the C++ exception// specifications in the ANSI C++ draft.//#   pragma warning( disable : 4290 )// disable: "no suitable definition provided for explicit template// instantiation request" Occurs in VC7 for no justifiable reason on all// #includes of Singleton//#   pragma warning( disable: 4661)// disable: deprecation warnings when using CRT calls in VC8// These show up on all C runtime lib code in VC8, disable since they clutter// the warnings with things we may not be able to do anything about (e.g.// generated code from nvparse etc). I doubt very much that these calls// will ever be actually removed from VC anyway, it would break too much code.//# pragma warning( disable: 4996)// disable: "conditional expression constant", always occurs on// ORXONOX_MUTEX_CONDITIONAL when no threading enabled//#   pragma warning (disable : 201)// Define the english written operators like and, or, xor#include <iso646.h>#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */// include visual leak detector to search for memory leaks//#include <vld.h>#endif /* _OrxonoxPlatform_H__ */
  • code/branches/network/src/util/Sleep.h

    • Property svn:eol-style set to native
    r1301 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    2625 *
    2726 */
    28 
    2927/**
    3028 @file  Sleep.h
     
    3432#include "UtilPrereqs.h"
    3533
    36 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    37 #  ifndef WIN32_LEAN_AND_MEAN
    38 #    define WIN32_LEAN_AND_MEAN
    39 #  endif
    40 #  include <windows.h>
     34#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32#  ifndef WIN32_LEAN_AND_MEAN#    define WIN32_LEAN_AND_MEAN#  endif#  include <windows.h>
    4135inline void usleep(DWORD dwMicroseconds)
    4236{
  • code/branches/network/src/util/String.cc

    • Property svn:eol-style set to native
  • code/branches/network/src/util/String.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/SubString.cc

    • Property svn:eol-style set to native
    r1349 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  *      Christian Meyer
    24  *   Co-authors:
    25  *      Benjamin Grauer
    26  *
    27 //
    28 //  splitLine
    29 //  STL string tokenizer
    30 //
    31 //  Created by Clemens Wacha.
    32 //  Version 1.0
    33 //  Copyright (c) 2005 Clemens Wacha. All rights reserved.
    34 //
    35  */
    36 
     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: *      Christian Meyer *   Co-authors: *      Benjamin Grauer *////  splitLine//  STL string tokenizer////  Created by Clemens Wacha.//  Version 1.0//  Copyright (c) 2005 Clemens Wacha. All rights reserved.// */
    372#include "SubString.h"
    383
     
    6732SubString::SubString(const std::string& string,
    6833                     const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
    69                      char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,
    70                      char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
     34                     char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,                     char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
    7135{
    7236  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
     
    8044SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    8145{
    82   for (unsigned int i = subSetBegin; i < subString.size(); i++)
    83   {
    84     this->strings.push_back(subString[i]);
    85     this->bInSafemode.push_back(subString.isInSafemode(i));
    86   }
     46  for (unsigned int i = subSetBegin; i < subString.size(); i++)  {
     47    this->strings.push_back(subString[i]);    this->bInSafemode.push_back(subString.isInSafemode(i));  }
    8748}
    8849
     
    9657SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd)
    9758{
    98   for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++)
    99   {
    100     this->strings.push_back(subString[i]);
    101     this->bInSafemode.push_back(subString.isInSafemode(i));
    102   }
     59  for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++)  {
     60    this->strings.push_back(subString[i]);    this->bInSafemode.push_back(subString.isInSafemode(i));  }
    10361}
    10462
     
    11068SubString::SubString(unsigned int argc, const char** argv)
    11169{
    112   for(unsigned int i = 0; i < argc; ++i)
    113   {
    114     this->strings.push_back(std::string(argv[i]));
    115     this->bInSafemode.push_back(false);
    116   }
     70  for(unsigned int i = 0; i < argc; ++i)  {
     71    this->strings.push_back(std::string(argv[i]));    this->bInSafemode.push_back(false);  }
    11772}
    11873
     
    13994SubString& SubString::operator=(const SubString& subString)
    14095{
    141   this->strings = subString.strings;
    142   this->bInSafemode = subString.bInSafemode;
     96  this->strings = subString.strings;  this->bInSafemode = subString.bInSafemode;
    14397  return *this;
    14498}
     
    201155SubString& SubString::operator+=(const SubString& subString)
    202156{
    203   for (unsigned int i = 0; i < subString.size(); i++)
    204   {
    205     this->strings.push_back(subString[i]);
    206     this->bInSafemode.push_back(subString.isInSafemode(i));
    207   }
     157  for (unsigned int i = 0; i < subString.size(); i++)  {
     158    this->strings.push_back(subString[i]);    this->bInSafemode.push_back(subString.isInSafemode(i));  }
    208159  return *this;
    209160}
     
    217168unsigned int SubString::split(const std::string& string, char splitter)
    218169{
    219   this->strings.clear();
    220   this->bInSafemode.clear();
     170  this->strings.clear();  this->bInSafemode.clear();
    221171  char split[2];
    222172  split[0] = splitter;
     
    239189unsigned int SubString::split(const std::string& string,
    240190                              const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
    241                               char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,
    242                               char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
    243 {
    244   this->strings.clear();
    245   this->bInSafemode.clear();
     191                              char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,                              char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
     192{
     193  this->strings.clear();  this->bInSafemode.clear();
    246194  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
    247195  return this->strings.size();
     
    309257 * @param emptyEntries: if empty Strings are added to the List of Strings.
    310258 * @param escape_char: Escape carater (escapes splitters)
    311  * @param safemode_char: the beginning of the safemode is marked with this
    312  * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token
    313  * @param openparenthesis_char the beginning of a safemode is marked with this
    314  * @param closeparenthesis_char the ending of a safemode is marked with this
    315  * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token
     259 * @param safemode_char: the beginning of the safemode is marked with this * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token * @param openparenthesis_char the beginning of a safemode is marked with this * @param closeparenthesis_char the ending of a safemode is marked with this * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token
    316260 * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line)
    317261 * @param start_state: the Initial state on how to parse the String.
     
    323267 */
    324268SubString::SPLIT_LINE_STATE
    325 SubString::splitLine(std::vector<std::string>& ret,
    326                      std::vector<bool>& bInSafemode,
     269SubString::splitLine(std::vector<std::string>& ret,                     std::vector<bool>& bInSafemode,
    327270                     const std::string& line,
    328271                     const std::string& delimiters,
    329272                     const std::string& delimiterNeighbours,
    330273                     bool emptyEntries,
    331                      char escape_char,
    332                      bool removeExcapeChar,
    333                      char safemode_char,
    334                      bool removeSafemodeChar,
    335                      char openparenthesis_char,
    336                      char closeparenthesis_char,
    337                      bool removeParenthesisChars,
     274                     char escape_char,                     bool removeExcapeChar,
     275                     char safemode_char,                     bool removeSafemodeChar,                     char openparenthesis_char,                     char closeparenthesis_char,                     bool removeParenthesisChars,
    338276                     char comment_char,
    339277                     SPLIT_LINE_STATE start_state)
     
    343281  unsigned int fallBackNeighbours = 0;
    344282
    345   std::string token;
    346   bool inSafemode = false;
    347 
    348   if(start_state != SL_NORMAL && ret.size() > 0)
    349   {
    350     token = ret[ret.size()-1];
    351     ret.pop_back();
    352   }
    353   if(start_state != SL_NORMAL && bInSafemode.size() > 0)
    354   {
    355     inSafemode = bInSafemode[bInSafemode.size()-1];
    356     bInSafemode.pop_back();
    357   }
    358 
     283  std::string token;  bool inSafemode = false;
     284
     285  if(start_state != SL_NORMAL && ret.size() > 0)  {    token = ret[ret.size()-1];
     286    ret.pop_back();  }  if(start_state != SL_NORMAL && bInSafemode.size() > 0)  {    inSafemode = bInSafemode[bInSafemode.size()-1];    bInSafemode.pop_back();  }
    359287  while(i < line.size())
    360288  {
     
    364292        if(line[i] == escape_char)
    365293        {
    366           state = SL_ESCAPE;
    367           if (!removeExcapeChar)
    368             token += line[i];
     294          state = SL_ESCAPE;          if (!removeExcapeChar)            token += line[i];
    369295        }
    370296        else if(line[i] == safemode_char)
    371297        {
    372           state = SL_SAFEMODE;
    373           inSafemode = true;
    374           if (!removeSafemodeChar)
    375             token += line[i];
    376         }
    377         else if(line[i] == openparenthesis_char)
    378         {
    379           state = SL_PARENTHESES;
    380           inSafemode = true;
    381           if (!removeParenthesisChars)
    382             token += line[i];
    383         }
     298          state = SL_SAFEMODE;          inSafemode = true;          if (!removeSafemodeChar)            token += line[i];
     299        }        else if(line[i] == openparenthesis_char)        {          state = SL_PARENTHESES;          inSafemode = true;          if (!removeParenthesisChars)            token += line[i];        }
    384300        else if(line[i] == comment_char)
    385301        {
     
    389305          if(emptyEntries || token.size() > 0)
    390306          {
    391             ret.push_back(token);
    392             token.clear();
    393             bInSafemode.push_back(inSafemode);
    394             inSafemode = false;
    395           }
     307            ret.push_back(token);            token.clear();            bInSafemode.push_back(inSafemode);            inSafemode = false;          }
    396308          token += line[i];       // EAT
    397309          state = SL_COMMENT;
     
    407319            ret.push_back(token);
    408320            token.clear();
    409             bInSafemode.push_back(inSafemode);
    410             inSafemode = false;
    411           }
     321            bInSafemode.push_back(inSafemode);            inSafemode = false;          }
    412322          state = SL_NORMAL;
    413323        }
     
    429339        }
    430340        break;
    431       case SL_ESCAPE:
    432         if (!removeSafemodeChar)
    433           token += line[i];
    434         else
    435         {
     341      case SL_ESCAPE:        if (!removeSafemodeChar)          token += line[i];        else        {
    436342          if(line[i] == 'n') token += '\n';
    437343          else if(line[i] == 't') token += '\t';
     
    442348          else if(line[i] == 'a') token += '\a';
    443349          else if(line[i] == '?') token += '\?';
    444           else token += line[i];  // EAT
    445         }
     350          else token += line[i];  // EAT        }
    446351        state = SL_NORMAL;
    447352        break;
     
    450355        {
    451356          state = SL_NORMAL;
    452           if (!removeSafemodeChar)
    453             token += line[i];
    454         }
     357          if (!removeSafemodeChar)            token += line[i];        }
    455358        else if(line[i] == escape_char)
    456359        {
     
    461364          token += line[i];       // EAT
    462365        }
    463         break;
    464 
    465       case SL_SAFEESCAPE:
     366        break;      case SL_SAFEESCAPE:
    466367        if(line[i] == 'n') token += '\n';
    467368        else if(line[i] == 't') token += '\t';
     
    475376        state = SL_SAFEMODE;
    476377        break;
    477 
    478       case SL_PARENTHESES:
    479         if(line[i] == closeparenthesis_char)
    480         {
    481           state = SL_NORMAL;
    482           if (!removeParenthesisChars)
    483             token += line[i];
    484         }
    485         else if(line[i] == escape_char)
    486         {
    487           state = SL_PARENTHESESESCAPE;
    488         }
    489         else
    490         {
    491           token += line[i];       // EAT
    492         }
    493         break;
    494 
    495       case SL_PARENTHESESESCAPE:
    496         if(line[i] == 'n') token += '\n';
    497         else if(line[i] == 't') token += '\t';
    498         else if(line[i] == 'v') token += '\v';
    499         else if(line[i] == 'b') token += '\b';
    500         else if(line[i] == 'r') token += '\r';
    501         else if(line[i] == 'f') token += '\f';
    502         else if(line[i] == 'a') token += '\a';
    503         else if(line[i] == '?') token += '\?';
    504         else token += line[i];  // EAT
    505         state = SL_PARENTHESES;
    506         break;
    507 
     378      case SL_PARENTHESES:        if(line[i] == closeparenthesis_char)        {          state = SL_NORMAL;          if (!removeParenthesisChars)            token += line[i];        }        else if(line[i] == escape_char)        {          state = SL_PARENTHESESESCAPE;        }        else        {          token += line[i];       // EAT        }        break;      case SL_PARENTHESESESCAPE:        if(line[i] == 'n') token += '\n';        else if(line[i] == 't') token += '\t';        else if(line[i] == 'v') token += '\v';        else if(line[i] == 'b') token += '\b';        else if(line[i] == 'r') token += '\r';        else if(line[i] == 'f') token += '\f';        else if(line[i] == 'a') token += '\a';        else if(line[i] == '?') token += '\?';        else token += line[i];  // EAT        state = SL_PARENTHESES;        break;
    508379      case SL_COMMENT:
    509380        if(line[i] == '\n')
     
    514385            ret.push_back(token);
    515386            token.clear();
    516             bInSafemode.push_back(inSafemode);
    517             inSafemode = false;
    518           }
     387            bInSafemode.push_back(inSafemode);            inSafemode = false;          }
    519388          state = SL_NORMAL;
    520389        }
     
    539408    ret.push_back(token);
    540409    token.clear();
    541     bInSafemode.push_back(inSafemode);
    542     inSafemode = false;
    543   }
     410    bInSafemode.push_back(inSafemode);    inSafemode = false;  }
    544411  return(state);
    545412}
  • code/branches/network/src/util/SubString.h

    • Property svn:eol-style set to native
    r1349 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  *      Christian Meyer
    24  *   Co-authors:
    25  *      Benjamin Grauer
    26  *      Fabian 'x3n' Landau
    27  *
    28 
    29 //  splitLine
    30 //  STL string tokenizer
    31 //
    32 //  Created by Clemens Wacha.
    33 //  Version 1.0
    34 //  Copyright (c) 2005 Clemens Wacha. All rights reserved.
    35 
    36  * Extended by Fabian 'x3n' Landau with the SL_PARENTHESES mode.
    37  */
    38 
    39  /*!
     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: *      Christian Meyer *   Co-authors: *      Benjamin Grauer *      Fabian 'x3n' Landau *//  splitLine//  STL string tokenizer////  Created by Clemens Wacha.//  Version 1.0//  Copyright (c) 2005 Clemens Wacha. All rights reserved. * Extended by Fabian 'x3n' Landau with the SL_PARENTHESES mode. */ /*!
    402 * @file substring.h
    413 * @brief a small class to get the parts of a string separated by commas
     
    6022
    6123#include "UtilPrereqs.h"
    62 
    6324#include <vector>
    6425#include <string>
     
    7839    SL_SAFEMODE,          //!< In safe mode (between "" mostly).
    7940    SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
    80     SL_COMMENT,           //!< In Comment mode.
    81     SL_PARENTHESES,       //!< Between parentheses (usually '(' and ')')
    82     SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
     41    SL_COMMENT,           //!< In Comment mode.    SL_PARENTHESES,       //!< Between parentheses (usually '(' and ')')    SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
    8342  } SPLIT_LINE_STATE;
    8443
     
    8948  SubString(const std::string& string,
    9049            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
    91             char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
    92             char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
     50            char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,            char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
    9351  SubString(unsigned int argc, const char** argv);
    9452  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
     
    11371  unsigned int split(const std::string& string,
    11472                     const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false,
    115                      char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
    116                      char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
     73                     char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,                     char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
    11774  std::string join(const std::string& delimiter = " ") const;
    11875  ////////////////////////////////////////
     
    13087  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
    13188  /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
    132   inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
    133   /** @brief Returns true if the token is in safemode. @param i the i'th token */
    134   inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
     89  inline const std::string& getString(unsigned int i) const { return (*this)[i]; };  /** @brief Returns true if the token is in safemode. @param i the i'th token */  inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
    13590  /** @brief Returns the front of the StringList. */
    13691  inline const std::string& front() const { return this->strings.front(); };
     
    14196
    14297  // the almighty algorithm.
    143   static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
    144                                     std::vector<bool>& bInSafemode,
     98  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,                                    std::vector<bool>& bInSafemode,
    14599                                    const std::string& line,
    146100                                    const std::string& delimiters = SubString::WhiteSpaces,
    147101                                    const std::string& delimiterNeighbours = "",
    148102                                    bool emptyEntries = false,
    149                                     char escape_char = '\\',
    150                                     bool removeExcapeChar = true,
     103                                    char escape_char = '\\',                                    bool removeExcapeChar = true,
    151104                                    char safemode_char = '"',
    152                                     bool removeSafemodeChar = true,
    153                                     char openparenthesis_char = '(',
    154                                     char closeparenthesis_char = ')',
    155                                     bool removeParenthesisChars = true,
    156                                     char comment_char = '\0',
     105                                    bool removeSafemodeChar = true,                                    char openparenthesis_char = '(',                                    char closeparenthesis_char = ')',                                    bool removeParenthesisChars = true,                                    char comment_char = '\0',
    157106                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
    158107  // debugging.
     
    165114
    166115private:
    167   std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    168   std::vector<bool>         bInSafemode;
     116  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings  std::vector<bool>         bInSafemode;
    169117};
    170118
  • code/branches/network/src/util/UtilPrereqs.h

    • Property svn:eol-style set to native
    r1414 r1494  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
     3 *                    > www.orxonox.net < *
    54 *
    65 *   License notice:
     
    3130  @brief Contains all the necessary forward declarations for all classes and structs.
    3231*/
    33 
    3432#ifndef _UtilPrereqs_H__
    3533#define _UtilPrereqs_H__
     
    6058// Forward declarations
    6159//-----------------------------------------------------------------------
    62 class ArgReader;
    63 class Convert;
    64 class MultiTypePrimitive;
    65 class MultiTypeString;
    66 class MultiTypeMath;
    67 template <class T>
    68 class String2Number;
    69 class SubString;
     60class ArgReader;class Convert;class MultiTypePrimitive;class MultiTypeString;class MultiTypeMath;template <class T>class String2Number;class SubString;
    7061
    7162#endif /* _UtilPrereqs_H__ */
  • code/branches/network/src/util/XMLIncludes.h

    • Property svn:eol-style set to native
  • code/branches/network/src/util/testing/CMakeLists.txt

    • Property svn:eol-style set to native
  • code/branches/network/src/util/testing/TestConverter.cpp

    • Property svn:eol-style set to native
Note: See TracChangeset for help on using the changeset viewer.