Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 4:39:06 PM (17 years ago)
Author:
landauf
Message:

changed ConfigValueContainer to use ConfigFileManager, but there is still an error

Location:
code/branches/core2/src/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/util/MultiTypeMath.cc

    r1003 r1020  
    169169        ConvertValue(&output, this->vector3_);
    170170    else if (this->type_ == MT_colourvalue)
    171     { std::cout << "3_1\n";
    172         ConvertValue(&output, this->colourvalue_);}
     171        ConvertValue(&output, this->colourvalue_);
    173172    else if (this->type_ == MT_quaternion)
    174173        ConvertValue(&output, this->quaternion_);
     
    190189        return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0));
    191190    else if (this->type_ == MT_colourvalue)
    192     { std::cout << "4_1\n";
    193         return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0)); }
     191        return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0));
    194192    else if (this->type_ == MT_quaternion)
    195193        return ConvertValue(&this->quaternion_, value, orxonox::Quaternion(1, 0, 0, 0));
  • code/branches/core2/src/util/String.cc

    r1006 r1020  
    6262std::string removeTrailingWhitespaces(const std::string& str)
    6363{
     64    unsigned int pos1 = 0;
     65    unsigned int pos2 = str.size() - 1;
     66    for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
     67    for (; pos2 >= 0         && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
     68    return str.substr(pos1, pos2 - pos1 + 1);
     69}
     70
     71/**
     72    @brief Returns the position of the next quote in the string, starting with start.
     73    @param str The string
     74    @param start The startposition
     75    @return The position of the next quote (std::string::npos if there is no next quote)
     76*/
     77unsigned int getNextQuote(const std::string& str, unsigned int start)
     78{
     79    unsigned int quote = start - 1;
     80
     81    while ((quote = str.find('\"', quote + 1)) != std::string::npos)
     82    {
     83        unsigned int backslash = quote;
     84        unsigned int numbackslashes = 0;
     85        for (; backslash > 0; backslash--, numbackslashes++)
     86            if (str[backslash - 1] != '\\')
     87                break;
     88
     89        if (numbackslashes % 2 == 0)
     90            break;
     91    }
     92
     93    return quote;
    6494}
    6595
     
    71101bool hasStringBetweenQuotes(const std::string& str)
    72102{
     103    unsigned int pos1 = getNextQuote(str, 0);
     104    unsigned int pos2 = getNextQuote(str, pos1 + 1);
     105    return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1);
    73106}
    74107
     
    80113std::string getStringBetweenQuotes(const std::string& str)
    81114{
     115    unsigned int pos1 = getNextQuote(str, 0);
     116    unsigned int pos2 = getNextQuote(str, pos1 + 1);
     117    if (pos1 != std::string::npos && pos2 != std::string::npos)
     118        return str.substr(pos1, pos2 - pos1 + 1);
     119    else
     120        return "";
    82121}
    83122
  • code/branches/core2/src/util/String.h

    r1006 r1020  
    3838
    3939_UtilExport std::string  removeTrailingWhitespaces(const std::string& str);
     40
     41_UtilExport unsigned int getNextQuote(const std::string& str, unsigned int start);
    4042
    4143_UtilExport bool         hasStringBetweenQuotes(const std::string& str);
Note: See TracChangeset for help on using the changeset viewer.