diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 551df5e2b..b4df76545 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -260,7 +260,7 @@ void FGAIBase::readFromScenario(SGPropertyNode* scFileNode) return; setPath(scFileNode->getStringValue("model", - fgGetString("/sim/multiplay/default-model", default_model))); + fgGetString("/sim/multiplay/default-model", default_model).c_str()).c_str()); setFallbackModelIndex(scFileNode->getIntValue("fallback-model-index", 0)); diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 5417bf733..5aa8c0924 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -173,7 +173,7 @@ void FGAICarrier::update(double dt) { //automatic turn into wind with a target wind of 25 kts otd //SG_LOG(SG_AI, SG_ALERT, "AICarrier: MPControl " << MPControl << " AIControl " << AIControl); - if (strcmp(_ai_latch_node->getStringValue(), "")) { + if (_ai_latch_node->getStringValue() != "") { SG_LOG(SG_AI, SG_DEBUG, "FGAICarrier::update(): not updating because ai-latch=" << _ai_latch_node->getStringValue()); } else if (!_MPControl && _AIControl){ diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index 3995a6859..1d1d0cc76 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -455,8 +455,8 @@ void FGAIMultiplayer::update(double dt) // bool motion_logging = false; { - const char* callsign = mLogRawSpeedMultiplayer->getStringValue(); - if (callsign && callsign[0] && this->_callsign == callsign) + string callsign = mLogRawSpeedMultiplayer->getStringValue(); + if (!callsign.empty() && this->_callsign == callsign) { motion_logging = true; } diff --git a/src/AIModel/performancedb.cxx b/src/AIModel/performancedb.cxx index 825e59cea..d5f8d0578 100644 --- a/src/AIModel/performancedb.cxx +++ b/src/AIModel/performancedb.cxx @@ -118,10 +118,10 @@ void PerformanceDB::load(const SGPath& filename) SGPropertyNode * node = root.getNode("performancedb"); for (int i = 0; i < node->nChildren(); i++) { SGPropertyNode * db_node = node->getChild(i); - if (!strcmp(db_node->getName(), "aircraft")) { + if (db_node->getNameString() == "aircraft") { PerformanceData* data = NULL; if (db_node->hasChild("base")) { - const string& baseName = db_node->getStringValue("base"); + std::string baseName = db_node->getStringValue("base"); PerformanceData* baseData = _db[baseName]; if (!baseData) { SG_LOG(SG_AI, SG_ALERT, @@ -136,21 +136,21 @@ void PerformanceDB::load(const SGPath& filename) } data->initFromProps(db_node); - const string& name = db_node->getStringValue("type", "heavy_jet"); + std::string name = db_node->getStringValue("type", "heavy_jet"); registerPerformanceData(name, data); - } else if (!strcmp(db_node->getName(), "alias")) { - const string& alias(db_node->getStringValue("alias")); + } else if (db_node->getNameString() == "alias") { + std::string alias = db_node->getStringValue("alias"); if (alias.empty()) { SG_LOG(SG_AI, SG_ALERT, "performance DB alias entry with no definition"); continue; } for (auto matchNode : db_node->getChildren("match")) { - const string& match(matchNode->getStringValue()); + std::string match = matchNode->getStringValue(); _aliases.push_back(StringPair(match, alias)); } } else { - SG_LOG(SG_AI, SG_ALERT, "unrecognized performance DB entry:" << db_node->getName()); + SG_LOG(SG_AI, SG_ALERT, "unrecognized performance DB entry:" << db_node->getNameString()); } } // of nodes iteration } diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index c0fbd528b..1327c3c28 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -625,8 +625,8 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable, const if (sm->contents_node != 0) sm->contents = sm->contents_node->getDoubleValue(); - const char *trigger_path = entry_node->getStringValue("trigger", 0); - if (trigger_path) { + string trigger_path = entry_node->getStringValue("trigger", ""); + if (!trigger_path.empty()) { sm->trigger_node = fgGetNode(trigger_path, true); sm->trigger_node->setBoolValue(sm->trigger_node->getBoolValue()); } diff --git a/src/ATC/ATISEncoder.cxx b/src/ATC/ATISEncoder.cxx index 1bec44ca9..d7beab125 100644 --- a/src/ATC/ATISEncoder.cxx +++ b/src/ATC/ATISEncoder.cxx @@ -225,9 +225,9 @@ string ATISEncoder::processTokens( SGPropertyNode_ptr node ) string ATISEncoder::processToken( SGPropertyNode_ptr token ) { - HandlerMap::iterator it = handlerMap.find( token->getName()); + HandlerMap::iterator it = handlerMap.find( token->getNameString()); if( it == handlerMap.end() ) { - SG_LOG(SG_ATC, SG_WARN, "ATISEncoder: unknown token: " << token->getName() ); + SG_LOG(SG_ATC, SG_WARN, "ATISEncoder: unknown token: " << token->getNameString() ); return EMPTY; } handler_t h = it->second; diff --git a/src/ATC/MetarPropertiesATISInformationProvider.cxx b/src/ATC/MetarPropertiesATISInformationProvider.cxx index 3dcb9a3b5..fbb39d8dc 100644 --- a/src/ATC/MetarPropertiesATISInformationProvider.cxx +++ b/src/ATC/MetarPropertiesATISInformationProvider.cxx @@ -104,7 +104,7 @@ ATISInformationProvider::CloudEntries MetarPropertiesATISInformationProvider::ge using simgear::PropertyList; PropertyList layers = _metar->getNode("clouds", true )->getChildren("layer"); for( PropertyList::iterator it = layers.begin(); it != layers.end(); ++it ) { - const char * coverage = (*it)->getStringValue("coverage","clear"); + std::string coverage = (*it)->getStringValue("coverage", "clear"); double elevation = (*it)->getDoubleValue("elevation-ft", -9999 ); if( elevation > 0 ) { reply[elevation] = coverage; diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index 23e2f2472..54b1ef276 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -44,7 +44,7 @@ using std::string; -static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name) +static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const std::string& name) { SGPropertyNode* p; @@ -52,7 +52,7 @@ static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name) if ((p = getNamedNode(prop->getChild(i), name))) return p; - if (!strcmp(prop->getStringValue("name"), name)) + if (prop->getStringValue("name") == name) return prop; return 0; } diff --git a/src/Aircraft/continuous.cxx b/src/Aircraft/continuous.cxx index 30512adbc..4dba3968a 100644 --- a/src/Aircraft/continuous.cxx +++ b/src/Aircraft/continuous.cxx @@ -137,18 +137,18 @@ static bool ReadFGReplayData2( ret->raw_data.resize(0); for (auto data: config->getChildren("data")) { - const char* data_type = data->getStringValue(); + std::string data_type = data->getStringValue(); SG_LOG(SG_SYSTEMS, SG_BULK, "in.tellg()=" << in.tellg() << " data_type=" << data_type); uint32_t length; readRaw(in, length); SG_LOG(SG_SYSTEMS, SG_DEBUG, "length=" << length); if (!in) break; - if (load_signals && !strcmp(data_type, "signals")) + if (load_signals && data_type == "signals") { ret->raw_data.resize(length); in.read(&ret->raw_data.front(), ret->raw_data.size()); } - else if (load_multiplayer && !strcmp(data_type, "multiplayer")) + else if (load_multiplayer && data_type == "multiplayer") { /* Multiplayer information is a vector of vectors. */ ret->multiplayer_messages.clear(); @@ -168,7 +168,7 @@ static bool ReadFGReplayData2( ); } } - else if (load_extra_properties && !strcmp(data_type, "extra-properties")) + else if (load_extra_properties && data_type == "extra-properties") { ReadFGReplayDataExtraProperties(in, ret, length); } @@ -439,14 +439,14 @@ static void writeFrame2(FGReplayData* r, std::ostream& out, SGPropertyNode_ptr c { for (auto data: config->getChildren("data")) { - const char* data_type = data->getStringValue(); - if (!strcmp(data_type, "signals")) + std::string data_type = data->getStringValue(); + if (data_type == "signals") { uint32_t signals_size = r->raw_data.size(); writeRaw(out, signals_size); out.write(&r->raw_data.front(), r->raw_data.size()); } - else if (!strcmp(data_type, "multiplayer")) + else if (data_type == "multiplayer") { uint32_t length = 0; for (auto message: r->multiplayer_messages) @@ -463,7 +463,7 @@ static void writeFrame2(FGReplayData* r, std::ostream& out, SGPropertyNode_ptr c out.write(&message->front(), message_size); } } - else if (!strcmp(data_type, "extra-properties")) + else if (data_type == "extra-properties") { uint32_t length = r->extra_properties.size(); SG_LOG(SG_SYSTEMS, SG_DEBUG, "data_type=" << data_type << " out.tellp()=" << out.tellp() @@ -493,19 +493,19 @@ bool continuousWriteFrame(Continuous& continuous, FGReplayData* r, std::ostream& bool has_extra_properties = false; for (auto data: config->getChildren("data")) { - const char* data_type = data->getStringValue(); - if (!strcmp(data_type, "signals")) + std::string data_type = data->getStringValue(); + if (data_type == "signals") { has_signals = true; } - else if (!strcmp(data_type, "multiplayer")) + else if (data_type == "multiplayer") { if (!r->multiplayer_messages.empty()) { has_multiplayer = true; } } - else if (!strcmp(data_type, "extra-properties")) + else if (data_type == "extra-properties") { if (!r->extra_properties.empty()) { diff --git a/src/Aircraft/flightrecorder.cxx b/src/Aircraft/flightrecorder.cxx index 2bb10a902..94a67a15a 100644 --- a/src/Aircraft/flightrecorder.cxx +++ b/src/Aircraft/flightrecorder.cxx @@ -83,7 +83,7 @@ static void s_RecordPropertyDiffs( { assert(a); assert(b); - assert(!strcmp(a->getName(), b->getName())); + assert(a->getNameString() == b->getNameString()); assert(a->getPath() == b->getPath()); assert(a->getIndex() == b->getIndex()); @@ -96,9 +96,9 @@ static void s_RecordPropertyDiffs( } } // If values differ, write a's value to out and change b's value to a's value. - const char* a_value = a->getStringValue(); - const char* b_value = b->getStringValue(); - if (strcmp(a_value, b_value)) { + const std::string a_value = a->getStringValue(); + const std::string b_value = b->getStringValue(); + if (a_value != b_value) { // Values are different so write out node and update b. SG_LOG(SG_SYSTEMS, SG_DEBUG, "recording property change:" << a->getPath() @@ -114,7 +114,7 @@ static void s_RecordPropertyDiffs( int bn = b->nChildren(); for (int i=0; igetChild(i); - SGPropertyNode* ac = a->getChild(bc->getName(), bc->getIndex(), false /*create*/); + SGPropertyNode* ac = a->getChild(bc->getNameString(), bc->getIndex(), false /*create*/); if (!ac) { // Child node is in b but not in a; we write out special // information about the deleted node and remove from b. @@ -129,7 +129,7 @@ static void s_RecordPropertyDiffs( int an = a->nChildren(); for (int i=0; igetChild(i); - SGPropertyNode* bc = b->getChild(ac->getName(), ac->getIndex(), true /*create*/); + SGPropertyNode* bc = b->getChild(ac->getNameString(), ac->getIndex(), true /*create*/); // Recurse. s_RecordPropertyDiffs(out, ac, bc, path_exclude_prefixes); } @@ -282,7 +282,7 @@ FGFlightRecorder::reinit(SGPropertyNode_ptr ConfigNode) else { // set name of active flight recorder type - const char* pRecorderName = + const std::string pRecorderName = m_ConfigNode->getStringValue("name", "aircraft-specific flight recorder"); SG_LOG(SG_SYSTEMS, SG_INFO, "FlightRecorder: Using custom recorder configuration: " << pRecorderName); @@ -357,8 +357,8 @@ FGFlightRecorder::getDefault(void) // set name of active flight recorder type SG_LOG(SG_SYSTEMS, SG_INFO, "FlightRecorder: No custom configuration. Loading generic default recorder."); - const char* Path = m_RecorderNode->getStringValue("default-config",NULL); - if (!Path) + const std::string Path = m_RecorderNode->getStringValue("default-config", ""); + if (Path.empty()) { SG_LOG(SG_SYSTEMS, SG_ALERT, "FlightRecorder: No default flight recorder specified! Check defaults.xml!"); } @@ -423,13 +423,13 @@ FGFlightRecorder::processSignalList(const char* pSignalType, TSignalList& Signal { SignalNode = SignalListNode->getChild("signal",Index,false); if (SignalNode.valid()&& - (0==strcmp(pSignalType, SignalNode->getStringValue("type","float")))) + (std::string(pSignalType) == SignalNode->getStringValue("type", "float"))) { - string PropertyPath = SignalNode->getStringValue("property",""); + string PropertyPath = SignalNode->getStringValue("property", ""); if (!PropertyPath.empty()) { PropertyPath = PropPrefix + PropertyPath; - const char* pInterpolation = SignalNode->getStringValue("interpolation","linear"); + const std::string pInterpolation = SignalNode->getStringValue("interpolation", "linear"); // Check if current signal has a "%i" place holder. Otherwise count is 1. string::size_type IndexPos = PropertyPath.find("%i"); @@ -462,17 +462,17 @@ FGFlightRecorder::processSignalList(const char* pSignalType, TSignalList& Signal Capture.Signal = fgGetNode(PPath.c_str(),true); } - if (0==strcmp(pInterpolation,"discrete")) + if (pInterpolation == "discrete") Capture.Interpolation = discrete; else - if ((0==strcmp(pInterpolation,"angular"))|| - (0==strcmp(pInterpolation,"angular-rad"))) + if ((pInterpolation == "angular")|| + (pInterpolation == "angular-rad")) Capture.Interpolation = angular_rad; else - if (0==strcmp(pInterpolation,"angular-deg")) + if (pInterpolation == "angular-deg") Capture.Interpolation = angular_deg; else - if (0==strcmp(pInterpolation,"linear")) + if (pInterpolation == "linear") Capture.Interpolation = linear; else { diff --git a/src/Aircraft/replay-internal.cxx b/src/Aircraft/replay-internal.cxx index 0921efdf1..c71122ee2 100644 --- a/src/Aircraft/replay-internal.cxx +++ b/src/Aircraft/replay-internal.cxx @@ -198,8 +198,8 @@ static void popupTip(const char* message, int delay) SGPath makeSavePath(FGTapeType type, SGPath* path_timeless) { - const char* tape_directory = fgGetString("/sim/replay/tape-directory", ""); - const char* aircraftType = fgGetString("/sim/aircraft", "unknown"); + std::string tape_directory = fgGetString("/sim/replay/tape-directory", ""); + std::string aircraftType = fgGetString("/sim/aircraft", "unknown"); if (path_timeless) *path_timeless = ""; SGPath path = SGPath(tape_directory); path.append(aircraftType); @@ -296,10 +296,10 @@ static void loadMessages(FGReplayInternal& self) for (auto it = msgs.begin(); it != msgs.end();++it) { - const char* msgText = (*it)->getStringValue("text", ""); + std::string msgText = (*it)->getStringValue("text", ""); const double msgTime = (*it)->getDoubleValue("time", -1.0); - const char* msgSpeaker = (*it)->getStringValue("speaker", "pilot"); - if (msgText[0] != 0 && msgTime >= 0) + std::string msgSpeaker = (*it)->getStringValue("speaker", "pilot"); + if (!msgText.empty() && msgTime >= 0) { FGReplayMessages data; data.sim_time = msgTime; @@ -605,7 +605,7 @@ static bool saveRawReplayData( for (auto data: meta->getNode("meta")->getChildren("data")) { SG_LOG(SG_SYSTEMS, SG_DEBUG, "data->getStringValue()=" << data->getStringValue()); - if (!strcmp(data->getStringValue(), "multiplayer")) + if (data->getStringValue() == "multiplayer") { uint32_t length = 0; for (auto message: frame->multiplayer_messages) @@ -1622,19 +1622,20 @@ static void indexContinuousRecording(FGReplayInternal& self, const void* data, s } if (length) { - stats[data->getStringValue()].num_frames += 1; - stats[data->getStringValue()].bytes += length; - if (!strcmp(data->getStringValue(), "signals")) + std::string data_type = data->getStringValue(); + stats[data_type].num_frames += 1; + stats[data_type].bytes += length; + if (data_type == "signals") { frameinfo.has_signals = true; } - else if (!strcmp(data->getStringValue(), "multiplayer")) + else if (data_type == "multiplayer") { frameinfo.has_multiplayer = true; ++self.m_continuous->m_num_frames_multiplayer; self.m_continuous->m_in_multiplayer = true; } - else if (!strcmp(data->getStringValue(), "extra-properties")) + else if (data_type == "extra-properties") { frameinfo.has_extra_properties = true; ++self.m_continuous->m_num_frames_extra_properties; @@ -2012,7 +2013,7 @@ FGReplayInternal::loadTape( bool multiplayer = false; for (auto data: meta_meta.getChildren("data")) { - if (!strcmp(data->getStringValue(), "multiplayer")) + if (data->getStringValue() == "multiplayer") { multiplayer = true; } diff --git a/src/Autopilot/autopilot.cxx b/src/Autopilot/autopilot.cxx index 5f0014fb2..00b963a62 100644 --- a/src/Autopilot/autopilot.cxx +++ b/src/Autopilot/autopilot.cxx @@ -167,7 +167,7 @@ Autopilot::Autopilot( SGPropertyNode_ptr rootNode, SGPropertyNode_ptr configNode for( int i = 0; i < count; ++i ) { SGPropertyNode_ptr node = configNode->getChild(i); - string childName = node->getName(); + string childName = node->getNameString(); if( childName == "property" || childName == "property-root" ) continue; diff --git a/src/Autopilot/autopilotgroup.cxx b/src/Autopilot/autopilotgroup.cxx index 18c6df148..a8209685c 100644 --- a/src/Autopilot/autopilotgroup.cxx +++ b/src/Autopilot/autopilotgroup.cxx @@ -187,7 +187,7 @@ void FGXMLAutopilotGroupImplementation::initFrom( SGPropertyNode_ptr rootNode, void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string& name, SGPropertyNode_ptr apNode, - const char* path ) + const std::string& path ) { SGPath config = globals->resolve_maybe_aircraft_path(path); if( config.isNull() ) diff --git a/src/Autopilot/autopilotgroup.hxx b/src/Autopilot/autopilotgroup.hxx index fd6875906..dcead22ed 100644 --- a/src/Autopilot/autopilotgroup.hxx +++ b/src/Autopilot/autopilotgroup.hxx @@ -36,7 +36,7 @@ public: static FGXMLAutopilotGroup * createInstance(const std::string& nodeName); - void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path ); + void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const std::string& path ); virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0; virtual void removeAutopilot( const std::string & name ) = 0; diff --git a/src/Autopilot/component.cxx b/src/Autopilot/component.cxx index 256c2b00d..459c54f26 100644 --- a/src/Autopilot/component.cxx +++ b/src/Autopilot/component.cxx @@ -47,7 +47,7 @@ bool Component::configure( SGPropertyNode& prop_root, for( int i = 0; i < cfg.nChildren(); ++i ) { SGPropertyNode_ptr child = cfg.getChild(i); - std::string cname(child->getName()); + std::string cname(child->getNameString()); if( !configure(*child, cname, prop_root) && cname != "params" ) // 'params' is usually used to specify parameters diff --git a/src/Autopilot/digitalfilter.cxx b/src/Autopilot/digitalfilter.cxx index d5d747367..9c3fd2904 100644 --- a/src/Autopilot/digitalfilter.cxx +++ b/src/Autopilot/digitalfilter.cxx @@ -903,7 +903,7 @@ bool DigitalFilter::configure( SGPropertyNode& prop_root, for( int i = 0; i < cfg.nChildren(); ++i ) { SGPropertyNode_ptr child = cfg.getChild(i); - std::string cname(child->getName()); + std::string cname(child->getNameString()); bool ok = false; if (!ok) ok = _implementation->configure(*child, cname, prop_root); if (!ok) ok = configure(*child, cname, prop_root); diff --git a/src/Autopilot/flipflop.cxx b/src/Autopilot/flipflop.cxx index 63fbbb55b..414ceb575 100644 --- a/src/Autopilot/flipflop.cxx +++ b/src/Autopilot/flipflop.cxx @@ -383,7 +383,7 @@ bool FlipFlopImplementation::configure( SGPropertyNode& prop_root, for( int i = 0; i < cfg.nChildren(); ++i ) { SGPropertyNode_ptr child = cfg.getChild(i); - string cname(child->getName()); + string cname(child->getNameString()); if( configure(*child, cname, prop_root) ) continue; diff --git a/src/Autopilot/inputvalue.cxx b/src/Autopilot/inputvalue.cxx index 1e597edf6..42c0b6a21 100644 --- a/src/Autopilot/inputvalue.cxx +++ b/src/Autopilot/inputvalue.cxx @@ -154,13 +154,13 @@ void InputValue::parse( SGPropertyNode& prop_root, if( !valueNode ) { // no , or element, use text node - const char * textnode = cfg.getStringValue(); + std::string textnode = cfg.getStringValue(); char * endp = NULL; // try to convert to a double value. If the textnode does not start with a number // endp will point to the beginning of the string. We assume this should be // a property name - _value = strtod( textnode, &endp ); - if( endp == textnode ) + _value = strtod( textnode.c_str(), &endp ); + if( endp == textnode.c_str() ) _property = prop_root.getNode(textnode, true); } } diff --git a/src/Cockpit/NavDisplay.cxx b/src/Cockpit/NavDisplay.cxx index 4810b28c9..a2ed96883 100644 --- a/src/Cockpit/NavDisplay.cxx +++ b/src/Cockpit/NavDisplay.cxx @@ -131,7 +131,7 @@ static string formatPropertyValue(SGPropertyNode* nd, const string& format) } if (format.find('s') != string::npos) { - ::snprintf(buf, 512, format.c_str(), nd->getStringValue()); + ::snprintf(buf, 512, format.c_str(), nd->getStringValue().c_str()); return buf; } @@ -466,8 +466,8 @@ NavDisplay::NavDisplay(SGPropertyNode *node) : continue; } - const char* id = symbol->getStringValue("id"); - if (id && strlen(id)) { + string id = symbol->getStringValue("id", ""); + if (!id.empty()) { definitionDict[id] = def; } @@ -481,8 +481,8 @@ NavDisplay::NavDisplay(SGPropertyNode *node) : continue; } - const char* id = rule->getStringValue("symbol"); - if (id && strlen(id) && (definitionDict.find(id) != definitionDict.end())) { + string id = rule->getStringValue("symbol", ""); + if (!id.empty() && (definitionDict.find(id) != definitionDict.end())) { r->setDefinition(definitionDict[id]); } else { SG_LOG(SG_INSTR, SG_WARN, "symbol rule has missing/unknown definition id:" << id); @@ -1305,11 +1305,11 @@ void NavDisplay::computePositionedState(FGPositioned* pos, string_set& states) static string mapAINodeToType(SGPropertyNode* model) { // assume all multiplayer items are aircraft for the moment. Not ideal. - if (!strcmp(model->getName(), "multiplayer")) { + if (model->getNameString() == "multiplayer") { return "ai-aircraft"; } - return string("ai-") + model->getName(); + return string("ai-") + model->getNameString(); } void NavDisplay::processAI() @@ -1464,7 +1464,7 @@ void NavDisplay::processCustomSymbols() string_set ss; computeCustomSymbolStates(symNode, ss); SymbolRuleVector rules; - findRules(symNode->getName(), ss, rules); + findRules(symNode->getNameString(), ss, rules); if (rules.empty()) { return; // no rules matched, we can skip this item } diff --git a/src/Cockpit/cockpitDisplayManager.cxx b/src/Cockpit/cockpitDisplayManager.cxx index 6eceb2da6..672422cbf 100644 --- a/src/Cockpit/cockpitDisplayManager.cxx +++ b/src/Cockpit/cockpitDisplayManager.cxx @@ -89,7 +89,7 @@ bool CockpitDisplayManager::build (SGPropertyNode* config_props) { for ( int i = 0; i < config_props->nChildren(); ++i ) { SGPropertyNode *node = config_props->getChild(i); - std::string name = node->getName(); + std::string name = node->getNameString(); std::ostringstream subsystemname; subsystemname << "instrument-" << i << '-' diff --git a/src/Cockpit/groundradar.cxx b/src/Cockpit/groundradar.cxx index 7c44b0131..b15c629fb 100644 --- a/src/Cockpit/groundradar.cxx +++ b/src/Cockpit/groundradar.cxx @@ -92,7 +92,7 @@ inline static osg::Vec3 fromPolar(double fi, double r) return osg::Vec3(sin(fi * SGD_DEGREES_TO_RADIANS) * r, cos(fi * SGD_DEGREES_TO_RADIANS) * r, 0); } -void GroundRadar::createTexture(const char* texture_name) +void GroundRadar::createTexture(const std::string& texture_name) { setSize(TextureHalfSize + TextureHalfSize); allocRT(); diff --git a/src/Cockpit/groundradar.hxx b/src/Cockpit/groundradar.hxx index ca93d4f19..3442d3bef 100644 --- a/src/Cockpit/groundradar.hxx +++ b/src/Cockpit/groundradar.hxx @@ -52,7 +52,7 @@ public: virtual void update (double dt); protected: - void createTexture(const char* texture_name); + void createTexture(const std::string& texture_name); void addRunwayVertices(const FGRunwayBase* aRunway, double aTowerLat, double aTowerLon, double aScale, osg::Vec3Array* aVertices); osg::Geometry *addPavementGeometry(const FGPavement* aPavement, double aTowerLat, double aTowerLon, double aScale); diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index de9e3aad5..475e3b699 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -1205,7 +1205,7 @@ FGTextLayer::Chunk::getValue () const sprintf(_buf, _fmt.c_str(), _text.c_str()); return _buf; case TEXT_VALUE: - sprintf(_buf, _fmt.c_str(), _node->getStringValue()); + sprintf(_buf, _fmt.c_str(), _node->getStringValue().c_str()); break; case DOUBLE_VALUE: double d = _offs + _node->getFloatValue() * _mult; diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index cb4a1892e..fb40dc5ca 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -115,7 +115,7 @@ readTexture (const SGPropertyNode * node) node->getFloatValue("y1"), node->getFloatValue("x2", 1.0), node->getFloatValue("y2", 1.0)); - SG_LOG(SG_COCKPIT, SG_DEBUG, "Read texture " << node->getName()); + SG_LOG(SG_COCKPIT, SG_DEBUG, "Read texture " << node->getNameString()); return texture; } @@ -255,7 +255,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale) { FGPanelTransformation * t = new FGPanelTransformation; - string name = node->getName(); + string name = node->getNameString(); string type = node->getStringValue("type"); string propName = node->getStringValue("property", ""); SGPropertyNode * target = 0; @@ -454,7 +454,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) layer = new FGGroupLayer(); for (int i = 0; i < node->nChildren(); i++) { const SGPropertyNode * child = node->getChild(i); - if (!strcmp(child->getName(), "layer")) + if (child->getNameString() == "layer") ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale)); } } @@ -483,12 +483,12 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) int nChunks = chunk_group->nChildren(); for (int i = 0; i < nChunks; i++) { const SGPropertyNode * node = chunk_group->getChild(i); - if (!strcmp(node->getName(), "chunk")) { + if (node->getNameString() == "chunk") { FGTextLayer::Chunk * chunk = readTextChunk(node); if (chunk != 0) tlayer->addChunk(chunk); } else { - SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName() + SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getNameString() << " in chunks" ); } } @@ -501,7 +501,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) layer = new FGSwitchLayer(); for (int i = 0; i < node->nChildren(); i++) { const SGPropertyNode * child = node->getChild(i); - if (!strcmp(child->getName(), "layer")) + if (child->getNameString() == "layer") ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale)); } } @@ -542,12 +542,12 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) int nTransformations = trans_group->nChildren(); for (int i = 0; i < nTransformations; i++) { const SGPropertyNode * node = trans_group->getChild(i); - if (!strcmp(node->getName(), "transformation")) { + if (node->getNameString() == "transformation") { FGPanelTransformation * t = readTransformation(node, w_scale, h_scale); if (t != 0) layer->addTransformation(t); } else { - SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName() + SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getNameString() << " in transformations" ); } } @@ -611,12 +611,12 @@ readInstrument (const SGPropertyNode * node, const SGPath& path) int nActions = action_group->nChildren(); for (int i = 0; i < nActions; i++) { const SGPropertyNode * node = action_group->getChild(i); - if (!strcmp(node->getName(), "action")) { + if (node->getNameString() == "action") { FGPanelAction * action = readAction(node, w_scale, h_scale); if (action != 0) instrument->addAction(action); } else { - SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName() + SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getNameString() << " in actions" ); } } @@ -630,12 +630,12 @@ readInstrument (const SGPropertyNode * node, const SGPath& path) int nLayers = layer_group->nChildren(); for (int i = 0; i < nLayers; i++) { const SGPropertyNode * node = layer_group->getChild(i); - if (!strcmp(node->getName(), "layer")) { + if (node->getNameString() == "layer") { FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale); if (layer != 0) instrument->addLayer(layer); } else { - SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName() + SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getNameString() << " in layers" ); } } @@ -741,11 +741,11 @@ readPanel (const SGPropertyNode * root, const SGPath& path) int nInstruments = instrument_group->nChildren(); for (int i = 0; i < nInstruments; i++) { const SGPropertyNode * node = instrument_group->getChild(i); - if (!strcmp(node->getName(), "instrument")) { + if (node->getNameString() == "instrument") { FGPanelInstrument * instrument = readInstrument(node, path); if (instrument != 0) panel->addInstrument(instrument); - } else if (!strcmp(node->getName(), "special-instrument")) { + } else if (node->getNameString() == "special-instrument") { //cout << "Special instrument found in instruments section!\n"; const string name = node->getStringValue("name"); if (name == "KLN89 GPS") { @@ -791,7 +791,7 @@ readPanel (const SGPropertyNode * root, const SGPath& path) SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" ); } } else { - SG_LOG( SG_COCKPIT, SG_WARN, "Skipping " << node->getName() + SG_LOG( SG_COCKPIT, SG_WARN, "Skipping " << node->getNameString() << " in instruments section" ); } } diff --git a/src/Cockpit/wxradar.cxx b/src/Cockpit/wxradar.cxx index 118883953..f16629ee4 100644 --- a/src/Cockpit/wxradar.cxx +++ b/src/Cockpit/wxradar.cxx @@ -96,7 +96,7 @@ wxRadarBg::wxRadarBg(SGPropertyNode *node) : branch = "/instrumentation/" + _name; _Instrument = fgGetNode(branch.c_str(), _num, true); - const char *tacan_source = node->getStringValue("tacan-source", "/instrumentation/tacan"); + string tacan_source = node->getStringValue("tacan-source", "/instrumentation/tacan"); _Tacan = fgGetNode(tacan_source, true); _font_node = _Instrument->getNode("font", true); @@ -596,8 +596,8 @@ wxRadarBg::update_data(const SGPropertyNode *ac, double altitude, double heading callsign->setAlignment(osgText::Text::LEFT_BOTTOM_BASE_LINE); callsign->setLineSpacing(_font_spacing); - const char *identity = ac->getStringValue("transponder-id"); - if (!identity[0]) + string identity = ac->getStringValue("transponder-id", ""); + if (identity.empty()) identity = ac->getStringValue("callsign"); stringstream text; @@ -730,7 +730,7 @@ wxRadarBg::update_aircraft() continue; double echo_radius, sigma; - const string name = model->getName(); + const string name = model->getNameString(); //cout << "name "<nChildren() ; i++) { SGPropertyNode *abox = box_def->getChild(i); - if( strcmp(abox->getName(), "box") == 0) { + if( abox->getNameString() == "box" ) { string type = abox->getStringValue("type", "cu-small"); cld_def = cloud_def_root->getChild(type.c_str()); @@ -212,7 +212,7 @@ void FGClouds::buildLayer(int iLayer, const string& name, double coverage) { for(int i = 0; i < layer_def->nChildren() ; i++) { SGPropertyNode *acloud = layer_def->getChild(i); - if( strcmp(acloud->getName(), "cloud") == 0) { + if( acloud->getNameString() == "cloud" ) { string cloud_name = acloud->getStringValue("name"); tCloudVariety[CloudVarietyCount].name = cloud_name; double count = acloud->getDoubleValue("count", 1.0); diff --git a/src/FDM/ExternalPipe/ExternalPipe.cxx b/src/FDM/ExternalPipe/ExternalPipe.cxx index 69c658475..d73d0a420 100644 --- a/src/FDM/ExternalPipe/ExternalPipe.cxx +++ b/src/FDM/ExternalPipe/ExternalPipe.cxx @@ -519,7 +519,7 @@ void FGExternalPipe::update_property( double dt ) { // Send requested property values to fdm for ( unsigned int i = 0; i < nodes.size(); i++ ) { sprintf( cmd, "set %s %s", property_names[i].c_str(), - nodes[i]->getStringValue() ); + nodes[i]->getStringValue().c_str() ); // cout << " sending " << cmd << endl; result = write_property( pd1, cmd ); } diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 5204ccde6..48a0fd123 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -922,7 +922,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs) for (int i=0; inode->nChildren(); i++) { string access=""; - pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName(); + pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getNameString(); int node_idx = pcs->node->getChild(i)->getIndex(); if (node_idx != 0) { pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx); diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp index 878e8a309..9f8fbf806 100644 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp @@ -112,14 +112,14 @@ bool FGPropertyNode::HasNode (const string &path) string FGPropertyNode::GetName( void ) const { - return string( getName() ); + return getNameString(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% string FGPropertyNode::GetPrintableName( void ) const { - string temp_string(getName()); + string temp_string(getNameString()); size_t initial_location=0; size_t found_location; diff --git a/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp b/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp index b60fe8c3e..a09e0b190 100644 --- a/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp @@ -130,7 +130,7 @@ void FGDeadBand::Debug(int from) cout << " GAIN: " << gain << endl; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp index 42bb78931..23b881701 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp @@ -121,7 +121,7 @@ void FGFCSFunction::Debug(int from) if (!InputNodes.empty()) cout << " INPUT: " << InputNodes[0]->GetName() << endl; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp index ddd009d72..08681261e 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFilter.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFilter.cpp @@ -224,7 +224,7 @@ void FGFilter::Debug(int from) } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/models/flight_control/FGGain.cpp b/src/FDM/JSBSim/models/flight_control/FGGain.cpp index a64305f42..ac2d36c20 100644 --- a/src/FDM/JSBSim/models/flight_control/FGGain.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGGain.cpp @@ -198,7 +198,7 @@ void FGGain::Debug(int from) cout << " GAIN: " << Gain->GetName() << endl; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; if (Type == "AEROSURFACE_SCALE") { cout << " In/Out Mapping:" << endl; diff --git a/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp b/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp index 4a8c1e4bc..67634d704 100644 --- a/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGKinemat.cpp @@ -190,7 +190,7 @@ void FGKinemat::Debug(int from) cout << " " << Detents[i] << " " << TransitionTimes[i] << endl; } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; if (!DoScale) cout << " NOSCALE" << endl; } } diff --git a/src/FDM/JSBSim/models/flight_control/FGPID.cpp b/src/FDM/JSBSim/models/flight_control/FGPID.cpp index fc06985bd..24de8a486 100644 --- a/src/FDM/JSBSim/models/flight_control/FGPID.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGPID.cpp @@ -237,7 +237,7 @@ void FGPID::Debug(int from) cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp index e9b89999a..5c0d08570 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSensor.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGSensor.cpp @@ -334,7 +334,7 @@ void FGSensor::Debug(int from) } } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp b/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp index ddbc6b0df..926308c79 100644 --- a/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGSwitch.cpp @@ -204,7 +204,7 @@ void FGSwitch::Debug(int from) ++i; } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getName() << endl; + cout << " OUTPUT: " << node->getNameString() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/LaRCsim/LaRCsim.cxx b/src/FDM/LaRCsim/LaRCsim.cxx index b1c764e05..a033680a5 100644 --- a/src/FDM/LaRCsim/LaRCsim.cxx +++ b/src/FDM/LaRCsim/LaRCsim.cxx @@ -57,10 +57,10 @@ FGLaRCsim::FGLaRCsim( double dt ) { aero = fgGetNode("/sim/aero", true); uiuc_type = fgGetNode("/sim/uiuc-type", true); - ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) ); + ls_toplevel_init( 0.0, (char *)(aero->getStringValue().c_str()) ); lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is - if ( !strcmp(aero->getStringValue(), "c172") ) { + if ( aero->getStringValue() == "c172" ) { copy_to_LaRCsim(); // initialize all of LaRCsim's vars //this should go away someday -- formerly done in fg_init.cxx @@ -71,7 +71,7 @@ FGLaRCsim::FGLaRCsim( double dt ) { I_xz = 0.000000E+00; } - if ( !strcmp(aero->getStringValue(), "basic") ) { + if ( aero->getStringValue() == "basic" ) { copy_to_LaRCsim(); // initialize all of LaRCsim's vars //this should go away someday -- formerly done in fg_init.cxx @@ -119,7 +119,7 @@ void FGLaRCsim::update( double dt ) { int multiloop = _calc_multiloop(dt); // if flying c172-larcsim, do the following - if ( !strcmp(aero->getStringValue(), "c172") ) { + if ( aero->getStringValue() == "c172" ) { // set control inputs // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n'; eng.set_IAS( V_calibrated_kts ); @@ -190,7 +190,7 @@ void FGLaRCsim::update( double dt ) { } // done with c172-larcsim if-block - if ( !strcmp(aero->getStringValue(), "basic") ) { + if ( aero->getStringValue() == "basic" ) { // set control inputs // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n'; eng.set_IAS( V_calibrated_kts ); @@ -277,7 +277,7 @@ void FGLaRCsim::update( double dt ) { // IO360.cxx for the C172 thrust is broken (not sure why). // So force C172 to use engine model in c172_engine.c instead of the IO360.cxx. - // if ( !strcmp(aero->getStringValue(), "c172") ) { + // if ( aero->getStringValue() == "c172" ) { // Use_External_Engine = 1; // } else { // Use_External_Engine = 0; @@ -318,7 +318,7 @@ void FGLaRCsim::update( double dt ) { // if flying uiuc, set some properties and over-ride some previous ones #ifdef ENABLE_UIUC_MODEL - if ( !strcmp(aero->getStringValue(), "uiuc")) { + if ( aero->getStringValue() == "uiuc" ) { // surface positions and other general properties fgSetDouble("/surface-positions/flight/rudder-pos-norm", fgGetDouble("/controls/flight/rudder")); @@ -377,10 +377,10 @@ void FGLaRCsim::update( double dt ) { // make the engine cranking and running sounds when fgfs starts up fgSetDouble("/engines/engine/cranking", 1); fgSetDouble("/engines/engine/running", 1); - if ( !strcmp(uiuc_type->getStringValue(), "uiuc-prop")) { + if ( uiuc_type->getStringValue() == "uiuc-prop" ) { // uiuc prop driven airplane, e.g. Wright Flyer } - else if ( !strcmp(uiuc_type->getStringValue(), "uiuc-jet")) { + else if ( uiuc_type->getStringValue() == "uiuc-jet" ) { // uiuc jet aircraft, e.g. a4d // used for setting the sound fgSetDouble("/engines/engine/n1", (75 + (globals->get_controls()->get_throttle( 0 ) * 100.0 )/400)); @@ -388,15 +388,15 @@ void FGLaRCsim::update( double dt ) { // used for setting the instruments fgSetDouble("/engines/engine[0]/n1", (50 + (globals->get_controls()->get_throttle( 0 ) * 50))); } - else if ( !strcmp(uiuc_type->getStringValue(), "uiuc-sailplane")) { + else if ( uiuc_type->getStringValue() == "uiuc-sailplane" ) { // uiuc sailplane, e.g. asw20 fgSetDouble("/engines/engine/cranking", 0); } - else if ( !strcmp(uiuc_type->getStringValue(), "uiuc-hangglider")) { + else if ( uiuc_type->getStringValue() == "uiuc-hangglider" ) { // uiuc hang glider, e.g. airwave fgSetDouble("/engines/engine/cranking", 0); } - else if ( !strcmp(uiuc_type->getStringValue(), "uiuc-ornithopter")) { + else if ( uiuc_type->getStringValue() == "uiuc-ornithopter" ) { // flapping wings fgSetDouble("/canopy/position-norm", 0); fgSetDouble("/wing-phase/position-norm", sin(flapper_phi - 3 * LS_PI / 2)); @@ -759,7 +759,7 @@ bool FGLaRCsim::copy_from_LaRCsim() { // cout << "climb rate = " << -V_down * 60 << endl; #ifdef ENABLE_UIUC_MODEL - if (!strcmp(aero->getStringValue(), "uiuc") && aircraft_) { + if (aero->getStringValue() == "uiuc" && aircraft_) { if (pilot_elev_no) { globals->get_controls()->set_elevator(Long_control); globals->get_controls()->set_elevator_trim(Long_trim); diff --git a/src/FDM/YASim/Hitch.cpp b/src/FDM/YASim/Hitch.cpp index cb4abd56e..369d87ca9 100644 --- a/src/FDM/YASim/Hitch.cpp +++ b/src/FDM/YASim/Hitch.cpp @@ -281,15 +281,14 @@ void Hitch::findBestAIObject(bool doit,bool running_as_autoconnect) _towEndIsConnectedToProperty=false; SGPropertyNode * ainode = fgGetNode("/ai/models",false); if(!ainode) return; - char myCallsign[256]="***********"; + std::string myCallsign = "***********"; if (running_as_autoconnect) { //get own callsign SGPropertyNode *cs=fgGetNode("/sim/multiplay/callsign",false); if (cs) { - strncpy(myCallsign,cs->getStringValue(),256); - myCallsign[255]=0; + myCallsign = cs->getStringValue(); } //reset tow length for search radius. Lentgh will be later copied from master _towLength=_winchInitialTowLength; @@ -299,8 +298,8 @@ void Hitch::findBestAIObject(bool doit,bool running_as_autoconnect) for (int i=0;inChildren();i++) { SGPropertyNode * n=ainode->getChild(i); - _nodeIsMultiplayer = strncmp("multiplayer",n->getName(),11)==0; - _nodeIsAiAircraft = strncmp("aircraft",n->getName(),8)==0; + _nodeIsMultiplayer = strncmp("multiplayer", n->getNameString().c_str(), 11) == 0; + _nodeIsAiAircraft = strncmp("aircraft", n->getNameString().c_str(), 8) == 0; if (!(_nodeIsMultiplayer || _nodeIsAiAircraft)) continue; if (running_as_autoconnect) @@ -308,7 +307,7 @@ void Hitch::findBestAIObject(bool doit,bool running_as_autoconnect) if (!_nodeIsMultiplayer) continue; if(n->getBoolValue("sim/hitches/aerotow/open",true)) continue; - if(strncmp(myCallsign,n->getStringValue("sim/hitches/aerotow/tow/connected-to-ai-or-mp-callsign"),255)!=0) + if (myCallsign != n->getStringValue("sim/hitches/aerotow/tow/connected-to-ai-or-mp-callsign")) continue; } double pos[3]; @@ -565,7 +564,7 @@ void Hitch::integrate (float dt) { std::stringstream message; message<<"Could not lock hitch (tow length is insufficient) on hitch " - <<_node->getName()<<" "<<_node->getIndex()<<"!"; + <<_node->getNameString()<<" "<<_node->getIndex()<<"!"; fgSetString("/sim/messages/pilot", message.str().c_str()); _open=true; return; @@ -576,7 +575,7 @@ void Hitch::integrate (float dt) if (_node->getBoolValue("broken",false)&&_open) message<<"Oh no, the tow is broken"; else - message<<(_open?"Opened hitch ":"Locked hitch ")<<_node->getName()<<" "<<_node->getIndex()<<"!"; + message<<(_open?"Opened hitch ":"Locked hitch ")<<_node->getNameString()<<" "<<_node->getIndex()<<"!"; fgSetString("/sim/messages/pilot", message.str().c_str()); _oldOpen=_open; } @@ -599,23 +598,21 @@ void Hitch::integrate (float dt) if (_node) { //_towEndNode=fgGetNode(_node->getStringValue("tow/node"), false); - char towNode[256]; - strncpy(towNode,_node->getStringValue("tow/node"),256); - towNode[255]=0; + std::string towNode = _node->getStringValue("tow/node"); _towEndNode=fgGetNode("ai/models")->getNode(towNode, false); //AI and multiplayer objects seem to change node? //Check if we have the right one by callsign if (_nodeIsMultiplayer || _nodeIsAiAircraft) { - char MPcallsign[256]=""; - const char *MPc; - MPc=_node->getStringValue("tow/connected-to-ai-or-mp-callsign"); - if (MPc) + std::string MPcallsign = ""; + std::string MPc =_node->getStringValue("tow/connected-to-ai-or-mp-callsign"); + if (!MPc.empty()) { - strncpy(MPcallsign,MPc,256); - MPcallsign[255]=0; + MPcallsign = MPc; } - if (((_towEndNode)&&(strncmp(_towEndNode->getStringValue("callsign"),MPcallsign,255)!=0))||!_towEndNode) + if ((_towEndNode + && _towEndNode->getStringValue("callsign") != MPcallsign) + || !_towEndNode) { _timeToNextReConnectTry-=dt; if((_timeToNextReConnectTry<0)||(_timeToNextReConnectTry>10)) @@ -627,13 +624,17 @@ void Hitch::integrate (float dt) for (int i=0;inChildren();i++) { SGPropertyNode * n=ainode->getChild(i); - if(_nodeIsMultiplayer?strncmp("multiplayer",n->getName(),11)==0:strncmp("aircraft",n->getName(),8)) - if (strcmp(n->getStringValue("callsign"),MPcallsign)==0)//found + if (_nodeIsMultiplayer + ? strncmp("multiplayer", n->getNameString().c_str(), 11) == 0 + : strncmp("aircraft", n->getNameString().c_str(), 8) + ) { + if (n->getStringValue("callsign") == MPcallsign)//found { _towEndNode=n; //_node->setStringValue("tow/node",n->getPath()); _node->setStringValue("tow/node",n->getDisplayName()); } + } } } } diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx index 17e6aa758..ff3335f50 100644 --- a/src/GUI/CanvasWidget.cxx +++ b/src/GUI/CanvasWidget.cxx @@ -81,14 +81,14 @@ CanvasWidget::CanvasWidget( int x, int y, SGPropertyNode *load = nasal->getNode("load"); if( load ) { - const char *s = load->getStringValue(); + const std::string s = load->getStringValue(); // avoid crash FLIGHTGEAR-5FQ - if (!s) { + if (s.empty()) { SG_LOG(SG_GUI, SG_ALERT, "Empty 'load' script for Canvas widget:" << cprops->getStringValue("name")); return; } - nas->handleCommand(module.c_str(), file.c_str(), s, cprops); + nas->handleCommand(module.c_str(), file.c_str(), s.c_str(), cprops); } } diff --git a/src/GUI/DefaultAircraftLocator.cxx b/src/GUI/DefaultAircraftLocator.cxx index e43470953..a6aa724c5 100644 --- a/src/GUI/DefaultAircraftLocator.cxx +++ b/src/GUI/DefaultAircraftLocator.cxx @@ -106,7 +106,7 @@ WeatherScenariosModel::WeatherScenariosModel(QObject *pr) : int nChildren = scenarios->nChildren(); for (int i = 0; i < nChildren; i++) { SGPropertyNode_ptr scenario = scenarios->getChild(i); - if (strcmp(scenario->getName(), "scenario") != 0) { + if (scenario->getNameString() != "scenario") { continue; } diff --git a/src/GUI/FGFontCache.cxx b/src/GUI/FGFontCache.cxx index 91661e6d3..2ec5afec3 100755 --- a/src/GUI/FGFontCache.cxx +++ b/src/GUI/FGFontCache.cxx @@ -164,7 +164,7 @@ FGFontCache::get(SGPropertyNode *node) if (!node) return get("Helvetica.txf", 15.0, 0.0); - const char *name = node->getStringValue("name", "Helvetica.txf"); + std::string name = node->getStringValue("name", "Helvetica.txf"); float size = node->getFloatValue("size", 15.0); float slant = node->getFloatValue("slant", 0.0); diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx index 8b6eee2d3..548b56b7d 100644 --- a/src/GUI/FGPUIDialog.cxx +++ b/src/GUI/FGPUIDialog.cxx @@ -254,7 +254,7 @@ void GUIInfo::apply_format(SGPropertyNode* n) else if (fmt_type == f_DOUBLE) snprintf(buf, FORMAT_BUFSIZE, format.c_str(), n->getDoubleValue()); else - snprintf(buf, FORMAT_BUFSIZE, format.c_str(), n->getStringValue()); + snprintf(buf, FORMAT_BUFSIZE, format.c_str(), n->getStringValue().c_str()); buf[FORMAT_BUFSIZE] = '\0'; text = buf; @@ -686,8 +686,8 @@ FGPUIDialog::FGPUIDialog(SGPropertyNode* props) : FGDialog(props), _nasal_close = nasal->getNode("close"); SGPropertyNode* open = nasal->getNode("open"); if (open) { - const char* s = open->getStringValue(); - nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props); + string s = open->getStringValue(); + nas->createModule(_module.c_str(), _module.c_str(), s.c_str(), s.length(), props); } } display(props); @@ -703,8 +703,8 @@ FGPUIDialog::~FGPUIDialog() auto nas = globals->get_subsystem(); if (nas) { if (_nasal_close) { - const char* s = _nasal_close->getStringValue(); - nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props); + string s = _nasal_close->getStringValue(); + nas->createModule(_module.c_str(), _module.c_str(), s.c_str(), s.length(), _props); } nas->deleteModule(_module.c_str()); } @@ -890,7 +890,7 @@ FGPUIDialog::makeObject(SGPropertyNode* props, int parentWidth, int parentHeight int height = props->getIntValue("height", parentHeight); int x = props->getIntValue("x", (parentWidth - width) / 2); int y = props->getIntValue("y", (parentHeight - height) / 2); - string type = props->getName(); + string type = props->getNameString(); if (type.empty()) type = "dialog"; @@ -989,11 +989,11 @@ FGPUIDialog::makeObject(SGPropertyNode* props, int parentWidth, int parentHeight } else if (type == "button") { puButton* obj; - const char* legend = props->getStringValue("legend", "[none]"); + string legend = props->getStringValue("legend", "[none]"); if (props->getBoolValue("one-shot", true)) - obj = new puOneShot(x, y, legend); + obj = new puOneShot(x, y, legend.c_str()); else - obj = new puButton(x, y, legend); + obj = new puButton(x, y, legend.c_str()); if (presetSize) obj->setSize(width, height); setupObject(obj, props); @@ -1149,14 +1149,14 @@ void FGPUIDialog::setupObject(puObject* object, SGPropertyNode* props) _conditionalObjects.push_back(cnd); } - string type = props->getName(); + string type = props->getNameString(); if (type == "input" && props->getBoolValue("live")) object->setDownCallback(action_callback); if (type == "text") { - const char* format = props->getStringValue("format", 0); - if (format) { - info->fmt_type = validate_format(format); + string format = props->getStringValue("format", ""); + if (!format.empty()) { + info->fmt_type = validate_format(format.c_str()); if (info->fmt_type != f_INVALID) info->format = format; else @@ -1165,10 +1165,8 @@ void FGPUIDialog::setupObject(puObject* object, SGPropertyNode* props) } if (props->hasValue("property")) { - const char* name = props->getStringValue("name"); - if (name == 0) - name = ""; - const char* propname = props->getStringValue("property"); + string name = props->getStringValue("name", ""); + string propname = props->getStringValue("property"); SGPropertyNode_ptr node = fgGetNode(propname, true); if (type == "map") { // mapWidget binds to a sub-tree of properties, and @@ -1189,12 +1187,12 @@ void FGPUIDialog::setupObject(puObject* object, SGPropertyNode* props) if (!bindings.empty()) { info->key = props->getIntValue("keynum", -1); if (props->hasValue("key")) - info->key = getKeyCode(props->getStringValue("key", "")); + info->key = getKeyCode(props->getStringValue("key", "").c_str()); for (auto bindingNode : bindings) { - const char* cmd = bindingNode->getStringValue("command"); - if (!strcmp(cmd, "nasal")) { + string cmd = bindingNode->getStringValue("command"); + if (cmd == "nasal") { // we need to clone the binding node, so we can unique the // Nasal module. Otherwise we always modify the global dialog // definition, and cloned dialogs use the same Nasal module for @@ -1235,7 +1233,7 @@ void FGPUIDialog::setupGroup(puGroup* group, SGPropertyNode* props, void FGPUIDialog::setColor(puObject* object, SGPropertyNode* props, int which) { - string type = props->getName(); + string type = props->getNameString(); if (type.empty()) type = "dialog"; if (type == "textbox" && props->getBoolValue("editable")) @@ -1470,7 +1468,7 @@ void FGPUIDialog::applySize(puObject* object) // Implementation of FGDialog::PropertyObject. //////////////////////////////////////////////////////////////////////// -FGPUIDialog::PropertyObject::PropertyObject(const char* n, +FGPUIDialog::PropertyObject::PropertyObject(string n, puObject* o, SGPropertyNode_ptr p) : name(n), object(o), node(p) @@ -1502,11 +1500,11 @@ fgValueList::~fgValueList() void fgValueList::make_list() { SGPropertyNode_ptr values = _props; - const char* vname = "value"; + string vname = "value"; if (_props->hasChild("properties")) { // dynamic values, read from a property's children - const char* path = _props->getStringValue("properties"); + string path = _props->getStringValue("properties"); values = fgGetNode(path, true); } @@ -1518,7 +1516,7 @@ void fgValueList::make_list() _list = new char*[value_nodes.size() + 1]; unsigned int i; for (i = 0; i < value_nodes.size(); i++) { - _list[i] = strdup((char*)value_nodes[i]->getStringValue()); + _list[i] = strdup((char*)value_nodes[i]->getStringValue().c_str()); } _list[i] = 0; } diff --git a/src/GUI/FGPUIDialog.hxx b/src/GUI/FGPUIDialog.hxx index e9c221d5c..de342397d 100644 --- a/src/GUI/FGPUIDialog.hxx +++ b/src/GUI/FGPUIDialog.hxx @@ -176,7 +176,7 @@ private: // closes. std::vector _info; struct PropertyObject { - PropertyObject(const char* name, + PropertyObject(std::string name, puObject* object, SGPropertyNode_ptr node); std::string name; diff --git a/src/GUI/FGPUIMenuBar.cxx b/src/GUI/FGPUIMenuBar.cxx index f11a60d54..2c290bba4 100755 --- a/src/GUI/FGPUIMenuBar.cxx +++ b/src/GUI/FGPUIMenuBar.cxx @@ -195,8 +195,8 @@ FGPUIMenuBar::make_menu (SGPropertyNode * node) FGLocale::utf8toLatin1(label); // append the keyboard hint to the menu entry - const char* key = item_nodes[i]->getStringValue("key", 0); - if (key) + string key = item_nodes[i]->getStringValue("key", ""); + if (!key.empty()) { label.append(" <"); label.append(key); diff --git a/src/GUI/LocalAircraftCache.cxx b/src/GUI/LocalAircraftCache.cxx index 8d286f416..39f07f2de 100644 --- a/src/GUI/LocalAircraftCache.cxx +++ b/src/GUI/LocalAircraftCache.cxx @@ -77,7 +77,7 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath) LocalizedStrings ls; ls.locale = "en"; ls.strings["name"] = QString::fromStdString(sim->getStringValue("description")).trimmed(); - authors = sim->getStringValue("author"); + authors = QString::fromStdString(sim->getStringValue("author")); if (sim->hasChild("rating")) { SGPropertyNode_ptr ratingsNode = sim->getNode("rating"); @@ -88,11 +88,11 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath) if (sim->hasChild("long-description")) { // clean up any XML whitspace in the text. - ls.strings["desc"] = QString(sim->getStringValue("long-description")).simplified(); + ls.strings["desc"] = QString::fromStdString(sim->getStringValue("long-description")).simplified(); } if (sim->hasChild("variant-of")) { - variantOf = sim->getStringValue("variant-of"); + variantOf = QString::fromStdString(sim->getStringValue("variant-of")); } else { isPrimary = true; } @@ -106,16 +106,16 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath) int nChildren = tagsNode->nChildren(); for (int i = 0; i < nChildren; i++) { const SGPropertyNode* c = tagsNode->getChild(i); - if (strcmp(c->getName(), "tag") == 0) { - const char* tagName = c->getStringValue(); - usesHeliports |= (strcmp(tagName, "helicopter") == 0); + if (c->getNameString() == "tag") { + std::string tagName = c->getStringValue(); + usesHeliports |= (tagName == "helicopter"); // could also consider vtol tag? - usesSeaports |= (strcmp(tagName, "seaplane") == 0); - usesSeaports |= (strcmp(tagName, "floats") == 0); - needsMaintenance |= (strcmp(tagName, "needs-maintenance") == 0); + usesSeaports |= (tagName == "seaplane"); + usesSeaports |= (tagName == "floats"); + needsMaintenance |= (tagName == "needs-maintenance"); // and actually store the tags - tags.push_back(QString::fromUtf8(tagName)); + tags.push_back(QString::fromStdString(tagName)); } } // of tags iteration } // of set-xml has tags @@ -148,13 +148,13 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath) } if (sim->hasChild("thumbnail")) { - thumbnailPath = sim->getStringValue("thumbnail"); + thumbnailPath = QString::fromStdString(sim->getStringValue("thumbnail")); } else { thumbnailPath = "thumbnail.jpg"; } if (sim->hasChild("minimum-fg-version")) { - minFGVersion = sim->getStringValue("minimum-fg-version"); + minFGVersion = QString::fromStdString(sim->getStringValue("minimum-fg-version")); } homepageUrl = QUrl(QString::fromStdString(sim->getStringValue("urls/home-page"))); diff --git a/src/GUI/MPServersModel.cpp b/src/GUI/MPServersModel.cpp index f549d9d23..cdbe277a3 100644 --- a/src/GUI/MPServersModel.cpp +++ b/src/GUI/MPServersModel.cpp @@ -110,7 +110,7 @@ void MPServersModel::onRefreshMPServersDone(simgear::HTTP::Request*) for (int i=0; inChildren(); ++i) { SGPropertyNode* c = targetnode->getChild(i); - if (c->getName() != std::string("server")) { + if (c->getNameString() != "server") { continue; } diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index 87f00e978..17b665a0a 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -2068,7 +2068,7 @@ MapWidget::DrawAIObject::DrawAIObject(SGPropertyNode* m, const SGGeod& g) : char buffer[1024]; ::snprintf(buffer, 1024, "%s\n%dkts", - model->getStringValue("name", "<>"), + model->getStringValue("name", "<>").c_str(), speedKts); legend = buffer; } diff --git a/src/GUI/MouseCursor.cxx b/src/GUI/MouseCursor.cxx index c21542d4d..5d04376d3 100644 --- a/src/GUI/MouseCursor.cxx +++ b/src/GUI/MouseCursor.cxx @@ -208,7 +208,7 @@ bool FGMouseCursor::setCursorCommand(const SGPropertyNode* arg, SGPropertyNode*) } - Cursor c = cursorFromString(arg->getStringValue("cursor")); + Cursor c = cursorFromString(arg->getStringValue("cursor").c_str()); setCursor(c); return true; } diff --git a/src/GUI/QmlAircraftInfo.cxx b/src/GUI/QmlAircraftInfo.cxx index 31f192ada..4313f0fa0 100644 --- a/src/GUI/QmlAircraftInfo.cxx +++ b/src/GUI/QmlAircraftInfo.cxx @@ -400,7 +400,7 @@ QString QmlAircraftInfo::authors() const QString html = "
    \n"; for (auto a : structuredAuthors->getChildren("author")) { html += "
  • "; - html += a->getStringValue("name"); + html += QString::fromStdString(a->getStringValue("name")); if (a->hasChild("nick")) { html += QStringLiteral(" '") + QString::fromStdString(a->getStringValue("nick")) + QStringLiteral("'"); } diff --git a/src/GUI/QmlPropertyModel.cxx b/src/GUI/QmlPropertyModel.cxx index 070d5fd8d..76d30fff7 100644 --- a/src/GUI/QmlPropertyModel.cxx +++ b/src/GUI/QmlPropertyModel.cxx @@ -147,7 +147,7 @@ public: auto it = std::find(_directChildren.begin(), _directChildren.end(), child); if (it == _directChildren.end()) { - SG_LOG(SG_GUI, SG_DEV_ALERT, "Bug in QmlPropertyModel - child not found when removing:" << parent->getPath() << " - " << child->getName()); + SG_LOG(SG_GUI, SG_DEV_ALERT, "Bug in QmlPropertyModel - child not found when removing:" << parent->getPath() << " - " << child->getNameString()); return; } diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index ca05ecb70..9c1cb5240 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -120,7 +120,7 @@ void mkDialog (const char *txt) if (!msg->getNode(name.c_str(), false)) break; - if (!strcmp(txt, msg->getNode(name.c_str())->getStringValue("message"))) { + if (!strcmp(txt, msg->getNode(name.c_str())->getStringValue("message").c_str())) { SG_LOG(SG_GENERAL, SG_WARN, "mkDialog(): duplicate of message " << txt); return; } @@ -397,11 +397,11 @@ void fgHiResDump() glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glHint(GL_POINT_SMOOTH_HINT, GL_DONT_CARE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE); - if ( (!strcmp(fgGetString("/sim/rendering/fog"), "disabled")) || + if ( fgGetString("/sim/rendering/fog") == "disabled" || (!fgGetBool("/sim/rendering/shading"))) { // if fastest fog requested, or if flat shading force fastest glHint ( GL_FOG_HINT, GL_FASTEST ); - } else if ( !strcmp(fgGetString("/sim/rendering/fog"), "nicest") ) { + } else if ( fgGetString("/sim/rendering/fog") == "nicest" ) { glHint ( GL_FOG_HINT, GL_DONT_CARE ); } diff --git a/src/GUI/layout-props.cxx b/src/GUI/layout-props.cxx index 04065e6d6..a3f8de7d5 100644 --- a/src/GUI/layout-props.cxx +++ b/src/GUI/layout-props.cxx @@ -24,10 +24,10 @@ int LayoutWidget::stringLength(const char* s) return (int)(FONT.getFloatStringWidth(s) + 0.999); } -const char* LayoutWidget::type() +std::string LayoutWidget::type() { - const char* t = _prop->getName(); - return (*t == 0) ? "dialog" : t; + string t = _prop->getNameString(); + return t.empty() ? "dialog" : t; } bool LayoutWidget::hasParent() @@ -47,9 +47,8 @@ int LayoutWidget::nChildren() int n = 0; for(int i=0; i<_prop->nChildren(); i++) { SGPropertyNode* p = _prop->getChild(i); - const char* name = p->getName(); - if(p->nChildren() != 0 || !strcmp(name, "hrule") - || !strcmp(name, "vrule")) + string name = p->getNameString(); + if (p->nChildren() != 0 || name == "hrule" || name == "vrule") n++; } return n; @@ -62,9 +61,8 @@ LayoutWidget LayoutWidget::getChild(int idx) int n = 0; for(int i=0; i<_prop->nChildren(); i++) { SGPropertyNode* p = _prop->getChild(i); - const char* name = p->getName(); - if(p->nChildren() != 0 || !strcmp(name, "hrule") - || !strcmp(name, "vrule")) { + string name = p->getNameString(); + if (p->nChildren() != 0 || name == "hrule" || name == "vrule") { if(idx == n) return LayoutWidget(p); n++; } @@ -87,7 +85,7 @@ bool LayoutWidget::getBool(const char* f, bool dflt) return _prop->getBoolValue(f, dflt); } -const char* LayoutWidget::getStr(const char* f) +std::string LayoutWidget::getStr(const char* f) { return _prop->getStringValue(f); } diff --git a/src/GUI/layout.cxx b/src/GUI/layout.cxx index 65e26710f..fa7df81f0 100644 --- a/src/GUI/layout.cxx +++ b/src/GUI/layout.cxx @@ -46,8 +46,8 @@ void LayoutWidget::calcPrefSize(int* w, int* h) if (!getBool("enabled", true) || isType("nasal")) return; - int legw = stringLength(getStr("legend")); - int labw = stringLength(getStr("label")); + int legw = stringLength(getStr("legend").c_str()); + int labw = stringLength(getStr("label").c_str()); if(isType("dialog") || isType("group") || isType("frame")) { if(!hasField("layout")) { @@ -55,10 +55,10 @@ void LayoutWidget::calcPrefSize(int* w, int* h) if(hasField("width")) *w = getNum("width"); if(hasField("height")) *h = getNum("height"); } else { - const char* layout = getStr("layout"); - if (eq(layout, "hbox" )) doHVBox(false, false, w, h); - else if(eq(layout, "vbox" )) doHVBox(false, true, w, h); - else if(eq(layout, "table")) doTable(false, w, h); + string layout = getStr("layout"); + if (layout == "hbox") doHVBox(false, false, w, h); + else if(layout == "vbox") doHVBox(false, true, w, h); + else if(layout == "table") doTable(false, w, h); } } else if (isType("text")) { *w = labw; @@ -130,25 +130,25 @@ void LayoutWidget::layout(int x, int y, int w, int h) // Correct our box for alignment. The values above correspond to // a "fill" alignment. - const char* halign = (isGroup || isType("hrule")) ? "fill" : "center"; + string halign = (isGroup || isType("hrule")) ? "fill" : "center"; if(hasField("halign")) halign = getStr("halign"); - if(eq(halign, "left")) { + if(halign == "left") { w = prefw; - } else if(eq(halign, "right")) { + } else if(halign == "right") { x += w - prefw; w = prefw; - } else if(eq(halign, "center")) { + } else if(halign == "center") { x += (w - prefw)/2; w = prefw; } - const char* valign = (isGroup || isType("vrule")) ? "fill" : "center"; + string valign = (isGroup || isType("vrule")) ? "fill" : "center"; if(hasField("valign")) valign = getStr("valign"); - if(eq(valign, "bottom")) { + if(valign == "bottom") { h = prefh; - } else if(eq(valign, "top")) { + } else if(valign == "top") { y += h - prefh; h = prefh; - } else if(eq(valign, "center")) { + } else if(valign == "center") { y += (h - prefh)/2; h = prefh; } @@ -186,10 +186,10 @@ void LayoutWidget::layout(int x, int y, int w, int h) // Finally, if we are ourselves a layout object, do the actual layout. if(isGroup && hasField("layout")) { - const char* layout = getStr("layout"); - if (eq(layout, "hbox" )) doHVBox(true, false); - else if(eq(layout, "vbox" )) doHVBox(true, true); - else if(eq(layout, "table")) doTable(true); + string layout = getStr("layout"); + if (layout == "hbox") doHVBox(true, false); + else if(layout == "vbox") doHVBox(true, true); + else if(layout == "table") doTable(true); } } diff --git a/src/GUI/layout.hxx b/src/GUI/layout.hxx index e2dce3b6d..1223a98a3 100644 --- a/src/GUI/layout.hxx +++ b/src/GUI/layout.hxx @@ -24,7 +24,7 @@ public: LayoutWidget() { _prop = 0; } LayoutWidget(SGPropertyNode* p) { _prop = p; } - const char* type(); + std::string type(); bool hasParent(); LayoutWidget parent(); int nChildren(); @@ -32,7 +32,7 @@ public: bool hasField(const char* f); int getNum(const char* f); bool getBool(const char* f, bool dflt = false); - const char* getStr(const char* f); + std::string getStr(const char* f); void setNum(const char* f, int num); void calcPrefSize(int* w, int* h); @@ -43,7 +43,7 @@ private: static puFont FONT; static bool eq(const char* a, const char* b); - bool isType(const char* t) { return eq(t, type()); } + bool isType(const char* t) { return (t == type()); } int padding(); int stringLength(const char* s); // must handle null argument diff --git a/src/GUI/menubar.cxx b/src/GUI/menubar.cxx index 000b9a8d9..684641725 100644 --- a/src/GUI/menubar.cxx +++ b/src/GUI/menubar.cxx @@ -23,21 +23,21 @@ FGMenuBar::getLocalizedLabel(SGPropertyNode* node) if (!node) return {}; - const char* name = node->getStringValue("name", 0); + std::string name = node->getStringValue("name", ""); const auto translated = globals->get_locale()->getLocalizedString(name, "menu"); if (!translated.empty()) return translated; // return default with fallback to name - const char* l = node->getStringValue("label", name); + std::string label = node->getStringValue("label", name.c_str()); // this can occur if the menu item is missing a - if (l == nullptr) { + if (label.empty()) { SG_LOG(SG_GUI, SG_ALERT, "FGMenuBar::getLocalizedLabel: No defined for:" << node->getPath()); return string{""}; } - return string{l}; + return label; } // end of menubar.cxx diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx index 3d8179802..ed970ce51 100644 --- a/src/GUI/new_gui.cxx +++ b/src/GUI/new_gui.cxx @@ -71,7 +71,7 @@ NewGUI::~NewGUI () // static void findAllLeafValues(SGPropertyNode* node, const std::string& leaf, std::vector& out) { - const char* name = node->getName(); + string name = node->getNameString(); if (name == leaf) { out.push_back(node->getStringValue()); } @@ -121,7 +121,7 @@ NewGUI::init () SGPath p(globals->get_fg_root(), "gui/dialogs"); readDir(p); - SGPath aircraftDialogDir(string(fgGetString("/sim/aircraft-dir")), "gui/dialogs"); + SGPath aircraftDialogDir(fgGetString("/sim/aircraft-dir"), "gui/dialogs"); if (aircraftDialogDir.exists()) { readDir(aircraftDialogDir); } @@ -414,12 +414,11 @@ NewGUI::setMenuBarOverlapHide(bool hide) void NewGUI::newDialog (SGPropertyNode* props) { - const char* cname = props->getStringValue("name"); - if(!cname) { + string name = props->getStringValue("name", ""); + if(name.empty()) { SG_LOG(SG_GENERAL, SG_ALERT, "New dialog has no property"); return; } - string name = cname; if(_active_dialogs.find(name) == _active_dialogs.end()) { _dialog_props[name] = props; @@ -566,7 +565,7 @@ NewGUI::setStyle (void) for (int i = 0; i < n->nChildren(); i++) { SGPropertyNode *child = n->getChild(i); - _colors[child->getName()] = new FGColor(child); + _colors[child->getNameString()] = new FGColor(child); } FGColor *c = _colors["background"]; diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 47197b01a..fd700f850 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -189,15 +189,15 @@ protected: private: void createMenuBarImplementation(); - struct ltstr + /*struct ltstr { - bool operator()(const char* s1, const char* s2) const { - return strcmp(s1, s2) < 0; + bool operator()(const std::string& s1, const std::string& s2) const { + return s1 < s2; } - }; + };*/ puFont *_font; - typedef std::map ColourDict; + typedef std::map ColourDict; ColourDict _colors; typedef ColourDict::iterator _itt_t; typedef ColourDict::const_iterator _citt_t; diff --git a/src/GUI/property_list.cxx b/src/GUI/property_list.cxx index 26f8e27f2..7b7dc41c1 100644 --- a/src/GUI/property_list.cxx +++ b/src/GUI/property_list.cxx @@ -86,7 +86,7 @@ static void dumpProperties(const SGPropertyNode *node) continue; int index = c->getIndex(); - cout << std::setw(11) << getValueTypeString(c) << " " << c->getName(); + cout << std::setw(11) << getValueTypeString(c) << " " << c->getNameString(); if (index > 0) cout << '[' << index << ']'; cout << " = "; @@ -409,7 +409,7 @@ int PropertyList::nodeNameCompare(const void *p1, const void *p2) const SGPropertyNode *n1 = (*(const NodeData *)p1).node; const SGPropertyNode *n2 = (*(const NodeData *)p2).node; - int diff = strcmp(n1->getName(), n2->getName()); + int diff = strcmp(n1->getNameString().c_str(), n2->getNameString().c_str()); return diff ? diff : n1->getIndex() - n2->getIndex(); } diff --git a/src/Input/FGCommonInput.cxx b/src/Input/FGCommonInput.cxx index dc8b1a18e..9fe6c0ac1 100644 --- a/src/Input/FGCommonInput.cxx +++ b/src/Input/FGCommonInput.cxx @@ -38,7 +38,7 @@ void FGCommonInput::read_bindings (const SGPropertyNode * node, binding_list_t * PropertyList bindings = node->getChildren("binding"); static string nasal = "nasal"; for (unsigned int i = 0; i < bindings.size(); i++) { - const char *cmd = bindings[i]->getStringValue("command"); + std::string cmd = bindings[i]->getStringValue("command"); if (nasal.compare(cmd) == 0 && !module.empty()) bindings[i]->setStringValue("module", module.c_str()); binding_list[modifiers].push_back(new SGBinding(bindings[i], globals->get_props())); diff --git a/src/Input/FGHIDEventInput.cxx b/src/Input/FGHIDEventInput.cxx index ea5ff5b90..e052cc8d9 100644 --- a/src/Input/FGHIDEventInput.cxx +++ b/src/Input/FGHIDEventInput.cxx @@ -820,12 +820,12 @@ void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode) for (int c=0; c < nChildren; ++c) { const auto nd = reportNode->getChild(c); const int size = nd->getIntValue("size", 1); // default to a single bit - if (!strcmp(nd->getName(), "unused-bits")) { + if (nd->getNameString() == "unused-bits") { bitCount += size; continue; } - if (!strcmp(nd->getName(), "type") || !strcmp(nd->getName(), "id")) { + if (nd->getNameString() == "type" || nd->getNameString() == "id") { continue; // already handled above } diff --git a/src/Input/FGMouseInput.cxx b/src/Input/FGMouseInput.cxx index 6e29df157..928374a37 100644 --- a/src/Input/FGMouseInput.cxx +++ b/src/Input/FGMouseInput.cxx @@ -420,7 +420,7 @@ void FGMouseInput::init() SGPropertyNode * mode_node = mouse_node->getChild("mode", j, true); // Read the mouse cursor for this mode - m.modes[j].cursor = FGMouseCursor::cursorFromString(mode_node->getStringValue("cursor", "inherit")); + m.modes[j].cursor = FGMouseCursor::cursorFromString(mode_node->getStringValue("cursor", "inherit").c_str()); // Read other properties for this mode m.modes[j].constrained = mode_node->getBoolValue("constrained", false); diff --git a/src/Instrumentation/HUD/HUD.cxx b/src/Instrumentation/HUD/HUD.cxx index 404d2aab5..059642efc 100644 --- a/src/Instrumentation/HUD/HUD.cxx +++ b/src/Instrumentation/HUD/HUD.cxx @@ -73,8 +73,8 @@ HUD::Input::Input(const SGPropertyNode *n, float factor, float offset, _coeff = 1.0 - 1.0 / powf(10, fabs(n->getFloatValue("damp", 0.0))); SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false); if (p) { - const char *path = p->getStringValue(); - if (path && path[0]) { + string path = p->getStringValue(); + if (!path.empty()) { _property = fgGetNode(path, true); _valid = true; } @@ -395,52 +395,52 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden for (int i = 0; i < root.nChildren(); i++) { SGPropertyNode *n = root.getChild(i); - const char *d = n->getStringValue("name", 0); + string d = n->getStringValue("name", ""); string desc; - if (d) + if (!d.empty()) desc = string(": \"") + d + '"'; - const char *name = n->getName(); - if (!strcmp(name, "name")) { + const string name = n->getNameString(); + if (name == "name") { continue; - } else if (!strcmp(name, "enable3d")) { + } else if (name == "enable3d") { // set in the tree so that valueChanged() picks it up _3DenabledN->setBoolValue(n->getBoolValue()); continue; - } else if (!strcmp(name, "import")) { - const char *fn = n->getStringValue("path", ""); + } else if (name == "import") { + string fn = n->getStringValue("path", ""); float xoffs = n->getFloatValue("x-offset", 0.0f); float yoffs = n->getFloatValue("y-offset", 0.0f); SG_LOG(SG_INPUT, TREE, indent << "|__import " << fn << desc); string ind = indent + string(i + 1 < root.nChildren() ? "| " : " "); - ret |= load(fn, x + xoffs, y + yoffs, level + 1, ind); + ret |= load(fn.c_str(), x + xoffs, y + yoffs, level + 1, ind); continue; } SG_LOG(SG_INPUT, TREE, indent << "|__" << name << desc); Item *item; - if (!strcmp(name, "label")) { + if (name == "label") { item = static_cast(new Label(this, n, x, y)); - } else if (!strcmp(name, "gauge")) { + } else if (name == "gauge") { item = static_cast(new Gauge(this, n, x, y)); - } else if (!strcmp(name, "tape")) { + } else if (name == "tape") { item = static_cast(new Tape(this, n, x, y)); - } else if (!strcmp(name, "dial")) { + } else if (name == "dial") { item = static_cast(new Dial(this, n, x, y)); - } else if (!strcmp(name, "turn-bank-indicator")) { + } else if (name == "turn-bank-indicator") { item = static_cast(new TurnBankIndicator(this, n, x, y)); - } else if (!strcmp(name, "ladder")) { + } else if (name == "ladder") { item = static_cast(new Ladder(this, n, x, y)); _ladders.insert(_ladders.begin(), item); continue; - } else if (!strcmp(name, "runway")) { + } else if (name == "runway") { item = static_cast(new Runway(this, n, x, y)); - } else if (!strcmp(name, "aiming-reticle")) { + } else if (name == "aiming-reticle") { item = static_cast(new AimingReticle(this, n, x, y)); } else { SG_LOG(SG_INPUT, TREE, indent << " \\...unsupported!"); @@ -466,7 +466,7 @@ void HUD::valueChanged(SGPropertyNode *node) loadNow = true; } - if (!strcmp(node->getName(), "current-path") && _visible) { + if (node->getNameString() == "current-path" && _visible) { loadNow = true; } @@ -483,7 +483,7 @@ void HUD::valueChanged(SGPropertyNode *node) load(path.c_str()); } - if (!strcmp(node->getName(), "current-color")) { + if (node->getNameString() == "current-color") { currentColorChanged(); } @@ -501,7 +501,7 @@ void HUD::valueChanged(SGPropertyNode *node) _a = clamp(_alpha->getFloatValue()); _cl = clamp(_alpha_clamp->getFloatValue()); - _units = strcmp(_unitsN->getStringValue(), "feet") ? METER : FEET; + _units = _unitsN->getStringValue() != "feet" ? METER : FEET; _listener_active = false; } diff --git a/src/Instrumentation/HUD/HUD_instrument.cxx b/src/Instrumentation/HUD/HUD_instrument.cxx index ae0e30e5c..cc45d6e87 100644 --- a/src/Instrumentation/HUD/HUD_instrument.cxx +++ b/src/Instrumentation/HUD/HUD_instrument.cxx @@ -51,24 +51,24 @@ HUD::Item::Item(HUD *hud, const SGPropertyNode *n, float x, float y) : vector opt = n->getChildren("option"); for (unsigned int i = 0; i < opt.size(); i++) { - const char *o = opt[i]->getStringValue(); - if (!strcmp(o, "vertical")) + string o = opt[i]->getStringValue(); + if (o == "vertical") _options |= VERTICAL; - else if (!strcmp(o, "horizontal")) + else if (o == "horizontal") _options |= HORIZONTAL; - else if (!strcmp(o, "top")) + else if (o == "top") _options |= TOP; - else if (!strcmp(o, "left")) + else if (o == "left") _options |= LEFT; - else if (!strcmp(o, "bottom")) + else if (o == "bottom") _options |= BOTTOM; - else if (!strcmp(o, "right")) + else if (o == "right") _options |= RIGHT; - else if (!strcmp(o, "both")) + else if (o == "both") _options |= (LEFT|RIGHT); - else if (!strcmp(o, "noticks")) + else if (o == "noticks") _options |= NOTICKS; - else if (!strcmp(o, "notext")) + else if (o == "notext") _options |= NOTEXT; else SG_LOG(SG_INPUT, SG_WARN, "HUD: unsupported option: " << o); diff --git a/src/Instrumentation/HUD/HUD_label.cxx b/src/Instrumentation/HUD/HUD_label.cxx index 5414cf02f..157c636a1 100644 --- a/src/Instrumentation/HUD/HUD_label.cxx +++ b/src/Instrumentation/HUD/HUD_label.cxx @@ -43,29 +43,29 @@ HUD::Label::Label(HUD *hud, const SGPropertyNode *n, float x, float y) : if (node) _blink_condition = sgReadCondition(globals->get_props(), node); - const char *halign = n->getStringValue("halign", "center"); - if (!strcmp(halign, "left")) + string halign = n->getStringValue("halign", "center"); + if (halign == "left") _halign = LEFT; - else if (!strcmp(halign, "right")) + else if (halign == "right") _halign = RIGHT; else _halign = HCENTER; _halign |= VCENTER; - const char *pre = n->getStringValue("prefix", 0); - const char *post = n->getStringValue("postfix", 0); - const char *fmt = n->getStringValue("format", 0); + string pre = n->getStringValue("prefix", ""); + string post = n->getStringValue("postfix", ""); + string fmt = n->getStringValue("format", ""); - if (pre) + if (!pre.empty()) _format = pre; - if (fmt) + if (!fmt.empty()) _format += fmt; else _format += "%s"; - if (post) + if (!post.empty()) _format += post; _mode = check_format(_format.c_str()); @@ -148,7 +148,7 @@ void HUD::Label::draw(void) if (_mode == NONE) snprintf(buf, BUFSIZE, _format.c_str(), 0); else if (_mode == STRING) - snprintf(buf, BUFSIZE, _format.c_str(), _input.getStringValue()); + snprintf(buf, BUFSIZE, _format.c_str(), _input.getStringValue().c_str()); else if (_mode == INT) snprintf(buf, BUFSIZE, _format.c_str(), int(_input.getFloatValue())); else if (_mode == LONG) diff --git a/src/Instrumentation/HUD/HUD_ladder.cxx b/src/Instrumentation/HUD/HUD_ladder.cxx index 95f20d6c0..74775d0e5 100644 --- a/src/Instrumentation/HUD/HUD_ladder.cxx +++ b/src/Instrumentation/HUD/HUD_ladder.cxx @@ -78,8 +78,8 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) : _hat(n->getBoolValue("enable-hat")), _clip_box(new ClipBox(n->getNode("clipping"))) { - const char *t = n->getStringValue("type"); - _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE; + string t = n->getStringValue("type"); + _type = t != "climb-dive" ? PITCH : CLIMB_DIVE; if (!_width_units) _width_units = 45; @@ -300,7 +300,7 @@ void HUD::Ladder::draw(void) for (int i = 0; i < models->nChildren(); i++) { SGPropertyNode *chld = models->getChild(i); string name; - name = chld->getName(); + name = chld->getNameString(); if (name == "tanker" || name == "aircraft" || name == "multiplayer") { bool valid = chld->getBoolValue("valid"); bool in_range = chld->getBoolValue("radar/in-range", true); diff --git a/src/Instrumentation/HUD/HUD_private.hxx b/src/Instrumentation/HUD/HUD_private.hxx index 46c33c3d7..e4c533aa2 100644 --- a/src/Instrumentation/HUD/HUD_private.hxx +++ b/src/Instrumentation/HUD/HUD_private.hxx @@ -73,7 +73,7 @@ public: return _property->getBoolValue(); } - const char *getStringValue() const { + std::string getStringValue() const { assert(_property); return _property->getStringValue(); } diff --git a/src/Instrumentation/HUD/HUD_tape.cxx b/src/Instrumentation/HUD/HUD_tape.cxx index 56b5b6071..34cfe9549 100644 --- a/src/Instrumentation/HUD/HUD_tape.cxx +++ b/src/Instrumentation/HUD/HUD_tape.cxx @@ -43,15 +43,14 @@ HUD::Tape::Tape(HUD *hud, const SGPropertyNode *n, float x, float y) : { _half_width_units = range_to_show() / 2.0; - const char *s; - s = n->getStringValue("pointer-type"); - _pointer_type = strcmp(s, "moving") ? FIXED : MOVING; // "fixed", "moving" + string s = n->getStringValue("pointer-type"); + _pointer_type = s != "moving" ? FIXED : MOVING; // "fixed", "moving" s = n->getStringValue("tick-type"); - _tick_type = strcmp(s, "bullet") ? LINE : CIRCLE; // "bullet", "line" + _tick_type = s != "bullet" ? LINE : CIRCLE; // "bullet", "line" s = n->getStringValue("tick-length"); // "variable", "constant" - _tick_length = strcmp(s, "constant") ? VARIABLE : CONSTANT; + _tick_length = s != "constant" ? VARIABLE : CONSTANT; _label_fmt = check_format(_format.c_str()); if (_label_fmt != INT && _label_fmt != LONG diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index 97f57e766..70d556d3c 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -280,8 +280,8 @@ void DCLGPS::update(double dt) { // Check if an alarm timer has expired if(_alarmSet) { - if(_alarmTime.hr() == atoi(fgGetString("/instrumentation/clock/indicated-hour")) - && _alarmTime.min() == atoi(fgGetString("/instrumentation/clock/indicated-min"))) { + if(_alarmTime.hr() == atoi(fgGetString("/instrumentation/clock/indicated-hour").c_str()) + && _alarmTime.min() == atoi(fgGetString("/instrumentation/clock/indicated-min").c_str())) { _messageStack.push_back("*Timer Expired"); _alarmSet = false; } @@ -971,8 +971,8 @@ void DCLGPS::SetPowerOnTimer() { } void DCLGPS::ResetPowerOnTimer() { - _powerOnTime.set_hr(atoi(fgGetString("/instrumentation/clock/indicated-hour"))); - _powerOnTime.set_min(atoi(fgGetString("/instrumentation/clock/indicated-min"))); + _powerOnTime.set_hr(atoi(fgGetString("/instrumentation/clock/indicated-hour").c_str())); + _powerOnTime.set_min(atoi(fgGetString("/instrumentation/clock/indicated-min").c_str())); _powerOnTimerSet = true; } diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index 3173d932a..6fc2438c8 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -146,8 +146,8 @@ DME::update (double delta_time_sec) char tmp[16]; // Figure out the source - const char * source = _source_node->getStringValue(); - if (source[0] == '\0') { + string source = _source_node->getStringValue(); + if (source.empty()) { std::string branch; branch = "/instrumentation/" + name() + "/frequencies/selected-mhz"; _source_node->setStringValue(branch.c_str()); diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index 8c37ad941..c16abf217 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -32,7 +32,7 @@ HeadingIndicatorDG::HeadingIndicatorDG ( SGPropertyNode *node ) : int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - std::string cname = child->getName(); + std::string cname = child->getNameString(); std::string cval = child->getStringValue(); if ( cname == "name" ) { name = cval; diff --git a/src/Instrumentation/heading_indicator_fg.cxx b/src/Instrumentation/heading_indicator_fg.cxx index 07aa84754..55c2915e6 100644 --- a/src/Instrumentation/heading_indicator_fg.cxx +++ b/src/Instrumentation/heading_indicator_fg.cxx @@ -31,7 +31,7 @@ HeadingIndicatorFG::HeadingIndicatorFG ( SGPropertyNode *node ) int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); string cval = child->getStringValue(); if ( cname == "name" ) { name = cval; diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 41f0adbff..555813f09 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -111,7 +111,7 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props, const SGPath& path) { for ( int i = 0; i < config_props->nChildren(); ++i ) { SGPropertyNode *node = config_props->getChild(i); - std::string name = node->getName(); + std::string name = node->getNameString(); std::ostringstream subsystemname; subsystemname << "instrument-" << i << '-' diff --git a/src/Instrumentation/mk_viii.cxx b/src/Instrumentation/mk_viii.cxx index efb819095..d439bca38 100644 --- a/src/Instrumentation/mk_viii.cxx +++ b/src/Instrumentation/mk_viii.cxx @@ -1131,7 +1131,7 @@ MK_VIII::IOHandler::update_inputs () { const char *mode; - mode = mk_node(autopilot_heading_lock)->getStringValue(); + mode = mk_node(autopilot_heading_lock)->getStringValue().c_str(); mk_dinput(autopilot_engaged) = mode && *mode; } @@ -4625,7 +4625,7 @@ MK_VIII::MK_VIII (SGPropertyNode *node) for (int i = 0; i < node->nChildren(); ++i) { SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); string cval = child->getStringValue(); if (cname == "name") diff --git a/src/Instrumentation/tacan.cxx b/src/Instrumentation/tacan.cxx index 7993608da..0e946da14 100644 --- a/src/Instrumentation/tacan.cxx +++ b/src/Instrumentation/tacan.cxx @@ -291,7 +291,7 @@ TACAN::valueChanged(SGPropertyNode *prop) int index = prop->getIndex(); std::string channel = _channel; - if (std::string("selected-mhz") == prop->getName()) + if (std::string("selected-mhz") == prop->getNameString()) { FGTACANRecord *rec= globals->get_channellist()->findByFrequency(prop->getDoubleValue()*1000); if (rec != nullptr) { diff --git a/src/Instrumentation/tcas.cxx b/src/Instrumentation/tcas.cxx index 7006011eb..a22629cb8 100644 --- a/src/Instrumentation/tcas.cxx +++ b/src/Instrumentation/tcas.cxx @@ -1184,7 +1184,7 @@ TCAS::TCAS(SGPropertyNode* pNode) : for (int i = 0; i < pNode->nChildren(); ++i) { SGPropertyNode* pChild = pNode->getChild(i); - string cname = pChild->getName(); + string cname = pChild->getNameString(); string cval = pChild->getStringValue(); int cintval = pChild->getIntValue(); diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 86d1a0fb4..30b9ed30c 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -171,7 +171,7 @@ compare_values (SGPropertyNode * value1, SGPropertyNode * value2) case simgear::props::DOUBLE: return (value1->getDoubleValue() == value2->getDoubleValue()); default: - return !strcmp(value1->getStringValue(), value2->getStringValue()); + return value1->getStringValue() == value2->getStringValue(); } } @@ -253,7 +253,7 @@ do_pause (const SGPropertyNode * arg, SGPropertyNode * root) static bool do_load (const SGPropertyNode * arg, SGPropertyNode * root) { - SGPath file(arg->getStringValue("file", "fgfs.sav")); + SGPath file(arg->getStringValue("file", "fgfs.sav").c_str()); if (file.extension() != "sav") file.concat(".sav"); @@ -286,7 +286,7 @@ do_load (const SGPropertyNode * arg, SGPropertyNode * root) static bool do_save (const SGPropertyNode * arg, SGPropertyNode * root) { - SGPath file(arg->getStringValue("file", "fgfs.sav")); + SGPath file(arg->getStringValue("file", "fgfs.sav").c_str()); if (file.extension() != "sav") file.concat(".sav"); @@ -543,7 +543,7 @@ do_property_adjust (const SGPropertyNode * arg, SGPropertyNode * root) * arg->getDoubleValue("offset")); double unmodifiable, modifiable; - split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"), + split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all").c_str(), &unmodifiable, &modifiable); modifiable += amount; limit_value(&modifiable, arg); @@ -575,7 +575,7 @@ do_property_multiply (const SGPropertyNode * arg, SGPropertyNode * root) double factor = arg->getDoubleValue("factor", 1.0); double unmodifiable, modifiable; - split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"), + split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all").c_str(), &unmodifiable, &modifiable); modifiable *= factor; limit_value(&modifiable, arg); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 0432b1bd7..b28e983ff 100755 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -365,7 +365,7 @@ private: vector cache = _cache->getChildren("aircraft"); for (unsigned int i = 0; i < cache.size(); i++) { - const char *name = cache[i]->getStringValue("file", ""); + const std::string name = cache[i]->getStringValue("file", ""); if (!simgear::strutils::iequals(_searchAircraft, name)) { continue; } diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 6218ac571..c03994958 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -624,7 +624,7 @@ fgGetDouble (const char * name, double defaultValue) return globals->get_props()->getDoubleValue(name, defaultValue); } -const char * +std::string fgGetString (const char * name, const char * defaultValue) { return globals->get_props()->getStringValue(name, defaultValue); diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 2ec24f770..0a060d314 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -7,6 +7,7 @@ #define __FG_PROPS_HXX 1 #include +#include #include #include @@ -424,7 +425,7 @@ inline double fgGetDouble (const std::string & name, double defaultValue = 0.0) * does not exist. * @return The property's value as a string, or the default value provided. */ -extern const char * fgGetString (const char * name, +extern std::string fgGetString (const char * name, const char * defaultValue = ""); /** @@ -441,7 +442,7 @@ extern const char * fgGetString (const char * name, * does not exist. * @return The property's value as a string, or the default value provided. */ -inline const char * fgGetString (const std::string & name, +inline std::string fgGetString (const std::string & name, const std::string & defaultValue = std::string("")) { return fgGetString( name.c_str(), defaultValue.c_str() ); @@ -856,9 +857,12 @@ public: if (node->getType() != simgear::props::STRING) return; - char *s = const_cast(node->getStringValue()); - for (; *s; s++) - *s = toupper(*s); + std::string value = node->getStringValue(); + std::string value_orig = value; + std::transform(value.begin(), value.end(), value.begin(), ::toupper); + if (value != value_orig) { + node->setStringValue(value); + } } }; diff --git a/src/Main/fg_scene_commands.cxx b/src/Main/fg_scene_commands.cxx index a1d8c1261..a0d19fdff 100644 --- a/src/Main/fg_scene_commands.cxx +++ b/src/Main/fg_scene_commands.cxx @@ -472,12 +472,12 @@ do_presets_commit (const SGPropertyNode * arg, SGPropertyNode * root) static bool do_press_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root) { - const char *prefix = arg->getStringValue("prefix"); + const string prefix = arg->getStringValue("prefix"); - if (arg->getBoolValue("guarded") && fgGetDouble((string(prefix) + "-guard").c_str()) < 1) + if (arg->getBoolValue("guarded") && fgGetDouble((prefix + "-guard").c_str()) < 1) return true; - string prop = string(prefix) + "-button"; + string prop = prefix + "-button"; double value; if (arg->getBoolValue("latching")) @@ -494,10 +494,10 @@ do_press_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root) static bool do_release_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root) { - const char *prefix = arg->getStringValue("prefix"); + const string prefix = arg->getStringValue("prefix"); if (arg->getBoolValue("guarded")) { - string prop = string(prefix) + "-guard"; + string prop = prefix + "-guard"; if (fgGetDouble(prop.c_str()) < 1) { fgSetDouble(prop.c_str(), 1); return true; @@ -505,7 +505,7 @@ do_release_cockpit_button (const SGPropertyNode * arg, SGPropertyNode * root) } if (! arg->getBoolValue("latching")) { - fgSetDouble((string(prefix) + "-button").c_str(), 0); + fgSetDouble((prefix + "-button").c_str(), 0); fgSetBool(arg->getStringValue("discrete"), false); } diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 70c1ebee0..667904c2f 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -84,7 +84,7 @@ public: } // test against the aircraft-dir property - const char* aircraftDir = fgGetString("/sim/aircraft-dir"); + const std::string aircraftDir = fgGetString("/sim/aircraft-dir"); string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir)); if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) { // current aircraft-dir matches resource aircraft diff --git a/src/Main/locale.cxx b/src/Main/locale.cxx index cadbe20b9..aac1722b0 100644 --- a/src/Main/locale.cxx +++ b/src/Main/locale.cxx @@ -316,8 +316,8 @@ FGLocale::loadResource(SGPropertyNode* localeNode, const char* resource) return true; } - const char* path_str = resourceNode->getStringValue(); - if (!path_str) + string path_str = resourceNode->getStringValue(); + if (path_str.empty()) { SG_LOG(SG_GENERAL, SG_WARN, "No path in " << stringNode->getPath() << "/" << resource << "."); return false; @@ -494,21 +494,21 @@ FGLocale::getLocalizedStrings(const char* id, const char* resource) } // Check for localized font -const char* +std::string FGLocale::getDefaultFont(const char* fallbackFont) { assert(_inited); - const char* font = nullptr; + std::string font; if (_currentLocale) { font = _currentLocale->getStringValue("font", ""); - if (font[0] != 0) + if (!font.empty()) return font; } if (_defaultLocale) { font = _defaultLocale->getStringValue("font", ""); - if (font[0] != 0) + if (!font.empty()) return font; } diff --git a/src/Main/locale.hxx b/src/Main/locale.hxx index e1f386f49..a67d67844 100644 --- a/src/Main/locale.hxx +++ b/src/Main/locale.hxx @@ -96,7 +96,7 @@ public: /** * Obtain default font for current locale. */ - const char* getDefaultFont (const char* fallbackFont); + std::string getDefaultFont (const char* fallbackFont); /** * Obtain a message string, from a localized resource ID, and use it as diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 141819225..3c0708975 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -569,9 +569,9 @@ struct SGLogDeltasListener : SGPropertyChangeListener { void valueChanged(SGPropertyNode* node) override { - const char* value = node->getStringValue(); + std::string value = node->getStringValue(); std::cerr << __FILE__ << ":" << __LINE__ << ": sglogdeltas value=" << value << "\n"; - logDeltaSet(value); + logDeltaSet(value.c_str()); } }; static SGLogDeltasListener s_sglogdeltas_listener; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index c9351a91d..0ee0ae0d7 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -339,17 +339,17 @@ private: } - int getNumMaturity(const char * str) + int getNumMaturity(const std::string& str) { // Changes should also be reflected in $FG_ROOT/options.xml const char* levels[] = {"alpha","beta","early-production","production"}; - if (!strcmp(str, "all")) { + if (str == "all") { return 0; } for (size_t i=0; i<(sizeof(levels)/sizeof(levels[0]));i++) - if (strcmp(str,levels[i])==0) + if (str == levels[i]) return i; return 0; @@ -809,7 +809,7 @@ static int fgOptAltitude( const char *arg ) { fgSetBool("/sim/presets/onground", false); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/altitude-ft", atof( arg )); else fgSetDouble("/sim/presets/altitude-ft", @@ -821,7 +821,7 @@ static int fgOptUBody( const char *arg ) { fgSetString("/sim/presets/speed-set", "UVW"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/uBody-fps", atof( arg )); else fgSetDouble("/sim/presets/uBody-fps", @@ -833,7 +833,7 @@ static int fgOptVBody( const char *arg ) { fgSetString("/sim/presets/speed-set", "UVW"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/vBody-fps", atof( arg )); else fgSetDouble("/sim/presets/vBody-fps", @@ -845,7 +845,7 @@ static int fgOptWBody( const char *arg ) { fgSetString("/sim/presets/speed-set", "UVW"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/wBody-fps", atof(arg)); else fgSetDouble("/sim/presets/wBody-fps", @@ -857,7 +857,7 @@ static int fgOptVNorth( const char *arg ) { fgSetString("/sim/presets/speed-set", "NED"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/speed-north-fps", atof( arg )); else fgSetDouble("/sim/presets/speed-north-fps", @@ -869,7 +869,7 @@ static int fgOptVEast( const char *arg ) { fgSetString("/sim/presets/speed-set", "NED"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/speed-east-fps", atof(arg)); else fgSetDouble("/sim/presets/speed-east-fps", @@ -881,7 +881,7 @@ static int fgOptVDown( const char *arg ) { fgSetString("/sim/presets/speed-set", "NED"); - if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) + if ( fgGetString("/sim/startup/units") == "feet" ) fgSetDouble("/sim/presets/speed-down-fps", atof(arg)); else fgSetDouble("/sim/presets/speed-down-fps", @@ -2416,7 +2416,7 @@ OptionResult Options::initAircraft() } else { SG_LOG(SG_INPUT, SG_INFO, "No user specified aircraft, using default" ); // ensure aircraft-id is valid - fgSetString("/sim/aircraft-id", fgGetString("/sim/aircraft")); + fgSetString("/sim/aircraft-id", fgGetString("/sim/aircraft").c_str()); } if (p->showAircraft) { diff --git a/src/Main/subsystemFactory.cxx b/src/Main/subsystemFactory.cxx index 78baa5d9d..997a181d8 100644 --- a/src/Main/subsystemFactory.cxx +++ b/src/Main/subsystemFactory.cxx @@ -242,8 +242,8 @@ do_reinit (const SGPropertyNode * arg, SGPropertyNode * root) globals->get_subsystem_mgr()->reinit(); } else { for ( unsigned int i = 0; i < subsystems.size(); i++ ) { - const char * name = subsystems[i]->getStringValue(); - SGSubsystem * subsystem = globals->get_subsystem(name); + std::string name = subsystems[i]->getStringValue(); + SGSubsystem * subsystem = globals->get_subsystem(name.c_str()); if (subsystem == 0) { result = false; SG_LOG( SG_GENERAL, SG_ALERT, @@ -271,8 +271,8 @@ do_suspend (const SGPropertyNode * arg, SGPropertyNode * root) vector subsystems = arg->getChildren("subsystem"); for ( unsigned int i = 0; i < subsystems.size(); i++ ) { - const char * name = subsystems[i]->getStringValue(); - SGSubsystem * subsystem = globals->get_subsystem(name); + std::string name = subsystems[i]->getStringValue(); + SGSubsystem * subsystem = globals->get_subsystem(name.c_str()); if (subsystem == 0) { result = false; SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << " not found"); @@ -295,8 +295,8 @@ do_resume (const SGPropertyNode * arg, SGPropertyNode * root) vector subsystems = arg->getChildren("subsystem"); for ( unsigned int i = 0; i < subsystems.size(); i++ ) { - const char * name = subsystems[i]->getStringValue(); - SGSubsystem * subsystem = globals->get_subsystem(name); + std::string name = subsystems[i]->getStringValue(); + SGSubsystem * subsystem = globals->get_subsystem(name.c_str()); if (subsystem == 0) { result = false; SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << " not found"); diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index d0b790cf3..3a4d3599c 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -263,8 +263,7 @@ void FGModelMgr::update(double dt) if (instance->heading_deg_node != 0) heading = testNan(instance->heading_deg_node->getDoubleValue()); } catch (const sg_range_exception&) { - const char *path = instance->node->getStringValue("path", - "unknown"); + string path = instance->node->getStringValue("path", "unknown"); SG_LOG(SG_AIRCRAFT, SG_INFO, "Instance of model " << path << " has invalid values"); return; @@ -359,7 +358,7 @@ bool FGModelMgr::Instance::checkLoaded() const void FGModelMgr::Listener::childAdded(SGPropertyNode * parent, SGPropertyNode * child) { - if (strcmp(parent->getName(), "model") || strcmp(child->getName(), "load")) + if (parent->getNameString() != "model" || child->getNameString() != "load") return; _mgr->add_model(parent); @@ -368,7 +367,7 @@ FGModelMgr::Listener::childAdded(SGPropertyNode * parent, SGPropertyNode * child void FGModelMgr::Listener::childRemoved(SGPropertyNode * parent, SGPropertyNode * child) { - if (strcmp(parent->getName(), "models") || strcmp(child->getName(), "model")) + if (parent->getNameString() != "models" || child->getNameString() != "model") return; // search instance by node and remove it from scenegraph diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index fcaa3c792..a9c480567 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -1378,7 +1378,7 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo) else PosMsg->pad = 0; - strncpy(PosMsg->Model, fgGetString("/sim/model/path"), MAX_MODEL_NAME_LEN); + strncpy(PosMsg->Model, fgGetString("/sim/model/path").c_str(), MAX_MODEL_NAME_LEN); PosMsg->Model[MAX_MODEL_NAME_LEN - 1] = '\0'; if (fgGetBool("/sim/freeze/replay-state", true)&& fgGetBool("/sim/multiplay/freeze-on-replay",true)) @@ -2163,13 +2163,13 @@ void FGMultiplayMgr::Send(double mpTime) { // FIXME: We assume unspecified are strings for the moment. - const char* cstr = it->second->getStringValue(); - int len = strlen(cstr); + string cstr = it->second->getStringValue(); + size_t len = cstr.length(); if (len > 0) { pData->string_value = new char[len + 1]; - strcpy(pData->string_value, cstr); + strcpy(pData->string_value, cstr.c_str()); } else { @@ -2487,8 +2487,8 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg, // --test-motion-mp. // { - const char* callsign = pLogRawSpeedMultiplayer->getStringValue(); - if (callsign && callsign[0] && !strcmp(callsign, MsgHdr->Callsign)) { + string callsign = pLogRawSpeedMultiplayer->getStringValue(); + if (!callsign.empty() && callsign == string(MsgHdr->Callsign)) { static SGVec3d s_pos_prev; static double s_simtime_prev = -1; SGVec3d pos = motionInfo.position; @@ -2753,7 +2753,7 @@ FGMultiplayMgr::addMultiplayer(const std::string& callsign, int config_children_n = config->nChildren(); for (int i=0; igetChild(i); - global_config->setDoubleValue(node->getName(), node->getDoubleValue()); + global_config->setDoubleValue(node->getNameString(), node->getDoubleValue()); } } } diff --git a/src/Navaids/route.cxx b/src/Navaids/route.cxx index ea2686d66..d3331d48f 100644 --- a/src/Navaids/route.cxx +++ b/src/Navaids/route.cxx @@ -385,7 +385,7 @@ WayptRef Waypt::createFromString(RouteBase* aOwner, const std::string& s, const if (pos != string::npos) { altFt = std::stof(target.substr(pos + 1)); target = target.substr(0, pos); - if (!strcmp(fgGetString("/sim/startup/units"), "meter")) { + if (fgGetString("/sim/startup/units") == "meter") { altFt *= SG_METER_TO_FEET; } altSetting = RESTRICT_AT; @@ -487,12 +487,12 @@ bool Waypt::initFromProperties(SGPropertyNode_ptr aProp) } if (aProp->hasChild("alt-restrict")) { - _altRestrict = restrictionFromString(aProp->getStringValue("alt-restrict")); + _altRestrict = restrictionFromString(aProp->getStringValue("alt-restrict").c_str()); _altitudeFt = aProp->getDoubleValue("altitude-ft"); } if (aProp->hasChild("speed-restrict")) { - _speedRestrict = restrictionFromString(aProp->getStringValue("speed-restrict")); + _speedRestrict = restrictionFromString(aProp->getStringValue("speed-restrict").c_str()); _speed = aProp->getDoubleValue("speed"); } diff --git a/src/Network/ATC-Inputs.cxx b/src/Network/ATC-Inputs.cxx index 2d025dc15..d5e2bfb0b 100644 --- a/src/Network/ATC-Inputs.cxx +++ b/src/Network/ATC-Inputs.cxx @@ -407,7 +407,7 @@ bool FGATCInput::do_analog_in() { // read the next config entry from the property tree SGPropertyNode *child = analog_in_node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); int index = child->getIndex(); string name = ""; string type = ""; @@ -680,7 +680,7 @@ bool FGATCInput::do_switches() { // read the next config entry from the property tree SGPropertyNode *child = switches_node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); string name = ""; string type = ""; vector output_nodes; @@ -881,7 +881,7 @@ bool FGATCInput::do_radio_switches() { // read the next config entry from the property tree SGPropertyNode *child = radio_in_node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); if ( cname == "switch" ) { string name = ""; diff --git a/src/Network/ATC-Outputs.cxx b/src/Network/ATC-Outputs.cxx index 4777d9844..9ef255535 100644 --- a/src/Network/ATC-Outputs.cxx +++ b/src/Network/ATC-Outputs.cxx @@ -441,7 +441,7 @@ bool FGATCOutput::do_analog_out() { // read the next config entry from the property tree SGPropertyNode *child = analog_out_node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); int index = child->getIndex(); string name = ""; string type = ""; @@ -510,7 +510,7 @@ bool FGATCOutput::do_lamps() { // read the next config entry from the property tree SGPropertyNode *child = lamps_out_node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); int index = child->getIndex(); string name = ""; string type = ""; diff --git a/src/Network/fgcom.cxx b/src/Network/fgcom.cxx index 22b66b8ba..2cf67e871 100644 --- a/src/Network/fgcom.cxx +++ b/src/Network/fgcom.cxx @@ -245,7 +245,7 @@ void FGCom::postinit() std::string app = "FGFS-"; app += _version_node->getStringValue(); - iaxc_set_callerid( _callsign_node->getStringValue(), app.c_str() ); + iaxc_set_callerid( _callsign_node->getStringValue().c_str(), app.c_str() ); iaxc_set_formats (IAXC_FORMAT_SPEEX, IAXC_FORMAT_ULAW|IAXC_FORMAT_SPEEX); iaxc_set_speex_settings(1, 5, 0, 1, 0, 3); iaxc_set_filters(IAXC_FILTER_AGC | IAXC_FILTER_DENOISE); diff --git a/src/Network/flarm.cxx b/src/Network/flarm.cxx index 07541b58a..5be873957 100644 --- a/src/Network/flarm.cxx +++ b/src/Network/flarm.cxx @@ -393,7 +393,7 @@ void FGFlarm::parse_message(const std::vector& tokens) { // reply with config data snprintf( nmea, 256, "$PFLAC,A,%s,%s", - keyword.c_str(), configNode->getStringValue()); + keyword.c_str(), configNode->getStringValue().c_str()); add_with_checksum(nmea, 256); Error = false; } @@ -447,7 +447,7 @@ void FGFlarm::parse_message(const std::vector& tokens) // reply snprintf( nmea, 256, "$PFLAC,A,%s,%s", - keyword.c_str(), configNode->getStringValue()); + keyword.c_str(), configNode->getStringValue().c_str()); add_with_checksum(nmea, 256); } } diff --git a/src/Network/generic.cxx b/src/Network/generic.cxx index de2a3c494..eeed1b2c0 100644 --- a/src/Network/generic.cxx +++ b/src/Network/generic.cxx @@ -357,8 +357,8 @@ bool FGGeneric::gen_message_binary() { } default: // SG_STRING - const char *strdata = _out_message[i].prop->getStringValue(); - int32_t strlength = strlen(strdata); + string strdata = _out_message[i].prop->getStringValue(); + size_t strlength = strdata.length(); if (binary_byte_order == BYTE_ORDER_NEEDS_CONVERSION) { SG_LOG( SG_IO, SG_ALERT, "Generic protocol: " @@ -372,7 +372,7 @@ bool FGGeneric::gen_message_binary() { } memcpy(&buf[length], &strlength, sizeof(int32_t)); length += sizeof(int32_t); - strncpy(&buf[length], strdata, strlength); + strncpy(&buf[length], strdata.c_str(), strlength); length += strlength; /* FIXME padding for alignment? Something like: * length += (strlength % 4 > 0 ? sizeof(int32_t) - strlength % 4 : 0; @@ -455,7 +455,7 @@ bool FGGeneric::gen_message_ascii() { default: // SG_STRING snprintf(tmp, 255, format.c_str(), - _out_message[i].prop->getStringValue()); + _out_message[i].prop->getStringValue().c_str()); } generic_sentence += tmp; diff --git a/src/Network/http/FlightHistoryUriHandler.hxx b/src/Network/http/FlightHistoryUriHandler.hxx index 9c17829a4..b6643c0c0 100644 --- a/src/Network/http/FlightHistoryUriHandler.hxx +++ b/src/Network/http/FlightHistoryUriHandler.hxx @@ -29,7 +29,7 @@ namespace http { class FlightHistoryUriHandler : public URIHandler { public: - FlightHistoryUriHandler( const char * uri = "/flighthistory/" ) : URIHandler( uri ) {} + FlightHistoryUriHandler( const std::string& uri = "/flighthistory/" ) : URIHandler( uri ) {} virtual bool handleRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); private: }; diff --git a/src/Network/http/JsonUriHandler.hxx b/src/Network/http/JsonUriHandler.hxx index c7922755b..b0a777311 100644 --- a/src/Network/http/JsonUriHandler.hxx +++ b/src/Network/http/JsonUriHandler.hxx @@ -29,7 +29,7 @@ namespace http { class JsonUriHandler : public URIHandler { public: - JsonUriHandler( const char * uri = "/json/" ) : URIHandler( uri ) {} + JsonUriHandler( const std::string& uri = "/json/" ) : URIHandler( uri ) {} virtual bool handleRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); private: SGPropertyNode_ptr getRequestedNode(const HTTPRequest & request); diff --git a/src/Network/http/NavdbUriHandler.hxx b/src/Network/http/NavdbUriHandler.hxx index 40f6f71ce..d9be895a3 100644 --- a/src/Network/http/NavdbUriHandler.hxx +++ b/src/Network/http/NavdbUriHandler.hxx @@ -28,7 +28,7 @@ namespace http { class NavdbUriHandler : public URIHandler { public: - NavdbUriHandler( const char * uri = "/navdb" ) : URIHandler( uri ) {} + NavdbUriHandler( const std::string& uri = "/navdb" ) : URIHandler( uri ) {} virtual bool handleRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); }; diff --git a/src/Network/http/PkgUriHandler.hxx b/src/Network/http/PkgUriHandler.hxx index 05d58be8c..783aec419 100644 --- a/src/Network/http/PkgUriHandler.hxx +++ b/src/Network/http/PkgUriHandler.hxx @@ -29,7 +29,7 @@ namespace http { class PkgUriHandler : public URIHandler { public: - PkgUriHandler( const char * uri = "/pkg/" ) : URIHandler( uri ) {} + PkgUriHandler( const std::string& uri = "/pkg/" ) : URIHandler( uri ) {} virtual bool handleRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); private: }; diff --git a/src/Network/http/PropertyUriHandler.cxx b/src/Network/http/PropertyUriHandler.cxx index 278de44d7..232611c39 100644 --- a/src/Network/http/PropertyUriHandler.cxx +++ b/src/Network/http/PropertyUriHandler.cxx @@ -74,7 +74,7 @@ private: class CompareNodes { public: bool operator() (const SGPropertyNode *a, const SGPropertyNode *b) const { - int r = strcmp(a->getName(), b->getName()); + int r = strcmp(a->getNameString().c_str(), b->getNameString().c_str()); return r ? r < 0 : a->getIndex() < b->getIndex(); } }; diff --git a/src/Network/http/PropertyUriHandler.hxx b/src/Network/http/PropertyUriHandler.hxx index 6faa15995..42f5f2416 100644 --- a/src/Network/http/PropertyUriHandler.hxx +++ b/src/Network/http/PropertyUriHandler.hxx @@ -28,7 +28,7 @@ namespace http { class PropertyUriHandler : public URIHandler { public: - PropertyUriHandler( const char * uri = "/prop/" ) : URIHandler( uri ) {} + PropertyUriHandler( const std::string& uri = "/prop/" ) : URIHandler( uri ) {} virtual bool handleGetRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); }; diff --git a/src/Network/http/RunUriHandler.hxx b/src/Network/http/RunUriHandler.hxx index ccc12a106..b937c241a 100644 --- a/src/Network/http/RunUriHandler.hxx +++ b/src/Network/http/RunUriHandler.hxx @@ -28,7 +28,7 @@ namespace http { class RunUriHandler : public URIHandler { public: - RunUriHandler( const char * uri = "/run.cgi" ) : URIHandler( uri ) {} + RunUriHandler( const std::string& uri = "/run.cgi" ) : URIHandler( uri ) {} virtual bool handleRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); }; diff --git a/src/Network/http/ScreenshotUriHandler.cxx b/src/Network/http/ScreenshotUriHandler.cxx index 312169144..943957c7a 100644 --- a/src/Network/http/ScreenshotUriHandler.cxx +++ b/src/Network/http/ScreenshotUriHandler.cxx @@ -360,8 +360,8 @@ public: SGConstPropertyNode_ptr canvasnode = canvas->getProps(); if (canvasnode) { - const char *canvasname = canvasnode->getStringValue("name"); - if (canvasname) { + string canvasname = canvasnode->getStringValue("name"); + if (!canvasname.empty()) { SG_LOG(SG_NETWORK, SG_INFO, "CanvasImageRequest: node=" << canvasnode->getDisplayName().c_str() << ", canvasname =" << canvasname); } } @@ -436,7 +436,7 @@ private: string _compressedData; }; -ScreenshotUriHandler::ScreenshotUriHandler(const char * uri) +ScreenshotUriHandler::ScreenshotUriHandler(const std::string& uri) : URIHandler(uri) { } diff --git a/src/Network/http/ScreenshotUriHandler.hxx b/src/Network/http/ScreenshotUriHandler.hxx index 858a32861..f73386e7c 100644 --- a/src/Network/http/ScreenshotUriHandler.hxx +++ b/src/Network/http/ScreenshotUriHandler.hxx @@ -28,7 +28,7 @@ namespace http { class ScreenshotUriHandler : public URIHandler { public: - ScreenshotUriHandler( const char * uri = "/screenshot/" ); + ScreenshotUriHandler( const std::string& uri = "/screenshot/" ); ~ScreenshotUriHandler(); virtual bool handleGetRequest( const HTTPRequest & request, HTTPResponse & response, Connection * connection ); virtual bool poll( Connection * connection ); diff --git a/src/Network/http/httpd.cxx b/src/Network/http/httpd.cxx index 05d9511c1..72b612a5c 100644 --- a/src/Network/http/httpd.cxx +++ b/src/Network/http/httpd.cxx @@ -442,39 +442,39 @@ void MongooseHttpd::init() { SGPropertyNode_ptr n = _configNode->getNode("uri-handler"); if (n.valid()) { - const char * uri; + string uri; - if ((uri = n->getStringValue("screenshot"))[0] != 0) { + if (!(uri = n->getStringValue("screenshot")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding screenshot uri handler at " << uri); _uriHandler.push_back(new flightgear::http::ScreenshotUriHandler(uri)); } - if ((uri = n->getStringValue("property"))[0] != 0) { + if (!(uri = n->getStringValue("property")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding property uri handler at " << uri); _uriHandler.push_back(new flightgear::http::PropertyUriHandler(uri)); } - if ((uri = n->getStringValue("json"))[0] != 0) { + if (!(uri = n->getStringValue("json")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding json uri handler at " << uri); _uriHandler.push_back(new flightgear::http::JsonUriHandler(uri)); } - if ((uri = n->getStringValue("pkg"))[0] != 0) { + if (!(uri = n->getStringValue("pkg")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding pkg uri handler at " << uri); _uriHandler.push_back(new flightgear::http::PkgUriHandler(uri)); } - if ((uri = n->getStringValue("flighthistory"))[0] != 0) { + if (!(uri = n->getStringValue("flighthistory")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding flighthistory uri handler at " << uri); _uriHandler.push_back(new flightgear::http::FlightHistoryUriHandler(uri)); } - if ((uri = n->getStringValue("run"))[0] != 0) { + if (!(uri = n->getStringValue("run")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding run uri handler at " << uri); _uriHandler.push_back(new flightgear::http::RunUriHandler(uri)); } - if ((uri = n->getStringValue("navdb"))[0] != 0) { + if (!(uri = n->getStringValue("navdb")).empty()) { SG_LOG(SG_NETWORK, SG_INFO, "httpd: adding navdb uri handler at " << uri); _uriHandler.push_back(new flightgear::http::NavdbUriHandler(uri)); } @@ -491,7 +491,7 @@ void MongooseHttpd::init() mg_set_option(_server, "document_root", docRoot.c_str()); - mg_set_option(_server, "listening_port", n->getStringValue("listening-port", "8080")); + mg_set_option(_server, "listening_port", n->getStringValue("listening-port", "8080").c_str()); { // build url rewrites relative to fg-root string rewrites = n->getStringValue("url-rewrites", ""); @@ -520,11 +520,11 @@ void MongooseHttpd::init() } if (!rewrites.empty()) mg_set_option(_server, "url_rewrites", rewrites.c_str()); } - mg_set_option(_server, "enable_directory_listing", n->getStringValue("enable-directory-listing", "yes")); - mg_set_option(_server, "idle_timeout_ms", n->getStringValue("idle-timeout-ms", "30000")); - mg_set_option(_server, "index_files", n->getStringValue("index-files", "index.html")); - mg_set_option(_server, "extra_mime_types", n->getStringValue("extra-mime-types", "")); - mg_set_option(_server, "access_log_file", n->getStringValue("access-log-file", "")); + mg_set_option(_server, "enable_directory_listing", n->getStringValue("enable-directory-listing", "yes").c_str()); + mg_set_option(_server, "idle_timeout_ms", n->getStringValue("idle-timeout-ms", "30000").c_str()); + mg_set_option(_server, "index_files", n->getStringValue("index-files", "index.html").c_str()); + mg_set_option(_server, "extra_mime_types", n->getStringValue("extra-mime-types", "").c_str()); + mg_set_option(_server, "access_log_file", n->getStringValue("access-log-file", "").c_str()); SG_LOG(SG_NETWORK,SG_INFO,"starting mongoose with these options: "); const char ** optionNames = mg_get_valid_option_names(); diff --git a/src/Network/http/jsonprops.cxx b/src/Network/http/jsonprops.cxx index e1e3fa4a4..d601e83e0 100644 --- a/src/Network/http/jsonprops.cxx +++ b/src/Network/http/jsonprops.cxx @@ -87,7 +87,7 @@ cJSON * JSON::valueToJson(SGPropertyNode_ptr n) } default: - return cJSON_CreateString(n->getStringValue()); + return cJSON_CreateString(n->getStringValue().c_str()); } } @@ -96,7 +96,7 @@ cJSON * JSON::toJson(SGPropertyNode_ptr n, int depth, double timestamp ) { cJSON * json = cJSON_CreateObject(); cJSON_AddItemToObject(json, "path", cJSON_CreateString(n->getPath(true).c_str())); - cJSON_AddItemToObject(json, "name", cJSON_CreateString(n->getName())); + cJSON_AddItemToObject(json, "name", cJSON_CreateString(n->getNameString().c_str())); if( n->hasValue() ) { switch( n->getType() ) { case simgear::props::BOOL: @@ -111,7 +111,7 @@ cJSON * JSON::toJson(SGPropertyNode_ptr n, int depth, double timestamp ) break; } default: - cJSON_AddItemToObject(json, "value", cJSON_CreateString(n->getStringValue())); + cJSON_AddItemToObject(json, "value", cJSON_CreateString(n->getStringValue().c_str())); break; } } diff --git a/src/Network/http/urihandler.hxx b/src/Network/http/urihandler.hxx index 1072e90e7..ad4ffe48f 100644 --- a/src/Network/http/urihandler.hxx +++ b/src/Network/http/urihandler.hxx @@ -63,7 +63,7 @@ private: */ class URIHandler : public SGReferenced { public: - URIHandler( const char * uri ) : _uri(uri) {} + URIHandler( const std::string& uri ) : _uri(uri) {} virtual ~URIHandler() {} /** diff --git a/src/Network/igc.cxx b/src/Network/igc.cxx index 1a827e196..0c5b9d5dc 100644 --- a/src/Network/igc.cxx +++ b/src/Network/igc.cxx @@ -49,8 +49,8 @@ IGCProtocol::~IGCProtocol() // generate IGC header records bool IGCProtocol::gen_Hrecords() { - const char* AircraftType = fgGetString("/sim/aircraft", "unknown");; - const char* Callsign = fgGetString("/sim/multiplay/callsign", ""); + const std::string AircraftType = fgGetString("/sim/aircraft", "unknown"); + const std::string Callsign = fgGetString("/sim/multiplay/callsign", ""); SGTime *t = globals->get_time_params(); int Day = t->getGmt()->tm_mday; @@ -74,8 +74,8 @@ bool IGCProtocol::gen_Hrecords() "HFRHWHardwareVersion:FlightGear Flight Simulator\r\n" // "hardware" version "HFFTYFRType:Flight Simulator\r\n", // logger type Day, Month, Year, - AircraftType, - Callsign, + AircraftType.c_str(), + Callsign.c_str(), Version); SGIOChannel *io = get_io_channel(); io->write(buf, length); diff --git a/src/Scripting/NasalModelData.cxx b/src/Scripting/NasalModelData.cxx index b476e2a82..8bde3eb3b 100644 --- a/src/Scripting/NasalModelData.cxx +++ b/src/Scripting/NasalModelData.cxx @@ -113,7 +113,7 @@ void FGNasalModelData::load() SG_LOG(SG_NASAL, SG_DEBUG, "Loading nasal module " << _module.c_str()); - const char *s = _load ? _load->getStringValue() : ""; + const string s = _load ? _load->getStringValue() : ""; FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal"); // Add _module_id to script local hash to allow placing canvasses on objects @@ -128,7 +128,7 @@ void FGNasalModelData::load() naRef arg[2]; arg[0] = nasalSys->propNodeGhost(_root); arg[1] = nasalSys->propNodeGhost(_prop); - nasalSys->createModule(_module.c_str(), _path.c_str(), s, strlen(s), + nasalSys->createModule(_module.c_str(), _path.c_str(), s.c_str(), s.length(), _root, 2, arg); } @@ -149,8 +149,8 @@ void FGNasalModelData::unload() if (_unload) { - const char *s = _unload->getStringValue(); - nasalSys->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _root); + const string s = _unload->getStringValue(); + nasalSys->createModule(_module.c_str(), _module.c_str(), s.c_str(), s.length(), _root); } nasalSys->deleteModule(_module.c_str()); diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 9b014d465..a6a9725ee 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -464,8 +464,8 @@ static naRef f_getprop(naContext c, naRef me, int argc, naRef* args) case props::UNSPECIFIED: { naRef nastr = naNewString(c); - const char* val = p->getStringValue(); - naStr_fromdata(nastr, (char*)val, strlen(val)); + std::string val = p->getStringValue(); + naStr_fromdata(nastr, val.c_str(), val.length()); return nastr; } case props::ALIAS: // <--- FIXME, recurse? @@ -1370,7 +1370,7 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n) { bool is_loaded = false; - const char* module = n->getName(); + std::string module = n->getNameString(); if(n->hasChild("module")) module = n->getStringValue("module"); if (n->getBoolValue("enabled",true)) @@ -1383,7 +1383,7 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n) bool ok=true; while((fn = n->getChild("file", j)) != NULL) { file_specified = true; - const char* file = fn->getStringValue(); + std::string file = fn->getStringValue(); SGPath p(file); if (!p.isAbsolute() || !p.exists()) { @@ -1396,16 +1396,16 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n) string{"Missing nasal file for module:"} + module, sg_location{file}); } } - ok &= p.isNull() ? false : loadModule(p, module); + ok &= p.isNull() ? false : loadModule(p, module.c_str()); j++; } - const char* src = n->getStringValue("script"); - if(!n->hasChild("script")) src = 0; // Hrm... - if(src) - createModule(module, n->getPath().c_str(), src, strlen(src)); + std::string src = n->getStringValue("script"); + if(!n->hasChild("script")) src = ""; // Hrm... + if(!src.empty()) + createModule(module.c_str(), n->getPath().c_str(), src.c_str(), src.length()); - if(!file_specified && !src) + if(!file_specified && src.empty()) { // module no longer exists - clear the archived "enable" flag n->setAttribute(SGPropertyNode::USERARCHIVE,false); @@ -1640,12 +1640,12 @@ bool FGNasalSys::handleCommand( const char* moduleName, bool FGNasalSys::handleCommand(const SGPropertyNode * arg, SGPropertyNode * root) { - const char* src = arg->getStringValue("script"); - const char* moduleName = arg->getStringValue("module"); + std::string src = arg->getStringValue("script"); + std::string moduleName = arg->getStringValue("module"); - return handleCommand( moduleName, + return handleCommand( moduleName.c_str(), arg->getPath(true).c_str(), - src, + src.c_str(), arg, root); } diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index 373cb7f86..592a9e80f 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -255,7 +255,7 @@ static naRef f_setAttribute(naContext c, naRef me, int argc, naRef* args) static naRef f_getName(naContext c, naRef me, int argc, naRef* args) { NODENOARG(); - return NASTR(node->getName()); + return NASTR(node->getNameString().c_str()); } @@ -321,7 +321,7 @@ static naRef f_getValue(naContext c, naRef me, int argc, naRef* args) case props::STRING: case props::UNSPECIFIED: - return NASTR(node->getStringValue()); + return NASTR(node->getStringValue().c_str()); case props::VEC3D: return makeVectorFromVec(c, node->getValue()); case props::VEC4D: diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index dd209950f..df33d60f0 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -128,7 +128,7 @@ FGFX::init() "File not found: '" << path_str); return; } - SG_LOG(SG_SOUND, SG_INFO, "Reading sound " << node->getName() + SG_LOG(SG_SOUND, SG_INFO, "Reading sound " << node->getNameString() << " from " << path); SGPropertyNode root; diff --git a/src/Sound/soundmanager.cxx b/src/Sound/soundmanager.cxx index c96909adb..b164df761 100644 --- a/src/Sound/soundmanager.cxx +++ b/src/Sound/soundmanager.cxx @@ -119,7 +119,7 @@ void FGSoundManager::reinit() update_device_list(); - select_device(_device_name->getStringValue()); + select_device(_device_name->getStringValue().c_str()); SGSoundMgr::reinit(); _is_initialized = true; @@ -207,8 +207,8 @@ void FGSoundManager::update(double dt) */ bool FGSoundManager::playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root) { - const char *qname = arg->getStringValue("queue"); - string name = qname ? qname : "chatter"; + string qname = arg->getStringValue("queue", ""); + string name = !qname.empty() ? qname : "chatter"; string path = arg->getStringValue("path"); string file = arg->getStringValue("file"); float volume = arg->getFloatValue("volume"); diff --git a/src/Systems/electrical.cxx b/src/Systems/electrical.cxx index c105ab4a2..60781dbd0 100644 --- a/src/Systems/electrical.cxx +++ b/src/Systems/electrical.cxx @@ -90,7 +90,7 @@ FGElectricalSupplier::FGElectricalSupplier ( SGPropertyNode *node ) { for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); // cout << " scanning: " << child->getName() << endl; - if ( !strcmp(child->getName(), "prop") ) { + if ( child->getNameString() == "prop" ) { string prop = child->getStringValue(); // cout << " Adding prop = " << prop << endl; add_prop( prop ); @@ -209,7 +209,7 @@ FGElectricalBus::FGElectricalBus ( SGPropertyNode *node ) { int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - if ( !strcmp(child->getName(), "prop") ) { + if ( child->getNameString() == "prop" ) { string prop = child->getStringValue(); add_prop( prop ); } @@ -231,7 +231,7 @@ FGElectricalOutput::FGElectricalOutput ( SGPropertyNode *node ) { int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - if ( !strcmp(child->getName(), "prop") ) { + if ( child->getNameString() == "prop" ) { string prop = child->getStringValue(); add_prop( prop ); } @@ -248,7 +248,7 @@ FGElectricalSwitch::FGElectricalSwitch( SGPropertyNode *node ) : int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); string cval = child->getStringValue(); if ( cname == "prop" ) { switch_node = fgGetNode( cval.c_str(), true ); @@ -277,7 +277,7 @@ FGElectricalConnector::FGElectricalConnector ( SGPropertyNode *node, int i; for ( i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); + string cname = child->getNameString(); string cval = child->getStringValue(); // cout << " " << cname << " = " << cval << endl; if ( cname == "input" ) { @@ -600,7 +600,7 @@ bool FGElectricalSystem::build (SGPropertyNode* config_props) { int count = config_props->nChildren(); for ( i = 0; i < count; ++i ) { node = config_props->getChild(i); - string name = node->getName(); + string name = node->getNameString(); // cout << name << endl; if ( name == "supplier" ) { FGElectricalSupplier *s = diff --git a/src/Systems/system_mgr.cxx b/src/Systems/system_mgr.cxx index 954137a17..c9b5b57a4 100644 --- a/src/Systems/system_mgr.cxx +++ b/src/Systems/system_mgr.cxx @@ -73,7 +73,7 @@ bool FGSystemMgr::build (SGPropertyNode* config_props) int count = config_props->nChildren(); for ( i = 0; i < count; ++i ) { node = config_props->getChild(i); - string name = node->getName(); + string name = node->getNameString(); std::ostringstream temp; temp << i; if ( name == "electrical" ) { diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index 49b479479..e3e3c3314 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -22,7 +22,7 @@ VacuumSystem::VacuumSystem ( SGPropertyNode *node ) { for ( int i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - if (!strcmp(child->getName(), "rpm")) + if (child->getNameString() == "rpm") _rpms.push_back(child->getStringValue()); } } diff --git a/src/Time/TimeManager.cxx b/src/Time/TimeManager.cxx index 39c5337b7..7de9a33da 100644 --- a/src/Time/TimeManager.cxx +++ b/src/Time/TimeManager.cxx @@ -581,13 +581,13 @@ void TimeManager::updateLocalTimeString() aircraftLocalTime->tm_min, aircraftLocalTime->tm_sec); // check against current string to avoid changes all the time - const char* s = _localTimeStringNode->getStringValue(); - if (strcmp(s, buf) != 0) { + string s = _localTimeStringNode->getStringValue(); + if (s != string(buf)) { _localTimeStringNode->setStringValue(buf); } - const char* zs = _localTimeZoneNode->getStringValue(); - if (strcmp(zs, _impl->get_description()) != 0) { + string zs = _localTimeZoneNode->getStringValue(); + if (zs != string(_impl->get_description())) { _localTimeZoneNode->setStringValue(_impl->get_description()); } } diff --git a/src/Viewer/CameraGroup.cxx b/src/Viewer/CameraGroup.cxx index 2d31ebe71..e7de0602b 100644 --- a/src/Viewer/CameraGroup.cxx +++ b/src/Viewer/CameraGroup.cxx @@ -151,9 +151,9 @@ public: } virtual void valueChanged(SGPropertyNode* prop) { - if (!strcmp(prop->getName(), "znear")) { + if (prop->getNameString() == "znear") { _cameraGroup->_zNear = prop->getFloatValue(); - } else if (!strcmp(prop->getName(), "zfar")) { + } else if (prop->getNameString() == "zfar") { _cameraGroup->_zFar = prop->getFloatValue(); } } @@ -869,12 +869,12 @@ CameraGroup* CameraGroup::buildCameraGroup(osgViewer::View* view, for (int i = 0; i < gnode->nChildren(); ++i) { SGPropertyNode* pNode = gnode->getChild(i); - const char* name = pNode->getName(); - if (!strcmp(name, "camera")) { + std::string name = pNode->getNameString(); + if (name == "camera") { cgroup->buildCamera(pNode); - } else if (!strcmp(name, "window")) { + } else if (name == "window") { WindowBuilder::getWindowBuilder()->buildWindow(pNode); - } else if (!strcmp(name, "gui")) { + } else if (name == "gui") { cgroup->buildGUICamera(pNode); } } @@ -1082,8 +1082,8 @@ void CameraGroup::buildDefaultGroup(osgViewer::View* viewer) if (oldSyntax) { for (int i = 0; i < renderingNode->nChildren(); ++i) { SGPropertyNode* propNode = renderingNode->getChild(i); - const char* propName = propNode->getName(); - if (!strcmp(propName, "window") || !strcmp(propName, "camera")) { + const string propName = propNode->getNameString(); + if (propName == "window" || propName == "camera") { SGPropertyNode* copiedNode = cgroupNode->getNode(propName, propNode->getIndex(), true); copyProperties(propNode, copiedNode); diff --git a/src/Viewer/renderer.cxx b/src/Viewer/renderer.cxx index 9ebd04f0e..e7662a2de 100644 --- a/src/Viewer/renderer.cxx +++ b/src/Viewer/renderer.cxx @@ -132,12 +132,12 @@ public: assert(dynamic_cast(stateAttribute)); osg::Hint* hint = static_cast(stateAttribute); - const char* value = mConfigNode->getStringValue(); - if (!value) + std::string value = mConfigNode->getStringValue(); + if (value.empty()) hint->setMode(GL_DONT_CARE); - else if (0 == strcmp(value, "nicest")) + else if (value == "nicest") hint->setMode(GL_NICEST); - else if (0 == strcmp(value, "fastest")) + else if (value == "fastest") hint->setMode(GL_FASTEST); else hint->setMode(GL_DONT_CARE); @@ -299,7 +299,7 @@ public: { } virtual void operator()(osg::StateSet* stateSet, osg::NodeVisitor*) { - if (strcmp(mFogEnabled->getStringValue(), "disabled") == 0) { + if (mFogEnabled->getStringValue() == "disabled") { stateSet->setMode(GL_FOG, osg::StateAttribute::OFF); } else { stateSet->setMode(GL_FOG, osg::StateAttribute::ON); @@ -520,18 +520,20 @@ FGRenderer::init( void ) addChangeListener(new DistanceAttenuationListener, "/sim/rendering/distance-attenuation"); addChangeListener(new DirectionalLightsListener, "/sim/rendering/triangle-directional-lights"); - if (const char* tc = fgGetString("/sim/rendering/texture-compression", NULL)) { - if (strcmp(tc, "false") == 0 || strcmp(tc, "off") == 0 || - strcmp(tc, "0") == 0 || strcmp(tc, "no") == 0 || - strcmp(tc, "none") == 0) { + std::string tc = fgGetString("/sim/rendering/texture-compression"); + if (!tc.empty()) { + if (tc == "false" || tc == "off" || + tc == "0" || tc == "no" || + tc == "none" + ) { SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::DoNotUseCompression); - } else if (strcmp(tc, "arb") == 0) { + } else if (tc == "arb") { SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::UseARBCompression); - } else if (strcmp(tc, "dxt1") == 0) { + } else if (tc == "dxt1") { SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::UseDXT1Compression); - } else if (strcmp(tc, "dxt3") == 0) { + } else if (tc == "dxt3") { SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::UseDXT3Compression); - } else if (strcmp(tc, "dxt5") == 0) { + } else if (tc == "dxt5") { SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::UseDXT5Compression); } else { SG_LOG(SG_VIEW, SG_WARN, "Unknown texture compression setting!"); diff --git a/src/Viewer/sview.cxx b/src/Viewer/sview.cxx index 230099311..b8d7c4202 100644 --- a/src/Viewer/sview.cxx +++ b/src/Viewer/sview.cxx @@ -1080,7 +1080,7 @@ struct SviewViewEyeTarget : SviewView : SviewView(view) { - if (!strcmp(config->getStringValue("type"), "legacy")) + if (config->getStringValue("type") == "legacy") { /* Legacy view. */ std::string callsign = config->getStringValue("callsign"); @@ -1091,7 +1091,7 @@ struct SviewViewEyeTarget : SviewView SG_LOG(SG_VIEW, SG_INFO, "eye-fixed"); m_steps.m_name = std::string() + "legacy tower" + callsign_desc; - if (!strcmp(config->getStringValue("view/type"), "lookat")) { + if (config->getStringValue("view/type") == "lookat") { /* E.g. Tower view or Tower view AGL. */ /* Add a step to move to centre of aircraft. target offsets appear @@ -1167,7 +1167,7 @@ struct SviewViewEyeTarget : SviewView SGPropertyNode* global_sim_view = globals->get_props() ->getNode("sim/view", config->getIntValue("view-number-raw")); - if (!strcmp(global_sim_view->getStringValue("type"), "lookat")) { + if (global_sim_view->getStringValue("type") == "lookat") { /* E.g. Helicopter view and Chase views. */ m_steps.m_name = std::string() + "legacy helicopter/chase" + callsign_desc; m_steps.add_step(new SviewStepAircraft(callsign)); @@ -1287,39 +1287,39 @@ struct SviewViewEyeTarget : SviewView throw std::runtime_error(std::string() + "No steps specified"); } for (SGPropertyNode* step: steps) { - const char* type = step->getStringValue("type"); + std::string type = step->getStringValue("type"); if (0) {} - else if (!strcmp(type, "aircraft")) { + else if (type == "aircraft") { std::string callsign = step->getStringValue("callsign"); m_steps.add_step(new SviewStepAircraft(callsign)); if (callsign != "") { m_steps.m_name += " callsign=" + callsign; } } - else if (!strcmp(type, "move")) { + else if (type == "move") { m_steps.add_step(new SviewStepMove( step->getDoubleValue("forward"), step->getDoubleValue("up"), step->getDoubleValue("right") )); } - else if (!strcmp(type, "direction-multiply")) { + else if (type == "direction-multiply") { m_steps.add_step(new SviewStepDirectionMultiply( step->getDoubleValue("heading"), step->getDoubleValue("pitch"), step->getDoubleValue("roll") )); } - else if (!strcmp(type, "copy-to-target")) { + else if (type == "copy-to-target") { m_steps.add_step(new SviewStepCopyToTarget); } - else if (!strcmp(type, "nearest-tower")) { + else if (type == "nearest-tower") { std::string callsign = step->getStringValue("callsign"); m_steps.add_step(new SviewStepNearestTower(callsign)); m_steps.m_name += " tower"; if (callsign != "") m_steps.m_name += " callsign=" + callsign; } - else if (!strcmp(type, "rotate")) { + else if (type == "rotate") { m_steps.add_step(new SviewStepRotate( step->getDoubleValue("heading"), step->getDoubleValue("pitch"), @@ -1329,26 +1329,26 @@ struct SviewViewEyeTarget : SviewView step->getDoubleValue("damping-roll") )); } - else if (!strcmp(type, "rotate-current-view")) { + else if (type == "rotate-current-view") { m_steps.add_step(new SviewStepRotate( globals->get_props()->getDoubleValue("heading"), globals->get_props()->getDoubleValue("pitch"), globals->get_props()->getDoubleValue("roll") )); } - else if (!strcmp(type, "mouse-drag")) + else if (type == "mouse-drag") { m_steps.add_step(new SviewStepMouseDrag( step->getDoubleValue("heading-scale", 1), step->getDoubleValue("pitch-scale", 1) )); } - else if (!strcmp(type, "double")) { + else if (type == "double") { m_steps.add_step(new SviewStepDouble(step)); m_steps.m_name += " double"; } - else if (!strcmp(type, "agl")) { - const char* callsign = step->getStringValue("callsign"); + else if (type == "agl") { + std::string callsign = step->getStringValue("callsign"); double damping_time = step->getDoubleValue("damping-time"); m_steps.add_step(new SviewStepAGL(callsign, damping_time)); } @@ -1371,11 +1371,11 @@ struct SviewViewEyeTarget : SviewView : SviewView(view) { - const char* type = config->getStringValue("type"); - if (!type) { + std::string type = config->getStringValue("type"); + if (type.empty()) { throw std::runtime_error("double-type not specified"); } - if (!strcmp(type, "last_pair") || !strcmp(type, "last_pair_double")) + if (type == "last_pair" || type == "last_pair_double") { /* Copy steps from that will set .target. */ for (auto step: b.m_steps) @@ -1404,7 +1404,7 @@ struct SviewViewEyeTarget : SviewView m_steps.add_step(step); } - if (!strcmp(type, "last_pair_double")) + if (type == "last_pair_double") { /* We need a final SviewStepDouble step. */ m_steps.add_step(new SviewStepDouble); @@ -1633,17 +1633,17 @@ std::shared_ptr SviewCreate(SGPropertyNode* config) std::shared_ptr sview_view; - const char* type = config->getStringValue("type"); + std::string type = config->getStringValue("type"); SG_LOG(SG_VIEW, SG_DEBUG, "type=" << type); if (0) { } - else if (!strcmp(type, "current")) { + else if (type == "current") { SGPropertyNode_ptr config2 = SviewConfigForCurrentView(); copyProperties(config, config2); config2->setStringValue("type", "legacy"); /* restore it after copy() sets to "current". */ sview_view.reset(new SviewViewEyeTarget(view, config2)); } - else if (!strcmp(type, "last_pair")) { + else if (type == "last_pair") { if (s_recent_views.size() < 2) { SG_LOG(SG_VIEW, SG_ALERT, "Need two pushed views"); return nullptr; @@ -1653,7 +1653,7 @@ std::shared_ptr SviewCreate(SGPropertyNode* config) std::shared_ptr eye = *(--it); sview_view.reset(new SviewViewEyeTarget(view, config, eye->m_steps, target->m_steps)); } - else if (!strcmp(type, "last_pair_double")) { + else if (type == "last_pair_double") { if (s_recent_views.size() < 2) { SG_LOG(SG_VIEW, SG_ALERT, "Need two pushed views"); return nullptr; diff --git a/src/Viewer/view.cxx b/src/Viewer/view.cxx index 9b949f673..93eb13dfe 100644 --- a/src/Viewer/view.cxx +++ b/src/Viewer/view.cxx @@ -173,8 +173,8 @@ View* View::createFromProperties(SGPropertyNode_ptr config, int view_index) View* v = nullptr; // supporting two types "lookat" = 1 and "lookfrom" = 0 - const char *type = config->getParent()->getStringValue("type"); - if (!strcmp(type, "lookat")) { + std::string type = config->getParent()->getStringValue("type"); + if (type == "lookat") { bool at_model = config->getBoolValue("at-model"); int at_model_index = config->getIntValue("at-model-idx");