From e95429572c257fc037eddd88905168598ef37a00 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 20 Mar 2002 19:16:13 +0000 Subject: [PATCH] Converted if ( string == "" ) constructs to if ( string.empty() ) Fixed a warning in soundmgr.cxx. --- src/Cockpit/panel.cxx | 4 ++-- src/Cockpit/panel_io.cxx | 4 ++-- src/GUI/gui.cxx | 2 +- src/Input/input.cxx | 2 +- src/Main/fg_init.cxx | 8 ++++---- src/Main/fg_props.cxx | 6 +++--- src/Navaids/fixlist.cxx | 2 +- src/Network/props.cxx | 4 ++-- src/Scenery/FGTileLoader.cxx | 2 +- src/Sound/fg_fx.cxx | 2 +- src/Sound/soundmgr.cxx | 10 +++++----- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 5443c0437..7538e29b6 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -1076,7 +1076,7 @@ FGTextLayer::Chunk::Chunk (const string &text, const string &fmt) : _type(FGTextLayer::TEXT), _fmt(fmt) { _text = text; - if (_fmt == "") + if (_fmt.empty()) _fmt = "%s"; } @@ -1084,7 +1084,7 @@ FGTextLayer::Chunk::Chunk (ChunkType type, const SGPropertyNode * node, const string &fmt, float mult) : _type(type), _fmt(fmt), _mult(mult) { - if (_fmt == "") { + if (_fmt.empty()) { if (type == TEXT_VALUE) _fmt = "%s"; else diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index d7707d687..b81717430 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -295,7 +295,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale) type = "rotation"; } - if (propName != (string)"") { + if (!propName.empty()) { target = fgGetNode(propName.c_str(), true); } @@ -724,7 +724,7 @@ readPanel (const SGPropertyNode * root) // Get multibackground if any... // string mbgTexture = root->getStringValue("multibackground[0]"); - if (mbgTexture != (string)"") { + if (!mbgTexture.empty()) { panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0); SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture ); diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 3ecbcb6c9..67662bcc9 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -167,7 +167,7 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable) string msg = txt; msg += '\n'; msg += throwable.getFormattedMessage(); - if (throwable.getOrigin() != (string)"") { + if (!throwable.getOrigin().empty()) { msg += "\n (reported by "; msg += throwable.getOrigin(); msg += ')'; diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 7dfbc57b4..baccfb3aa 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -110,7 +110,7 @@ FGBinding::read (const SGPropertyNode * node) } _command_name = node->getStringValue("command", ""); - if (_command_name == "") { + if (_command_name.empty()) { SG_LOG(SG_INPUT, SG_ALERT, "No command supplied for binding."); _command = 0; return; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 132e3fdcc..48f4af1f2 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -140,7 +140,7 @@ bool fgInitFGRoot ( int argc, char **argv ) { #if defined( unix ) || defined( __CYGWIN__ ) // Next check home directory for .fgfsrc.hostname file - if ( root == "" ) { + if ( root.empty() ) { envp = ::getenv( "HOME" ); if ( envp != NULL ) { SGPath config( envp ); @@ -155,7 +155,7 @@ bool fgInitFGRoot ( int argc, char **argv ) { #endif // Next check home directory for .fgfsrc file - if ( root == "" ) { + if ( root.empty() ) { envp = ::getenv( "HOME" ); if ( envp != NULL ) { SGPath config( envp ); @@ -165,7 +165,7 @@ bool fgInitFGRoot ( int argc, char **argv ) { } // Next check if fg-root is set as an env variable - if ( root == "" ) { + if ( root.empty() ) { envp = ::getenv( "FG_ROOT" ); if ( envp != NULL ) { root = envp; @@ -174,7 +174,7 @@ bool fgInitFGRoot ( int argc, char **argv ) { // Otherwise, default to a random compiled-in location if we can't // find fg-root any other way. - if ( root == "" ) { + if ( root.empty() ) { #if defined( __CYGWIN__ ) root = "/FlightGear"; #elif defined( WIN32 ) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 0ba8109ac..2d63d14f1 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -105,7 +105,7 @@ getLoggingClasses () string result = ""; for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) { if ((classes&log_class_mappings[i].c) > 0) { - if (result != (string)"") + if (!result.empty()) result += '|'; result += log_class_mappings[i].name; } @@ -142,7 +142,7 @@ setLoggingClasses (const char * c) return; } - if (classes == "" || classes == "all") { // default + if (classes.empty() || classes == "all") { // default logbuf::set_log_classes(SG_ALL); SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: " << getLoggingClasses()); @@ -200,7 +200,7 @@ setLoggingPriority (const char * p) logbuf::set_log_priority(SG_BULK); } else if (priority == "debug") { logbuf::set_log_priority(SG_DEBUG); - } else if (priority == "" || priority == "info") { // default + } else if (priority.empty() || priority == "info") { // default logbuf::set_log_priority(SG_INFO); } else if (priority == "warn") { logbuf::set_log_priority(SG_WARN); diff --git a/src/Navaids/fixlist.cxx b/src/Navaids/fixlist.cxx index 55a083166..e3a02a84e 100644 --- a/src/Navaids/fixlist.cxx +++ b/src/Navaids/fixlist.cxx @@ -103,7 +103,7 @@ bool FGFixList::query( const string& ident, double lon, double lat, double elev, FGFix *fix, double *heading, double *dist ) { *fix = fixlist[ident]; - if ( fix->get_ident() == "" ) { + if ( fix->get_ident().empty() ) { return false; } diff --git a/src/Network/props.cxx b/src/Network/props.cxx index 3dcc68200..b54ac4d29 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -203,7 +203,7 @@ bool FGProps::process_command( const char *cmd ) { } } else if ( command == "pwd" ) { string ttt = node->getPath(); - if ( ttt == "" ) { + if ( ttt.empty() ) { ttt = "/"; } ttt += "\n"; @@ -269,7 +269,7 @@ bool FGProps::process_command( const char *cmd ) { if ( mode == PROMPT ) { string prompt = node->getPath(); - if ( prompt == "" ) { + if ( prompt.empty() ) { prompt = "/"; } prompt += "> "; diff --git a/src/Scenery/FGTileLoader.cxx b/src/Scenery/FGTileLoader.cxx index 2e0a01b2b..3bbe26521 100644 --- a/src/Scenery/FGTileLoader.cxx +++ b/src/Scenery/FGTileLoader.cxx @@ -92,7 +92,7 @@ FGTileLoader::add( FGTileEntry* tile ) static bool beenhere = false; if (!beenhere) { - if ( globals->get_fg_scenery() != (string)"" ) { + if ( !globals->get_fg_scenery().empty() ) { tile_path.set( globals->get_fg_scenery() ); } else { tile_path.set( globals->get_fg_root() ); diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index a58bd4aba..d7b58e543 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -53,7 +53,7 @@ FGFX::init() string path_str = node->getStringValue("path"); SGPath path( globals->get_fg_root() ); - if (path_str == "") { + if (path_str.empty()) { SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file."); return; } diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index 0580ae588..edd46700d 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -40,9 +40,9 @@ // constructor FGSimpleSound::FGSimpleSound( string file ) - : requests(0), + : pitch(1.0), volume(1.0), - pitch(1.0) + requests(0) { SGPath slfile( globals->get_fg_root() ); slfile.append( file ); @@ -54,9 +54,9 @@ FGSimpleSound::FGSimpleSound( string file ) } FGSimpleSound::FGSimpleSound( unsigned char *buffer, int len ) - : requests(0), + : pitch(1.0), volume(1.0), - pitch(1.0) + requests(0) { sample = new slSample ( buffer, len ); pitch_envelope = new slEnvelope( 1, SL_SAMPLE_ONE_SHOT ); @@ -245,7 +245,7 @@ bool FGSoundMgr::add( FGSimpleSound *sound, const string& refname ) { FGSimpleSound *FGSoundMgr::add( const string& refname, const string &file ) { FGSimpleSound *sound; - if (file == (string)"") + if (file.empty()) return NULL; sample_map_iterator it = samples.find(file);