Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 11, 2008, 3:29:16 AM (16 years ago)
Author:
landauf
Message:

config-values are working again, now with a totally reworked ConfigValueContainer using MultiTypes (this commit is just a bugfix, the major work was done before, see r792)

added << operator to std::ostream for all MultiTypes

Location:
code/branches/core/src/orxonox/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/orxonox/core/ConfigValueContainer.cc

    r794 r797  
    5252        this->searchConfigFileLine();                                               // Search the entry in the config-file
    5353
    54         std::string valueString = this->parseValueString();                         // Parses the value string from the config-file-entry
     54        std::string valueString = this->parseValueString(!(defvalue.isA(MT_string) || defvalue.isA(MT_constchar)));     // Parses the value string from the config-file-entry
    5555        if (!this->parseString(valueString, defvalue))                              // Try to convert the string to a value
    5656            this->resetConfigFileEntry();                                           // The conversion failed
     
    6565    bool ConfigValueContainer::valueToString(std::string* output, MultiTypeMath& input)
    6666    {
    67         if (this->value_.getType() == MT_int)
     67        if (input.getType() == MT_int)
    6868            return ConvertValue(output, input.getInt(), std::string("0"));
    69         else if (this->value_.getType() == MT_uint)
     69        else if (input.getType() == MT_uint)
    7070            return ConvertValue(output, input.getUnsignedInt(), std::string("0"));
    71         else if (this->value_.getType() == MT_char)
    72             return ConvertValue(output, input.getChar(), std::string("0"));
    73         else if (this->value_.getType() == MT_uchar)
    74             return ConvertValue(output, input.getUnsignedChar(), std::string("0"));
    75         else if (this->value_.getType() == MT_short)
     71        else if (input.getType() == MT_char)
     72            return ConvertValue(output, (int)input.getChar(), std::string("0"));
     73        else if (input.getType() == MT_uchar)
     74            return ConvertValue(output, (unsigned int)input.getUnsignedChar(), std::string("0"));
     75        else if (input.getType() == MT_short)
    7676            return ConvertValue(output, input.getShort(), std::string("0"));
    77         else if (this->value_.getType() == MT_ushort)
     77        else if (input.getType() == MT_ushort)
    7878            return ConvertValue(output, input.getUnsignedShort(), std::string("0"));
    79         else if (this->value_.getType() == MT_long)
     79        else if (input.getType() == MT_long)
    8080            return ConvertValue(output, input.getLong(), std::string("0"));
    81         else if (this->value_.getType() == MT_ulong)
     81        else if (input.getType() == MT_ulong)
    8282            return ConvertValue(output, input.getUnsignedLong(), std::string("0"));
    83         else if (this->value_.getType() == MT_float)
     83        else if (input.getType() == MT_float)
    8484            return ConvertValue(output, input.getFloat(), std::string("0.000000"));
    85         else if (this->value_.getType() == MT_double)
     85        else if (input.getType() == MT_double)
    8686            return ConvertValue(output, input.getDouble(), std::string("0.000000"));
    87         else if (this->value_.getType() == MT_longdouble)
     87        else if (input.getType() == MT_longdouble)
    8888            return ConvertValue(output, input.getChar(), std::string("0.000000"));
    89         else if (this->value_.getType() == MT_bool)
     89        else if (input.getType() == MT_bool)
    9090        {
    9191            if (input.getBool())
     
    9696            return true;
    9797        }
    98         else if (this->value_.getType() == MT_constchar)
     98        else if (input.getType() == MT_constchar)
    9999        {
    100100            (*output) = "\"" + input.getString() + "\"";
    101101            return true;
    102102        }
    103         else if (this->value_.getType() == MT_string)
     103        else if (input.getType() == MT_string)
    104104        {
    105105            (*output) = "\"" + input.getString() + "\"";
    106106            return true;
    107107        }
    108         else if (this->value_.getType() == MT_vector2)
     108        else if (input.getType() == MT_vector2)
    109109        {
    110110            std::ostringstream ostream;
     
    120120            }
    121121        }
    122         else if (this->value_.getType() == MT_vector3)
     122        else if (input.getType() == MT_vector3)
    123123        {
    124124            std::ostringstream ostream;
     
    134134            }
    135135        }
    136         else if (this->value_.getType() == MT_colourvalue)
     136        else if (input.getType() == MT_colourvalue)
    137137        {
    138138            std::ostringstream ostream;
     
    148148            }
    149149        }
    150         else if (this->value_.getType() == MT_quaternion)
     150        else if (input.getType() == MT_quaternion)
    151151        {
    152152            std::ostringstream ostream;
     
    162162            }
    163163        }
    164         else if (this->value_.getType() == MT_radian)
     164        else if (input.getType() == MT_radian)
    165165            return ConvertValue(output, input.getRadian(), std::string("0.000000"));
    166         else if (this->value_.getType() == MT_degree)
     166        else if (input.getType() == MT_degree)
    167167            return ConvertValue(output, input.getDegree(), std::string("0.000000"));
    168168
     
    177177    bool ConfigValueContainer::parseString(const std::string& input, MultiTypeMath& defvalue)
    178178    {
    179         if (this->value_.getType() == MT_int)
     179        if (defvalue.getType() == MT_int)
    180180            return this->parseString(input, defvalue.getInt());
    181         else if (this->value_.getType() == MT_uint)
     181        else if (defvalue.getType() == MT_uint)
    182182            return this->parseString(input, defvalue.getUnsignedInt());
    183         else if (this->value_.getType() == MT_char)
     183        else if (defvalue.getType() == MT_char)
    184184            return this->parseString(input, defvalue.getChar());
    185         else if (this->value_.getType() == MT_uchar)
     185        else if (defvalue.getType() == MT_uchar)
    186186            return this->parseString(input, defvalue.getUnsignedChar());
    187         else if (this->value_.getType() == MT_short)
     187        else if (defvalue.getType() == MT_short)
    188188            return this->parseString(input, defvalue.getShort());
    189         else if (this->value_.getType() == MT_ushort)
     189        else if (defvalue.getType() == MT_ushort)
    190190            return this->parseString(input, defvalue.getUnsignedShort());
    191         else if (this->value_.getType() == MT_long)
     191        else if (defvalue.getType() == MT_long)
    192192            return this->parseString(input, defvalue.getLong());
    193         else if (this->value_.getType() == MT_ulong)
     193        else if (defvalue.getType() == MT_ulong)
    194194            return this->parseString(input, defvalue.getUnsignedLong());
    195         else if (this->value_.getType() == MT_float)
     195        else if (defvalue.getType() == MT_float)
    196196            return this->parseString(input, defvalue.getFloat());
    197         else if (this->value_.getType() == MT_double)
     197        else if (defvalue.getType() == MT_double)
    198198            return this->parseString(input, defvalue.getDouble());
    199         else if (this->value_.getType() == MT_longdouble)
     199        else if (defvalue.getType() == MT_longdouble)
    200200            return this->parseString(input, defvalue.getLongDouble());
    201         else if (this->value_.getType() == MT_bool)
     201        else if (defvalue.getType() == MT_bool)
    202202            return this->parseString(input, defvalue.getBool());
    203         else if (this->value_.getType() == MT_constchar)
     203        else if (defvalue.getType() == MT_constchar)
    204204            return this->parseString(input, defvalue.getString());
    205         else if (this->value_.getType() == MT_string)
     205        else if (defvalue.getType() == MT_string)
    206206            return this->parseString(input, defvalue.getString());
    207         else if (this->value_.getType() == MT_vector2)
     207        else if (defvalue.getType() == MT_vector2)
    208208            return this->parseString(input, defvalue.getVector2());
    209         else if (this->value_.getType() == MT_vector3)
     209        else if (defvalue.getType() == MT_vector3)
    210210            return this->parseString(input, defvalue.getVector3());
    211         else if (this->value_.getType() == MT_colourvalue)
     211        else if (defvalue.getType() == MT_colourvalue)
    212212            return this->parseString(input, defvalue.getColourValue());
    213         else if (this->value_.getType() == MT_quaternion)
     213        else if (defvalue.getType() == MT_quaternion)
    214214            return this->parseString(input, defvalue.getQuaternion());
    215         else if (this->value_.getType() == MT_radian)
     215        else if (defvalue.getType() == MT_radian)
    216216            return this->parseString(input, defvalue.getRadian());
    217         else if (this->value_.getType() == MT_degree)
     217        else if (defvalue.getType() == MT_degree)
    218218            return this->parseString(input, defvalue.getDegree());
    219219
  • code/branches/core/src/orxonox/core/ConfigValueContainer.h

    r796 r797  
    9292            inline ConfigValueContainer& getValue(bool* value)           { this->value_.getValue(value); return *this; }
    9393            inline ConfigValueContainer& getValue(std::string* value)    { this->value_.getValue(value); return *this; }
     94            inline ConfigValueContainer& getValue(const char** value)    { this->value_.getValue(value); return *this; }
    9495            inline ConfigValueContainer& getValue(Vector2* value)        { this->value_.getValue(value); return *this; }
    9596            inline ConfigValueContainer& getValue(Vector3* value)        { this->value_.getValue(value); return *this; }
Note: See TracChangeset for help on using the changeset viewer.