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/orxonox
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/Level.cc

    r5929 r6394  
    141141    void Level::playerEntered(PlayerInfo* player)
    142142    {
    143         COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
     143        COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
    144144        player->setGametype(this->getGametype());
    145145    }
     
    147147    void Level::playerLeft(PlayerInfo* player)
    148148    {
    149         COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
     149        COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
    150150        player->setGametype(0);
    151151    }
  • code/branches/presentation2/src/orxonox/LevelManager.cc

    r6256 r6394  
    122122    }
    123123
    124     std::string LevelManager::getAvailableLevelListItem(unsigned int index) const
     124    const std::string& LevelManager::getAvailableLevelListItem(unsigned int index) const
    125125    {
    126126        if (index >= availableLevels_.size())
    127             return std::string();
     127            return BLANKSTRING;
    128128        else
    129129            return availableLevels_[index];
  • code/branches/presentation2/src/orxonox/LevelManager.h

    r5781 r6394  
    6060            const std::string& getDefaultLevel() const; //tolua_export
    6161            void compileAvailableLevelList(); //tolua_export
    62             std::string getAvailableLevelListItem(unsigned int index) const; //tolua_export
     62            const std::string& getAvailableLevelListItem(unsigned int index) const; //tolua_export
    6363
    6464            static LevelManager* getInstancePtr() { return singletonPtr_s; }
  • code/branches/presentation2/src/orxonox/Radar.cc

    r6314 r6394  
    8585    }
    8686
    87     RadarViewable::Shape Radar::addObjectDescription(const std::string name)
     87    RadarViewable::Shape Radar::addObjectDescription(const std::string& name)
    8888    {
    8989        std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name);
  • code/branches/presentation2/src/orxonox/Radar.h

    r5929 r6394  
    5555
    5656        const RadarViewable* getFocus();
    57         RadarViewable::Shape addObjectDescription(const std::string name);
     57        RadarViewable::Shape addObjectDescription(const std::string& name);
    5858
    5959        void listObjects() const;
  • code/branches/presentation2/src/orxonox/gamestates/GSLevel.cc

    r6387 r6394  
    154154            if (find == this->staticObjects_.end())
    155155            {
    156                 COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ")" << std::endl;
     156                COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ')' << std::endl;
    157157            }
    158158        }
  • code/branches/presentation2/src/orxonox/gametypes/Asteroids.cc

    r5929 r6394  
    7272        Gametype::start();
    7373
    74         std::string message = "The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...";
     74        std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
    7575        COUT(0) << message << std::endl;
    7676        Host::Broadcast(message);
     
    8181        Gametype::end();
    8282
    83         std::string message = "The match has ended.";
     83        std::string message("The match has ended.");
    8484        COUT(0) << message << std::endl;
    8585        Host::Broadcast(message);
  • code/branches/presentation2/src/orxonox/gametypes/Deathmatch.cc

    r5781 r6394  
    4747        Gametype::start();
    4848
    49         std::string message = "The match has started!";
     49        std::string message("The match has started!");
    5050        COUT(0) << message << std::endl;
    5151        Host::Broadcast(message);
     
    5656        Gametype::end();
    5757
    58         std::string message = "The match has ended.";
     58        std::string message("The match has ended.");
    5959        COUT(0) << message << std::endl;
    6060        Host::Broadcast(message);
     
    6565        Gametype::playerEntered(player);
    6666
    67         std::string message = player->getName() + " entered the game";
     67        const std::string& message = player->getName() + " entered the game";
    6868        COUT(0) << message << std::endl;
    6969        Host::Broadcast(message);
     
    7676        if (valid_player)
    7777        {
    78             std::string message = player->getName() + " left the game";
     78            const std::string& message = player->getName() + " left the game";
    7979            COUT(0) << message << std::endl;
    8080            Host::Broadcast(message);
     
    9090        if (valid_player)
    9191        {
    92             std::string message = player->getOldName() + " changed name to " + player->getName();
     92            const std::string& message = player->getOldName() + " changed name to " + player->getName();
    9393            COUT(0) << message << std::endl;
    9494            Host::Broadcast(message);
     
    126126        if (player)
    127127        {
    128             std::string message = player->getName() + " scores!";
     128            const std::string& message = player->getName() + " scores!";
    129129            COUT(0) << message << std::endl;
    130130            Host::Broadcast(message);
  • code/branches/presentation2/src/orxonox/gametypes/Gametype.cc

    r6387 r6394  
    7171
    7272        // load the corresponding score board
    73         if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
     73        if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
    7474        {
    7575            this->scoreboard_ = new OverlayGroup(this);
  • code/branches/presentation2/src/orxonox/gametypes/UnderAttack.cc

    r5929 r6394  
    6969    {
    7070        this->end(); //end gametype
    71         std::string message = "Ship destroyed! Team 0 has won!";
     71        std::string message("Ship destroyed! Team 0 has won!");
    7272        COUT(0) << message << std::endl;
    7373        Host::Broadcast(message);
     
    152152                this->gameEnded_ = true;
    153153                this->end();
    154                 std::string message = "Time is up! Team 1 has won!";
     154                std::string message("Time is up! Team 1 has won!");
    155155                COUT(0) << message << std::endl;
    156156                Host::Broadcast(message);
     
    171171            if ( gameTime_ <= timesequence_ && gameTime_ > 0)
    172172            {
    173                 std::string message = multi_cast<std::string>(timesequence_) + " seconds left!";
     173                const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
    174174/*
    175175                COUT(0) << message << std::endl;
  • code/branches/presentation2/src/orxonox/graphics/Billboard.cc

    r5781 r6394  
    4242        RegisterObject(Billboard);
    4343
    44         this->material_ = "";
    4544        this->colour_ = ColourValue::White;
    4645//        this->rotation_ = 0;
     
    7675    void Billboard::changedMaterial()
    7776    {
    78         if (this->material_ == "")
     77        if (this->material_.empty())
    7978            return;
    8079
     
    9998        {
    10099/*
    101             if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
     100            if (this->getScene() && GameMode::showsGraphics() && !this->material_.empty())
    102101            {
    103102                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
  • code/branches/presentation2/src/orxonox/infos/HumanPlayer.cc

    r6108 r6394  
    164164        if (this->isInitialized() && this->isLocalPlayer())
    165165        {
    166             if (this->getGametype() && this->getGametype()->getHUDTemplate() != "")
     166            if (this->getGametype() && !this->getGametype()->getHUDTemplate().empty())
    167167                this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
    168168            else
     
    179179        }
    180180
    181         if (this->isLocalPlayer() && this->humanHudTemplate_ != "" && GameMode::showsGraphics())
     181        if (this->isLocalPlayer() && !this->humanHudTemplate_.empty() && GameMode::showsGraphics())
    182182        {
    183183            this->humanHud_ = new OverlayGroup(this);
     
    195195        }
    196196
    197         if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
     197        if (this->isLocalPlayer() && !this->gametypeHudTemplate_.empty())
    198198        {
    199199            this->gametypeHud_ = new OverlayGroup(this);
  • code/branches/presentation2/src/orxonox/items/Engine.h

    r5929 r6394  
    106106            virtual const Vector3& getDirection() const;
    107107
    108             void loadSound(const std::string filename);
    109 
    110108        private:
    111109            void networkcallback_shipID();
  • code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc

    r6381 r6394  
    3535
    3636#include "util/Convert.h"
    37 #include "util/StringUtils.h"
    3837#include "core/CoreIncludes.h"
    3938#include "core/GameMode.h"
     
    201200        if (effect == NULL)
    202201            return;
    203         effect->setLuaState(this->lua_, "f" + multi_cast<std::string>(this->effectContainers_.size()));
     202        effect->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size()));
    204203        this->effectContainers_.push_back(effect);
    205204        if (this->getShip())
  • code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc

    r6375 r6394  
    318318            this->print(this->shell_->getInput(), Shell::Input, 0);
    319319
    320         if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
     320        if (this->shell_->getInput().empty())
    321321            this->inputWindowStart_ = 0;
    322322    }
  • code/branches/presentation2/src/orxonox/overlays/Map.cc

    r6218 r6394  
    4949#include <OgreViewport.h>
    5050
     51#include "util/StringUtils.h"
    5152#include "core/ConsoleCommand.h"
    5253#include "core/CoreIncludes.h"
  • code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.cc

    r6387 r6394  
    4545#include "util/Convert.h"
    4646#include "util/Exception.h"
    47 #include "util/StringUtils.h"
    4847#include "core/GameMode.h"
    4948#include "core/CoreIncludes.h"
     
    146145
    147146        if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
    148             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
     147            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
    149148
    150149        OrxonoxOverlay::overlays_s[this->getName()] = this;
     
    154153    void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
    155154    {
    156         if (this->background_ && material != "")
     155        if (this->background_ && !material.empty())
    157156            this->background_->setMaterialName(material);
    158157    }
  • code/branches/presentation2/src/orxonox/pickup/DroppedItem.cc

    r5929 r6394  
    8383        if (this->item_)
    8484        {
    85             COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl;
     85            COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << '\'' << std::endl;
    8686            this->item_->destroy();
    8787        }
     
    112112        drop->createTimer();
    113113
    114         COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
     114        COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << ',' << position.y << ',' << position.z << ")." << std::endl;
    115115
    116116        return drop;
  • code/branches/presentation2/src/orxonox/pickup/PickupInventory.cc

    r6150 r6394  
    196196            return "";
    197197
    198         std::string name = "pickup_" + item->getGUIImage();
     198        const std::string& name = "pickup_" + item->getGUIImage();
    199199
    200200        if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
     
    203203        }
    204204
    205         return "set:" + name + " image:full_image";
     205        return ("set:" + name + " image:full_image");
    206206    }
    207207
     
    332332        txt->setVisible(true);
    333333        txt->setProperty("Text", item->getGUIText());
    334         txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour + "");
    335 
    336         std::string image = PickupInventory::getImageForItem(item);
     334        txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour);
     335
     336        const std::string& image = PickupInventory::getImageForItem(item);
    337337        btn->setVisible(true);
    338338        btn->setProperty("NormalImage", image);
  • code/branches/presentation2/src/orxonox/sound/AmbientSound.cc

    r6388 r6394  
    113113        if (GameMode::playsSound())
    114114        {
    115             std::string path = "ambient/" + MoodManager::getInstance().getMood() + "/" + source;
     115            const std::string& path = "ambient/" + MoodManager::getInstance().getMood() + '/' + source;
    116116            shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
    117117            if (fileInfo != NULL)
  • code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc

    r6378 r6394  
    5757        DataStreamPtr dataStream = Resource::open(fileInfo);
    5858
    59         std::string extension(this->filename_.substr(this->filename_.find_last_of('.') + 1));
     59        const std::string& extension = this->filename_.substr(this->filename_.find_last_of('.') + 1);
    6060        if (getLowercase(extension) == "ogg")
    6161        {
  • code/branches/presentation2/src/orxonox/sound/SoundManager.cc

    r6388 r6394  
    9292        {
    9393            this->deviceNames_.push_back(devices);
    94             COUT(4) << "\"" << devices << "\", ";
     94            COUT(4) << '"' << devices << "\", ";
    9595            devices += strlen(devices) + 1;
    9696            if (*devices == '\0')
     
    100100
    101101        // Open the selected device
    102         COUT(3) << "Sound: Opening device \"" << renderDevice << "\"" << std::endl;
     102        COUT(3) << "Sound: Opening device \"" << renderDevice << '\' << std::endl;
    103103        this->device_ = alcOpenDevice(renderDevice.c_str());
    104104*/
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc

    r6387 r6394  
    3030#include "WeaponMode.h"
    3131
    32 #include "util/StringUtils.h"
    3332#include "core/CoreIncludes.h"
    3433#include "core/XMLPort.h"
  • code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc

    r6387 r6394  
    333333            this->camera_ = new Camera(this);
    334334            this->camera_->requestFocus();
    335             if (this->cameraPositionTemplate_ != "")
     335            if (!this->cameraPositionTemplate_.empty())
    336336                this->addTemplate(this->cameraPositionTemplate_);
    337337            if (this->cameraPositions_.size() > 0)
     
    349349        if (!this->hud_ && GameMode::showsGraphics())
    350350        {
    351             if (this->hudtemplate_ != "")
     351            if (!this->hudtemplate_.empty())
    352352            {
    353353                this->hud_ = new OverlayGroup(this);
  • code/branches/presentation2/src/orxonox/worldentities/WorldEntity.cc

    r6108 r6394  
    814814    void WorldEntity::setCollisionTypeStr(const std::string& typeStr)
    815815    {
    816         std::string typeStrLower = getLowercase(typeStr);
     816        const std::string& typeStrLower = getLowercase(typeStr);
    817817        CollisionType type;
    818818        if (typeStrLower == "dynamic")
  • code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc

    r6387 r6394  
    199199    {
    200200        // play spawn effect
    201         if (this->spawnparticlesource_ != "")
     201        if (!this->spawnparticlesource_.empty())
    202202        {
    203203            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
  • code/branches/presentation2/src/orxonox/worldentities/pawns/SpaceShip.cc

    r5929 r6394  
    187187    void SpaceShip::loadEngineTemplate()
    188188    {
    189         if (this->enginetemplate_ != "")
     189        if (!this->enginetemplate_.empty())
    190190        {
    191191            Template* temp = Template::getTemplate(this->enginetemplate_);
Note: See TracChangeset for help on using the changeset viewer.