Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 22, 2009, 2:07:44 PM (15 years ago)
Author:
rgrieder
Message:

std::string tweaks:

  • Declared BLANKSTRING in UtilPrereqs.h as well (removed obsolete StringUtils.h includes to avoid dependencies)
  • Using BLANKSTRING if const std::string& return type is possible
  • Replaced a few (const) std::string arguments with const std::string&
  • if (str == "") —> if (str.empty())
  • std::string msg = name + "adsf"; —> const std::string& msg = name + "asdf";
  • std::string asdf = object→getFooBar(); —> const std::string& asdf = object→getFooBar();
  • std::string asdf = "asdf"; —> std::string asdf("asdf");
  • ostream << "."; and name + "." —> ostream << '.'; and name + '.'
  • str = ""; —> str.clear()
  • std::string asdf = ""; —> std::string asdf;
  • asdf_ = ""; (in c'tor) —> delete line
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/ConfigFileManager.cc

    r6387 r6394  
    9999            this->value_ = value;
    100100        else
    101             this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
     101            this->value_ = '"' + addSlashes(stripEnclosingQuotes(value)) + '"';
    102102    }
    103103
     
    112112    std::string ConfigFileEntryValue::getFileEntry() const
    113113    {
    114         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    115             return (this->name_ + "=" + this->value_);
    116         else
    117             return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
     114        if (this->additionalComment_.empty())
     115            return (this->name_ + '=' + this->value_);
     116        else
     117            return (this->name_ + '=' + this->value_ + " " + this->additionalComment_);
    118118    }
    119119
     
    124124    std::string ConfigFileEntryVectorValue::getFileEntry() const
    125125    {
    126         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    127             return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
    128         else
    129             return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
     126        if (this->additionalComment_.empty())
     127            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + ']' + '=' + this->value_);
     128        else
     129            return (this->name_ + '[' + multi_cast<std::string>(this->index_) + "]=" + this->value_ + ' ' + this->additionalComment_);
    130130    }
    131131
     
    171171    std::string ConfigFileSection::getFileEntry() const
    172172    {
    173         if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    174             return ("[" + this->name_ + "]");
    175         else
    176             return ("[" + this->name_ + "] " + this->additionalComment_);
     173        if (this->additionalComment_.empty())
     174            return ('[' + this->name_ + ']');
     175        else
     176            return ('[' + this->name_ + "] " + this->additionalComment_);
    177177    }
    178178
     
    251251                std::getline(file, line);
    252252
    253                 std::string temp = getStripped(line);
     253                const std::string& temp = getStripped(line);
    254254                if (!isEmpty(temp) && !isComment(temp))
    255255                {
     
    261261                    {
    262262                        // New section
    263                         std::string comment = line.substr(pos2 + 1);
     263                        const std::string& comment = line.substr(pos2 + 1);
    264264                        if (isComment(comment))
    265265                            newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
     
    293293                                commentposition = getNextCommentPosition(line, commentposition + 1);
    294294                            }
    295                             std::string value = "", comment = "";
     295                            std::string value, comment;
    296296                            if (commentposition == std::string::npos)
    297297                            {
Note: See TracChangeset for help on using the changeset viewer.