Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 724


Ignore:
Timestamp:
Dec 29, 2007, 9:39:55 PM (16 years ago)
Author:
landauf
Message:

reference → pointer (for better readability)

Location:
code/branches/FICN/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/misc/Convert.h

    r722 r724  
    5353    */
    5454    template <typename T>
    55     static bool ToString(std::string& output, T input)
     55    static bool ToString(std::string* output, T input)
    5656    {
    5757        std::ostringstream oss;
    5858        if (oss << input)
    5959        {
    60             output = oss.str();
     60            (*output) = oss.str();
    6161            return true;
    6262        }
     
    7878    */
    7979    template <typename T>
    80     static bool ToString(std::string& output, T input, const std::string& fallbackString)
     80    static bool ToString(std::string* output, T input, const std::string& fallbackString)
    8181    {
    8282        if (Convert::ToString(output, input))
    8383            return true;
    8484
    85         output = fallbackString;
     85        (*output) = fallbackString;
    8686        return false;
    8787    }
     
    9999    */
    100100    template <typename T>
    101     static bool FromString(T& output, const std::string& input)
     101    static bool FromString(T* output, const std::string& input)
    102102    {
    103103        std::istringstream iss(input);
    104         if (iss >> output)
     104        if (iss >> (*output))
    105105            return true;
    106106
     
    121121    */
    122122    template <typename T>
    123     static bool FromString(T& output, const std::string& input, T fallbackValue)
     123    static bool FromString(T* output, const std::string& input, T fallbackValue)
    124124    {
    125125        if (Convert::FromString(output, input))
    126126            return true;
    127127
    128         output = fallbackValue;
     128        (*output) = fallbackValue;
    129129        return false;
    130130    }
  • code/branches/FICN/src/orxonox/core/ConfigValueContainer.cc

    r721 r724  
    5050        this->type_ = VT_Int;
    5151
    52         Convert::ToString(this->defvalueString_, defvalue, "0");                    // Try to convert the default-value to a string
     52        Convert::ToString(&this->defvalueString_, defvalue, "0");                   // Try to convert the default-value to a string
    5353        this->searchConfigFileLine();                                               // Search the entry in the config-file
    5454
     
    7272        this->type_ = VT_uInt;
    7373
    74         Convert::ToString(this->defvalueString_, defvalue, "0");                    // Try to convert the default-value to a string
     74        Convert::ToString(&this->defvalueString_, defvalue, "0");                   // Try to convert the default-value to a string
    7575        this->searchConfigFileLine();                                               // Search the entry in the config-file
    7676
     
    9494        this->type_ = VT_Char;
    9595
    96         Convert::ToString(this->defvalueString_, (int)defvalue, "0");               // Try to convert the default-value to a string
     96        Convert::ToString(&this->defvalueString_, (int)defvalue, "0");              // Try to convert the default-value to a string
    9797        this->searchConfigFileLine();                                               // Search the entry in the config-file
    9898
     
    116116        this->type_ = VT_uChar;
    117117
    118         Convert::ToString(this->defvalueString_, (unsigned int)defvalue, "0");      // Try to convert the default-value to a string
     118        Convert::ToString(&this->defvalueString_, (unsigned int)defvalue, "0");     // Try to convert the default-value to a string
    119119        this->searchConfigFileLine();                                               // Search the entry in the config-file
    120120
     
    138138        this->type_ = VT_Float;
    139139
    140         Convert::ToString(this->defvalueString_, defvalue, "0.000000");             // Try to convert the default-value to a string
     140        Convert::ToString(&this->defvalueString_, defvalue, "0.000000");            // Try to convert the default-value to a string
    141141        this->searchConfigFileLine();                                               // Search the entry in the config-file
    142142
     
    160160        this->type_ = VT_Double;
    161161
    162         Convert::ToString(this->defvalueString_, defvalue, "0.000000");             // Try to convert the default-value to a string
     162        Convert::ToString(&this->defvalueString_, defvalue, "0.000000");            // Try to convert the default-value to a string
    163163        this->searchConfigFileLine();                                               // Search the entry in the config-file
    164164
     
    182182        this->type_ = VT_LongDouble;
    183183
    184         Convert::ToString(this->defvalueString_, defvalue, "0.000000");             // Try to convert the default-value to a string
     184        Convert::ToString(&this->defvalueString_, defvalue, "0.000000");            // Try to convert the default-value to a string
    185185        this->searchConfigFileLine();                                               // Search the entry in the config-file
    186186
     
    384384    bool ConfigValueContainer::parseSting(const std::string& input, int defvalue)
    385385    {
    386         return Convert::FromString(this->value_.value_int_, input, defvalue);
     386        return Convert::FromString(&this->value_.value_int_, input, defvalue);
    387387    }
    388388
     
    395395    bool ConfigValueContainer::parseSting(const std::string& input, unsigned int defvalue)
    396396    {
    397         return Convert::FromString(this->value_.value_uint_, input, defvalue);
     397        return Convert::FromString(&this->value_.value_uint_, input, defvalue);
    398398    }
    399399
     
    407407    {
    408408        // I used value_int_ instead of value_char_ to avoid number <-> char confusion in the config-file
    409         return Convert::FromString(this->value_.value_int_, input, (int)defvalue);
     409        return Convert::FromString(&this->value_.value_int_, input, (int)defvalue);
    410410    }
    411411
     
    419419    {
    420420        // I used value_uint_ instead of value_uchar_ to avoid number <-> char confusion in the config-file
    421         return Convert::FromString(this->value_.value_uint_, input, (unsigned int)defvalue);
     421        return Convert::FromString(&this->value_.value_uint_, input, (unsigned int)defvalue);
    422422    }
    423423
     
    430430    bool ConfigValueContainer::parseSting(const std::string& input, float defvalue)
    431431    {
    432         return Convert::FromString(this->value_.value_float_, input, defvalue);
     432        return Convert::FromString(&this->value_.value_float_, input, defvalue);
    433433    }
    434434
     
    441441    bool ConfigValueContainer::parseSting(const std::string& input, double defvalue)
    442442    {
    443         return Convert::FromString(this->value_.value_double_, input, defvalue);
     443        return Convert::FromString(&this->value_.value_double_, input, defvalue);
    444444    }
    445445
     
    452452    bool ConfigValueContainer::parseSting(const std::string& input, long double defvalue)
    453453    {
    454         return Convert::FromString(this->value_.value_long_double_, input, defvalue);
     454        return Convert::FromString(&this->value_.value_long_double_, input, defvalue);
    455455    }
    456456
     
    477477        {
    478478            // Its not a known word - is it a number?
    479             return Convert::FromString(this->value_.value_bool_, input, defvalue);
     479            return Convert::FromString(&this->value_.value_bool_, input, defvalue);
    480480        }
    481481
     
    549549        {
    550550            std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");
    551             if (!Convert::FromString(this->value_vector2_.x, tokens[0], defvalue.x))
     551            if (!Convert::FromString(&this->value_vector2_.x, tokens[0], defvalue.x))
    552552            {
    553553                this->value_vector2_ = defvalue;
    554554                return false;
    555555            }
    556             if (!Convert::FromString(this->value_vector2_.y, tokens[1], defvalue.y))
     556            if (!Convert::FromString(&this->value_vector2_.y, tokens[1], defvalue.y))
    557557            {
    558558                this->value_vector2_ = defvalue;
     
    583583        {
    584584            std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");
    585             if (!Convert::FromString(this->value_vector3_.x, tokens[0], defvalue.x))
     585            if (!Convert::FromString(&this->value_vector3_.x, tokens[0], defvalue.x))
    586586            {
    587587                this->value_vector3_ = defvalue;
    588588                return false;
    589589            }
    590             if (!Convert::FromString(this->value_vector3_.y, tokens[1], defvalue.y))
     590            if (!Convert::FromString(&this->value_vector3_.y, tokens[1], defvalue.y))
    591591            {
    592592                this->value_vector3_ = defvalue;
    593593                return false;
    594594            }
    595             if (!Convert::FromString(this->value_vector3_.z, tokens[2], defvalue.z))
     595            if (!Convert::FromString(&this->value_vector3_.z, tokens[2], defvalue.z))
    596596            {
    597597                this->value_vector3_ = defvalue;
     
    622622        {
    623623            std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");
    624             if (!Convert::FromString(this->value_colourvalue_.r, tokens[0], defvalue.r))
     624            if (!Convert::FromString(&this->value_colourvalue_.r, tokens[0], defvalue.r))
    625625            {
    626626                this->value_colourvalue_ = defvalue;
    627627                return false;
    628628            }
    629             if (!Convert::FromString(this->value_colourvalue_.g, tokens[1], defvalue.g))
     629            if (!Convert::FromString(&this->value_colourvalue_.g, tokens[1], defvalue.g))
    630630            {
    631631                this->value_colourvalue_ = defvalue;
    632632                return false;
    633633            }
    634             if (!Convert::FromString(this->value_colourvalue_.b, tokens[2], defvalue.b))
     634            if (!Convert::FromString(&this->value_colourvalue_.b, tokens[2], defvalue.b))
    635635            {
    636636                this->value_colourvalue_ = defvalue;
    637637                return false;
    638638            }
    639             if (!Convert::FromString(this->value_colourvalue_.a, tokens[3], defvalue.a))
     639            if (!Convert::FromString(&this->value_colourvalue_.a, tokens[3], defvalue.a))
    640640            {
    641641                this->value_colourvalue_ = defvalue;
Note: See TracChangeset for help on using the changeset viewer.