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
Location:
code/branches/presentation2/src/modules
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/objects/Attacher.cc

    r5929 r6394  
    9898        this->target_ = 0;
    9999
    100         if (this->targetname_ == "")
     100        if (this->targetname_.empty())
    101101            return;
    102102
     
    113113    void Attacher::loadedNewXMLName(BaseObject* object)
    114114    {
    115         if (this->target_ || this->targetname_ == "")
     115        if (this->target_ || this->targetname_.empty())
    116116            return;
    117117
  • code/branches/presentation2/src/modules/objects/eventsystem/EventFilter.cc

    r5929 r6394  
    6262        if (this->bActive_)
    6363        {
    64             COUT(2) << "Warning: Detected Event loop in EventFilter \"" << this->getName() << "\"" << std::endl;
     64            COUT(2) << "Warning: Detected Event loop in EventFilter \"" << this->getName() << '"' << std::endl;
    6565            return;
    6666        }
  • code/branches/presentation2/src/modules/objects/eventsystem/EventListener.cc

    r5929 r6394  
    5858        if (this->bActive_)
    5959        {
    60             COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << "\"" << std::endl;
     60            COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << '"' << std::endl;
    6161            return;
    6262        }
     
    7171        this->eventName_ = eventname;
    7272
    73         if (this->eventName_ == "")
     73        if (this->eventName_.empty())
    7474            return;
    7575
     
    8181    void EventListener::loadedNewXMLName(BaseObject* object)
    8282    {
    83         if (this->eventName_ == "")
     83        if (this->eventName_.empty())
    8484            return;
    8585
  • code/branches/presentation2/src/modules/objects/eventsystem/EventTarget.cc

    r6387 r6394  
    6060        if (this->bActive_)
    6161        {
    62             COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl;
     62            COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << '"' << std::endl;
    6363            return;
    6464        }
     
    8080    void EventTarget::loadedNewXMLName(BaseObject* object)
    8181    {
    82         if (this->target_ == "")
     82        if (this->target_.empty())
    8383            return;
    8484
  • code/branches/presentation2/src/modules/objects/triggers/DistanceTrigger.cc

    r5937 r6394  
    9292    if (!targetId)
    9393    {
    94         COUT(1) << "Error: \"" << targets << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
     94        COUT(1) << "Error: \"" << targets << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << std::endl;
    9595        return;
    9696    }
  • code/branches/presentation2/src/modules/objects/triggers/Trigger.cc

    r5929 r6394  
    280280  {
    281281    if (this->mode_ == TriggerMode::EventTriggerAND)
    282       return std::string("and");
     282      return "and";
    283283    else if (this->mode_ == TriggerMode::EventTriggerOR)
    284       return std::string("or");
     284      return "or";
    285285    else if (this->mode_ == TriggerMode::EventTriggerXOR)
    286       return std::string("xor");
     286      return "xor";
    287287    else
    288       return std::string("and");
     288      return "and";
    289289  }
    290290
  • code/branches/presentation2/src/modules/overlays/GUIOverlay.cc

    r6387 r6394  
    6969        if (this->isVisible())
    7070        {
    71             std::string str;
    72             std::stringstream out;
     71            std::ostringstream out;
    7372            out << reinterpret_cast<long>(this);
    74             str = out.str();
     73            const std::string& str = out.str();
    7574            COUT(1) << "GUIManager ptr: " << str << std::endl;
    7675            GUIManager::getInstance().showGUIExtra(this->guiName_, str);
  • code/branches/presentation2/src/modules/overlays/OverlayText.cc

    r5781 r6394  
    134134    void OverlayText::setFont(const std::string& font)
    135135    {
    136         if (font != "")
     136        if (!font.empty())
    137137            this->text_->setFontName(font);
    138138    }
  • code/branches/presentation2/src/modules/overlays/hud/HUDBar.cc

    r6223 r6394  
    7272
    7373        // create new material
    74         std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
     74        const std::string& materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
    7575        Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General"));
    7676        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
  • code/branches/presentation2/src/modules/overlays/hud/HUDHealthBar.h

    r6054 r6394  
    5353
    5454            inline void setTextFont(const std::string& font)
    55                 { if (font != "") { this->textoverlay_->setFont(font); } }
     55                { if (!font.empty()) { this->textoverlay_->setFont(font); } }
    5656            inline const std::string& getTextFont() const
    5757                { return this->textoverlay_->getFont(); }
  • code/branches/presentation2/src/modules/overlays/hud/HUDNavigation.cc

    r6378 r6394  
    3636
    3737#include "util/Math.h"
    38 #include "util/StringUtils.h"
    3938#include "util/Convert.h"
    4039#include "core/CoreIncludes.h"
     
    108107    void HUDNavigation::setFont(const std::string& font)
    109108    {
    110         if (this->navText_ && font != "")
     109        if (this->navText_ && !font.empty())
    111110            this->navText_->setFontName(font);
    112111    }
  • code/branches/presentation2/src/modules/overlays/hud/HUDRadar.cc

    r5781 r6394  
    126126            panel = *itRadarDots_;
    127127            ++itRadarDots_;
    128             std::string materialName = TextureGenerator::getMaterialName(
     128            const std::string& materialName = TextureGenerator::getMaterialName(
    129129                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
    130130            if (materialName != panel->getMaterialName())
  • code/branches/presentation2/src/modules/overlays/hud/TeamBaseMatchScore.cc

    r5929 r6394  
    7171        if (this->owner_)
    7272        {
    73             std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";
    74             std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";
     73            const std::string& bases1 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ')';
     74            const std::string& bases2 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ')';
    7575
    76             std::string score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
    77             std::string score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
     76            const std::string& score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
     77            const std::string& score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
    7878
    7979            std::string output1;
     
    9999            }
    100100
    101             std::string output = "";
     101            std::string output;
    102102            if (this->bShowBases_ || this->bShowScore_)
    103103            {
    104104                if (this->bShowLeftTeam_ && this->bShowRightTeam_)
    105                     output = output1 + ":" + output2;
     105                    output = output1 + ':' + output2;
    106106                else if (this->bShowLeftTeam_ || this->bShowRightTeam_)
    107107                    output = output1 + output2;
  • code/branches/presentation2/src/modules/pong/PongScore.cc

    r5929 r6394  
    7777            std::string name2;
    7878
    79             std::string score1 = "0";
    80             std::string score2 = "0";
     79            std::string score1("0");
     80            std::string score2("0");
    8181
    8282            if (player1)
     
    114114            }
    115115
    116             std::string output = "PONG";
     116            std::string output("PONG");
    117117            if (this->bShowName_ || this->bShowScore_)
    118118            {
    119119                if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
    120                     output = output1 + ":" + output2;
     120                    output = output1 + ':' + output2;
    121121                else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
    122122                    output = output1 + output2;
  • code/branches/presentation2/src/modules/questsystem/QuestDescription.cc

    r6387 r6394  
    5050    {
    5151        RegisterObject(QuestDescription);
    52 
    53         this->title_ = "";
    54         this->description_ = "";
    5552    }
    5653
     
    9491    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
    9592    {
    96         std::string message = "";
     93        std::string message;
    9794        if(item == "hint")
    9895        {
    99             message = "You received a hint: '" + this->title_ + "'";
     96            message = "You received a hint: '" + this->title_ + '\'';
    10097        }
    10198        else if(item == "quest")
     
    103100            if(status == "start")
    104101            {
    105                 message = "You received a new quest: '" + this->title_ + "'";
     102                message = "You received a new quest: '" + this->title_ + '\'';
    106103            }
    107104            else if(status == "fail")
    108105            {
    109                 message = "You failed the quest: '" + this->title_ + "'";
     106                message = "You failed the quest: '" + this->title_ + '\'';
    110107            }
    111108            else if(status == "complete")
    112109            {
    113                 message = "You successfully completed the quest: '" + this->title_ + "'";
     110                message = "You successfully completed the quest: '" + this->title_ + '\'';
    114111            }
    115112            else
  • code/branches/presentation2/src/modules/questsystem/QuestGUINode.cc

    r6388 r6394  
    134134        if(this->window_ != NULL)
    135135        {
    136             buffer = (std::string)(this->window_->getName().c_str());
     136            buffer = this->window_->getName().c_str();
    137137        }
    138138        else
    139139        {
    140             buffer = "";
     140            buffer.erase();
    141141        }
    142142    }
     
    187187                CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
    188188                window->addChildWindow(statusWindow);
    189                 std::string status = "";
     189                std::string status;
    190190                if(quest->isActive(this->gui_->getPlayer()))
    191191                {
  • code/branches/presentation2/src/modules/questsystem/QuestItem.cc

    r6387 r6394  
    4747    {
    4848        RegisterObject(QuestItem);
    49 
    50         this->id_ = "";
    5149    }
    5250
  • code/branches/presentation2/src/modules/questsystem/QuestListener.cc

    r6388 r6394  
    183183        {
    184184            COUT(1) << "An unforseen, never to happen, Error has occurred. This is impossible!" << std::endl;
    185         return "";
     185            return "";
    186186        }
    187187    }
  • code/branches/presentation2/src/modules/questsystem/QuestNotification.cc

    r6387 r6394  
    3232namespace orxonox {
    3333
    34     const std::string QuestNotification::SENDER = "questsystem";
     34    const std::string QuestNotification::SENDER("questsystem");
    3535
    3636    QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator)
  • code/branches/presentation2/src/modules/questsystem/notifications/Notification.cc

    r6387 r6394  
    7575    void Notification::initialize(void)
    7676    {
    77         this->message_ = "";
     77        this->message_.clear();
    7878        this->sender_ = NotificationManager::NONE;
    7979        this->sent_ = false;
  • code/branches/presentation2/src/modules/questsystem/notifications/NotificationManager.cc

    r6182 r6394  
    4444{
    4545
    46     const std::string NotificationManager::ALL = "all";
    47     const std::string NotificationManager::NONE = "none";
     46    const std::string NotificationManager::ALL("all");
     47    const std::string NotificationManager::NONE("none");
    4848
    4949    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
  • code/branches/presentation2/src/modules/questsystem/notifications/NotificationQueue.cc

    r5929 r6394  
    4646    CreateFactory(NotificationQueue);
    4747
    48     const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";
    49     const Vector2 NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0);
    50     const float NotificationQueue::DEFAULT_FONT_SIZE  = 0.025f;
     48    const std::string NotificationQueue::DEFAULT_FONT("VeraMono");
     49    const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0);
     50    const float NotificationQueue::DEFAULT_FONT_SIZE = 0.025f;
    5151
    5252    /**
     
    271271            if(!first)
    272272            {
    273                 *string += ",";
     273                *string += ',';
    274274            }
    275275            else
     
    300300        while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
    301301        {
    302             pTemp = new std::string("");
     302            pTemp = new std::string();
    303303            while(index < targets.size() && targets[index] != ',' && targets[index] != ' ')
    304304            {
     
    399399        std::ostringstream stream;
    400400        stream << reinterpret_cast<unsigned long>(notification);
    401         std::string addressString = stream.str() ;
     401        const std::string& addressString = stream.str();
    402402        container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
    403403
Note: See TracChangeset for help on using the changeset viewer.