void TgtAptDialog_Reset(puObject *)
{
- sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
TgtAptDialogInput->setValue ( NewTgtAirportId );
TgtAptDialogInput->setCursor( 0 ) ;
}
void AddWayPoint(puObject *cb)
{
- sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
TgtAptDialogInput->setValue( NewTgtAirportId );
/* refresh waypoint list */
void NewTgtAirportInit()
{
SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
- sprintf( NewTgtAirportId, "%s",
- fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
int len = 150
- puGetDefaultLabelFont().getStringWidth( NewTgtAirportLabel ) / 2;
update_old_control_values();
- sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
}
float altitude;
- if ( startup_units_node->getStringValue() == "feet" ) {
+ if ( string(startup_units_node->getStringValue()) == "feet" ) {
altitude = current_aircraft.fdm_state->get_Altitude();
} else {
altitude = (current_aircraft.fdm_state->get_Altitude()
sprintf(_buf, _fmt.c_str(), _text.c_str());
return _buf;
case TEXT_VALUE:
- sprintf(_buf, _fmt.c_str(), _node->getStringValue().c_str());
+ sprintf(_buf, _fmt.c_str(), _node->getStringValue());
break;
case DOUBLE_VALUE:
sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
type = "rotation";
}
- if (propName != (string)"") {
- target = fgGetNode(propName, true);
+ if (propName != "") {
+ target = fgGetNode(propName.c_str(), true);
}
t->node = target;
t->table = new SGInterpTable();
for(int i = 0; i < trans_table->nChildren(); i++) {
const SGPropertyNode * node = trans_table->getChild(i);
- if (node->getName() == "entry") {
+ if (string(node->getName()) == "entry") {
double ind = node->getDoubleValue("ind", 0.0);
double dep = node->getDoubleValue("dep", 0.0);
SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
else if (type == "number-value") {
string propName = node->getStringValue("property");
float scale = node->getFloatValue("scale", 1.0);
- SGPropertyNode * target = fgGetNode(propName, true);
+ SGPropertyNode * target = fgGetNode(propName.c_str(), true);
chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
format, scale);
}
for (int i = 0; i < node->nChildren(); i++) {
const SGPropertyNode * child = node->getChild(i);
cerr << "Trying child " << child->getName() << endl;
- if (child->getName() == "layer") {
+ if (string(child->getName()) == "layer") {
cerr << "succeeded!" << endl;
((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
}
int nChunks = chunk_group->nChildren();
for (int i = 0; i < nChunks; i++) {
const SGPropertyNode * node = chunk_group->getChild(i);
- if (node->getName() == "chunk") {
+ if (string(node->getName()) == "chunk") {
FGTextLayer::Chunk * chunk = readTextChunk(node);
if (chunk != 0)
tlayer->addChunk(chunk);
int nTransformations = trans_group->nChildren();
for (int i = 0; i < nTransformations; i++) {
const SGPropertyNode * node = trans_group->getChild(i);
- if (node->getName() == "transformation") {
+ if (string(node->getName()) == "transformation") {
FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
if (t != 0)
layer->addTransformation(t);
int nActions = action_group->nChildren();
for (int i = 0; i < nActions; i++) {
const SGPropertyNode * node = action_group->getChild(i);
- if (node->getName() == "action") {
+ if (string(node->getName()) == "action") {
FGPanelAction * action = readAction(node, w_scale, h_scale);
if (action != 0)
instrument->addAction(action);
int nLayers = layer_group->nChildren();
for (int i = 0; i < nLayers; i++) {
const SGPropertyNode * node = layer_group->getChild(i);
- if (node->getName() == "layer") {
+ if (string(node->getName()) == "layer") {
FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
if (layer != 0)
instrument->addLayer(layer);
int nInstruments = instrument_group->nChildren();
for (int i = 0; i < nInstruments; i++) {
const SGPropertyNode * node = instrument_group->getChild(i);
- if (node->getName() == "instrument") {
+ if (string(node->getName()) == "instrument") {
FGPanelInstrument * instrument = readInstrument(node);
if (instrument != 0)
panel->addInstrument(instrument);
speed_up = fgGetNode("/sim/speed-up", true);
aero = fgGetNode("/sim/aero", true);
- ls_toplevel_init( 0.0, (char *)(aero->getStringValue().c_str()) );
+ ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) );
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
- if ( aero->getStringValue() == "c172" ) {
+ if ( string(aero->getStringValue()) == "c172" ) {
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
//this should go away someday -- formerly done in fg_init.cxx
// Run an iteration of the EOM (equations of motion)
void FGLaRCsim::update( int multiloop ) {
- if ( aero->getStringValue() == "c172" ) {
+ if ( string(aero->getStringValue()) == "c172" ) {
// set control inputs
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
eng.set_IAS( V_calibrated_kts );
speed_up->getIntValue();
Flap_handle = 30.0 * globals->get_controls()->get_flaps();
- if ( aero->getStringValue() == "c172" ) {
+ if ( string(aero->getStringValue()) == "c172" ) {
Use_External_Engine = 1;
} else {
Use_External_Engine = 0;
_set_Climb_Rate( -1 * V_down );
// cout << "climb rate = " << -V_down * 60 << endl;
- if ( aero->getStringValue() == "uiuc" ) {
+ if ( string(aero->getStringValue()) == "uiuc" ) {
if (pilot_elev_no) {
globals->get_controls()->set_elevator(Long_control);
globals->get_controls()->set_elevator_trim(Long_trim);
void AptDialog_Reset(puObject *)
{
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
- sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
AptDialogInput->setValue ( NewAirportId );
AptDialogInput->setCursor( 0 ) ;
}
void NewAirport(puObject *cb)
{
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
- sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
// cout << "NewAirport " << NewAirportId << endl;
AptDialogInput->setValue( NewAirportId );
void NewAirportInit(void)
{
- sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
+ sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
int len = 150
- puGetDefaultLabelFont().getStringWidth( NewAirportLabel ) / 2;
void NewCallSign(puObject *cb)
{
- sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
+ sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign") );
// sprintf( NewNetId, "%s", fgd_callsign );
NetIdDialogInput->setValue( NewNetId );
void NewNetIdInit(void)
{
- sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
+ sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign") );
// sprintf( NewNetId, "%s", fgd_callsign );
int len = 150 - puGetDefaultLabelFont().getStringWidth( NewNetIdLabel ) / 2;
for (i = 0; i < (int)node->nChildren(); i++) {
SGPropertyNode * child = node->getChild(i);
name = child->getName();
- if ( node->getChild(name, 1) != 0 ) {
+ if ( node->getChild(name.c_str(), 1) != 0 ) {
iindex = child->getIndex();
sprintf(sindex, "[%d]", iindex);
name += sindex;
values[ pi ] = new char[ 2 ] ;
} else {
dflag[ pi ] = 0 ;
- value = node->getStringValue ( name, "" );
+ value = node->getStringValue ( name.c_str(), "" );
values[ pi ] = new char[ strlen(value.c_str())+2 ] ;
strcpy ( values [pi], value.c_str() );
line += " = '" + value + "' " + "(";
- line += getValueTypeString( node->getNode( name ) );
+ line += getValueTypeString( node->getNode( name.c_str() ) );
line += ")";
files[ pi ] = new char[ strlen(line.c_str())+2 ] ;
strcpy ( files [ pi ], line.c_str() ) ;
// FIXME: inefficient
const string & tmp = prop1->getStringValue();
return (prop1->setUnspecifiedValue(prop2->getStringValue()) &&
- prop2->setUnspecifiedValue(tmp));
+ prop2->setUnspecifiedValue(tmp.c_str()));
}
/**
* Get the logging classes.
*/
-static string
+static const char *
getLoggingClasses ()
{
sgDebugClass classes = logbuf::get_log_classes();
result += log_class_mappings[i].name;
}
}
- return result;
+ return result.c_str();
}
-static void addLoggingClass (const string &name)
+static void
+addLoggingClass (const string &name)
{
sgDebugClass classes = logbuf::get_log_classes();
for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
* Set the logging classes.
*/
static void
-setLoggingClasses (string classes)
+setLoggingClasses (const char * c)
{
+ string classes = c;
logbuf::set_log_classes(SG_NONE);
if (classes == "none") {
/**
* Get the logging priority.
*/
-static string
+static const char *
getLoggingPriority ()
{
switch (logbuf::get_log_priority()) {
* Set the logging priority.
*/
static void
-setLoggingPriority (string priority)
+setLoggingPriority (const char * p)
{
+ string priority = p;
if (priority == "bulk") {
logbuf::set_log_priority(SG_BULK);
} else if (priority == "debug") {
}
-#if 0
-/**
- * Get the pause state of the sim.
- */
-static bool
-getFreeze ()
-{
- return globals->get_freeze();
-}
-
-
-/**
- * Set the pause state of the sim.
- */
-static void
-setFreeze (bool freeze)
-{
- globals->set_freeze(freeze);
- if ( freeze ) {
- // BusyCursor( 0 );
- current_atcdisplay->CancelRepeatingMessage();
- current_atcdisplay->RegisterRepeatingMessage("**** SIM IS FROZEN **** SIM IS FROZEN ****");
- } else {
- // BusyCursor( 1 );
- current_atcdisplay->CancelRepeatingMessage();
- }
-}
-#endif
-
/**
* Return the current aircraft directory (UIUC) as a string.
*/
-static string
+static const char *
getAircraftDir ()
{
- return aircraft_dir;
+ return aircraft_dir.c_str();
}
* Set the current aircraft directory (UIUC).
*/
static void
-setAircraftDir (string dir)
+setAircraftDir (const char * dir)
{
- if (getAircraftDir() != dir) {
- aircraft_dir = dir;
-// needReinit(); FIXME!!
- }
+ aircraft_dir = dir;
}
/**
* Return the current Zulu time.
*/
-static string
+static const char *
getDateString ()
{
string out;
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
out = buf;
- return out;
+ return out.c_str();
}
* Set the current Zulu time.
*/
static void
-setDateString (string date_string)
+setDateString (const char * date_string)
{
static const SGPropertyNode *cur_time_override
= fgGetNode("/sim/time/cur-time-override", true);
// Scan for basic ISO format
// YYYY-MM-DDTHH:MM:SS
- int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
+ int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
&(new_time.tm_year), &(new_time.tm_mon),
&(new_time.tm_mday), &(new_time.tm_hour),
&(new_time.tm_min), &(new_time.tm_sec));
/**
* Return the GMT as a string.
*/
-static string
+static const char *
getGMTString ()
{
string out;
t->tm_hour, t->tm_min, t->tm_sec);
// cout << t << " " << buf << endl;
out = buf;
- return out;
+ return out.c_str();
}
}
+\f
+////////////////////////////////////////////////////////////////////////
+// Property convenience functions.
+////////////////////////////////////////////////////////////////////////
+
+SGPropertyNode *
+fgGetNode (const char * path, bool create)
+{
+ return globals->get_props()->getNode(path, create);
+}
+
+SGPropertyNode *
+fgGetNode (const char * path, int index, bool create)
+{
+ return globals->get_props()->getNode(path, index, create);
+}
+
+bool
+fgHasNode (const char * path)
+{
+ return (fgGetNode(path, false) != 0);
+}
+
+bool
+fgGetBool (const char * name, bool defaultValue)
+{
+ return globals->get_props()->getBoolValue(name, defaultValue);
+}
+
+int
+fgGetInt (const char * name, int defaultValue)
+{
+ return globals->get_props()->getIntValue(name, defaultValue);
+}
+
+int
+fgGetLong (const char * name, long defaultValue)
+{
+ return globals->get_props()->getLongValue(name, defaultValue);
+}
+
+float
+fgGetFloat (const char * name, float defaultValue)
+{
+ return globals->get_props()->getFloatValue(name, defaultValue);
+}
+
+double
+fgGetDouble (const char * name, double defaultValue)
+{
+ return globals->get_props()->getDoubleValue(name, defaultValue);
+}
+
+const char *
+fgGetString (const char * name, const char * defaultValue)
+{
+ return globals->get_props()->getStringValue(name, defaultValue);
+}
+
+bool
+fgSetBool (const char * name, bool val)
+{
+ return globals->get_props()->setBoolValue(name, val);
+}
+
+bool
+fgSetInt (const char * name, int val)
+{
+ return globals->get_props()->setIntValue(name, val);
+}
+
+bool
+fgSetLong (const char * name, long val)
+{
+ return globals->get_props()->setLongValue(name, val);
+}
+
+bool
+fgSetFloat (const char * name, float val)
+{
+ return globals->get_props()->setFloatValue(name, val);
+}
+
+bool
+fgSetDouble (const char * name, double val)
+{
+ return globals->get_props()->setDoubleValue(name, val);
+}
+
+bool
+fgSetString (const char * name, const char * val)
+{
+ return globals->get_props()->setStringValue(name, val);
+}
+
+void
+fgSetArchivable (const char * name, bool state)
+{
+ SGPropertyNode * node = globals->get_props()->getNode(name);
+ if (node == 0)
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Attempt to set archive flag for non-existant property "
+ << name);
+ else
+ node->setAttribute(SGPropertyNode::ARCHIVE, state);
+}
+
+void
+fgSetReadable (const char * name, bool state)
+{
+ SGPropertyNode * node = globals->get_props()->getNode(name);
+ if (node == 0)
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Attempt to set read flag for non-existant property "
+ << name);
+ else
+ node->setAttribute(SGPropertyNode::READ, state);
+}
+
+void
+fgSetWritable (const char * name, bool state)
+{
+ SGPropertyNode * node = globals->get_props()->getNode(name);
+ if (node == 0)
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Attempt to set write flag for non-existant property "
+ << name);
+ else
+ node->setAttribute(SGPropertyNode::WRITE, state);
+}
+
+void
+fgUntie (const char * name)
+{
+ if (!globals->get_props()->untie(name))
+ SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
+}
+
+
+
\f
////////////////////////////////////////////////////////////////////////
// Implementation of FGCondition.
// Implementation of FGPropertyCondition.
////////////////////////////////////////////////////////////////////////
-FGPropertyCondition::FGPropertyCondition (const string &propname)
+FGPropertyCondition::FGPropertyCondition (const char * propname)
: _node(fgGetNode(propname, true))
{
}
}
void
-FGComparisonCondition::setLeftProperty (const string &propname)
+FGComparisonCondition::setLeftProperty (const char * propname)
{
_left_property = fgGetNode(propname, true);
}
void
-FGComparisonCondition::setRightProperty (const string &propname)
+FGComparisonCondition::setRightProperty (const char * propname)
{
delete _right_value;
_right_value = 0;
// Convenience functions for getting property values.
////////////////////////////////////////////////////////////////////////
-
/**
* Get a property node.
*
* @param create true to create the node if it doesn't exist.
* @return The node, or 0 if none exists and none was created.
*/
-inline SGPropertyNode *
-fgGetNode (const string &path, bool create = false)
-{
- return globals->get_props()->getNode(path, create);
-}
+extern SGPropertyNode * fgGetNode (const char * path, bool create = false);
/**
* @param create true to create the node if it doesn't exist.
* @return The node, or 0 if none exists and none was created.
*/
-inline SGPropertyNode *
-fgGetNode (const string &path, int index, bool create = false)
-{
- return globals->get_props()->getNode(path, index, create);
-}
+extern SGPropertyNode * fgGetNode (const char * path,
+ int index, bool create = false);
/**
* @param path The path of the node, relative to root.
* @return true if the node exists, false otherwise.
*/
-inline bool
-fgHasNode (const string &path)
-{
- return (fgGetNode(path, false) != 0);
-}
+extern bool fgHasNode (const char * path);
/**
* does not exist.
* @return The property's value as a bool, or the default value provided.
*/
-inline bool fgGetBool (const string &name, bool defaultValue = false)
-{
- return globals->get_props()->getBoolValue(name, defaultValue);
-}
+extern bool fgGetBool (const char * name, bool defaultValue = false);
/**
* does not exist.
* @return The property's value as an int, or the default value provided.
*/
-inline int fgGetInt (const string &name, int defaultValue = 0)
-{
- return globals->get_props()->getIntValue(name, defaultValue);
-}
+extern int fgGetInt (const char * name, int defaultValue = 0);
/**
* does not exist.
* @return The property's value as a long, or the default value provided.
*/
-inline int fgGetLong (const string &name, long defaultValue = 0L)
-{
- return globals->get_props()->getLongValue(name, defaultValue);
-}
+extern int fgGetLong (const char * name, long defaultValue = 0L);
/**
* does not exist.
* @return The property's value as a float, or the default value provided.
*/
-inline float fgGetFloat (const string &name, float defaultValue = 0.0)
-{
- return globals->get_props()->getFloatValue(name, defaultValue);
-}
+extern float fgGetFloat (const char * name, float defaultValue = 0.0);
/**
* does not exist.
* @return The property's value as a double, or the default value provided.
*/
-inline double fgGetDouble (const string &name, double defaultValue = 0.0)
-{
- return globals->get_props()->getDoubleValue(name, defaultValue);
-}
+extern double fgGetDouble (const char * name, double defaultValue = 0.0);
/**
* does not exist.
* @return The property's value as a string, or the default value provided.
*/
-inline string fgGetString (const string &name, string defaultValue = "")
-{
- return globals->get_props()->getStringValue(name, defaultValue);
-}
+extern const char * fgGetString (const char * name,
+ const char * defaultValue = "");
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetBool (const string &name, bool val)
-{
- return globals->get_props()->setBoolValue(name, val);
-}
+extern bool fgSetBool (const char * name, bool val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetInt (const string &name, int val)
-{
- return globals->get_props()->setIntValue(name, val);
-}
+extern bool fgSetInt (const char * name, int val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetLong (const string &name, long val)
-{
- return globals->get_props()->setLongValue(name, val);
-}
+extern bool fgSetLong (const char * name, long val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetFloat (const string &name, float val)
-{
- return globals->get_props()->setFloatValue(name, val);
-}
+extern bool fgSetFloat (const char * name, float val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetDouble (const string &name, double val)
-{
- return globals->get_props()->setDoubleValue(name, val);
-}
+extern bool fgSetDouble (const char * name, double val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
-inline bool fgSetString (const string &name, const string &val)
-{
- return globals->get_props()->setStringValue(name, val);
-}
+extern bool fgSetString (const char * name, const char * val);
\f
* @param name The property name.
* @param state The state of the archive attribute (defaults to true).
*/
-inline void
-fgSetArchivable (const string &name, bool state = true)
-{
- SGPropertyNode * node = globals->get_props()->getNode(name);
- if (node == 0)
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Attempt to set archive flag for non-existant property "
- << name);
- else
- node->setAttribute(SGPropertyNode::ARCHIVE, state);
-}
+extern void fgSetArchivable (const char * name, bool state = true);
/**
* @param name The property name.
* @param state The state of the read attribute (defaults to true).
*/
-inline void
-fgSetReadable (const string &name, bool state = true)
-{
- SGPropertyNode * node = globals->get_props()->getNode(name);
- if (node == 0)
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Attempt to set read flag for non-existant property "
- << name);
- else
- node->setAttribute(SGPropertyNode::READ, state);
-}
+extern void fgSetReadable (const char * name, bool state = true);
/**
* @param name The property name.
* @param state The state of the write attribute (defaults to true).
*/
-inline void
-fgSetWritable (const string &name, bool state = true)
-{
- SGPropertyNode * node = globals->get_props()->getNode(name);
- if (node == 0)
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Attempt to set write flag for non-existant property "
- << name);
- else
- node->setAttribute(SGPropertyNode::WRITE, state);
-}
+extern void fgSetWritable (const char * name, bool state = true);
\f
* Classes should use this function to release control of any
* properties they are managing.
*/
-inline void
-fgUntie (const string &name)
-{
- if (!globals->get_props()->untie(name))
- SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
-}
+extern void fgUntie (const char * name);
/**
*/
template <class V>
inline void
-fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0,
+fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0,
bool useDefault = true)
{
if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
*/
template <class V>
inline void
-fgTie (const string &name, int index, V (*getter)(int),
+fgTie (const char * name, int index, V (*getter)(int),
void (*setter)(int, V) = 0, bool useDefault = true)
{
if (!globals->get_props()->tie(name,
*/
template <class T, class V>
inline void
-fgTie (const string &name, T * obj, V (T::*getter)() const,
+fgTie (const char * name, T * obj, V (T::*getter)() const,
void (T::*setter)(V) = 0, bool useDefault = true)
{
if (!globals->get_props()->tie(name,
*/
template <class T, class V>
inline void
-fgTie (const string &name, T * obj, int index,
+fgTie (const char * name, T * obj, int index,
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
bool useDefault = true)
{
class FGPropertyCondition : public FGCondition
{
public:
- FGPropertyCondition (const string &propname);
+ FGPropertyCondition (const char * propname);
virtual ~FGPropertyCondition ();
virtual bool test () const { return _node->getBoolValue(); }
private:
FGComparisonCondition (Type type, bool reverse = false);
virtual ~FGComparisonCondition ();
virtual bool test () const;
- virtual void setLeftProperty (const string &propname);
- virtual void setRightProperty (const string &propname);
+ virtual void setLeftProperty (const char * propname);
+ virtual void setRightProperty (const char * propname);
// will make a local copy
virtual void setRightValue (const SGPropertyNode * value);
private:
// set current_options lon/lat if an airport id is specified
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
- if ( fgGetString("/sim/startup/airport-id").length() ) {
+ if ( fgGetString("/sim/startup/airport-id")[0] != '\0' ) {
// fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") );
fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"),
fgGetDouble("/orientation/heading-deg") );
} else if ( arg == "--enable-anti-alias-hud" ) {
fgSetBool("/sim/hud/antialiased", true);
} else if ( arg.find( "--control=") == 0 ) {
- fgSetString("/sim/control-mode", arg.substr(10));
+ fgSetString("/sim/control-mode", arg.substr(10).c_str());
} else if ( arg == "--disable-auto-coordination" ) {
fgSetBool("/sim/auto-coordination", false);
} else if ( arg == "--enable-auto-coordination" ) {
fgSetBool("/sim/auto-coordination", true);
} else if ( arg.find( "--browser-app=") == 0 ) {
- fgSetString("/sim/startup/browser-app", arg.substr(14));
+ fgSetString("/sim/startup/browser-app", arg.substr(14).c_str());
} else if ( arg == "--disable-hud" ) {
fgSetBool("/sim/hud/visibility", false);
} else if ( arg == "--enable-hud" ) {
fgSetBool("/sim/sound/audible", true);
} else if ( arg.find( "--airport-id=") == 0 ) {
// NB: changed property name!!!
- fgSetString("/sim/startup/airport-id", arg.substr(13));
+ fgSetString("/sim/startup/airport-id", arg.substr(13).c_str());
} else if ( arg.find( "--offset-distance=") == 0 ) {
fgSetDouble("/sim/startup/offset-distance", atof(arg.substr(18)));
} else if ( arg.find( "--offset-azimuth=") == 0 ) {
} else if ( arg.find( "--fg-scenery=" ) == 0 ) {
globals->set_fg_scenery(arg.substr( 13 ));
} else if ( arg.find( "--fdm=" ) == 0 ) {
- fgSetString("/sim/flight-model", arg.substr(6));
+ fgSetString("/sim/flight-model", arg.substr(6).c_str());
} else if ( arg.find( "--aero=" ) == 0 ) {
- fgSetString("/sim/aero", arg.substr(7));
+ fgSetString("/sim/aero", arg.substr(7).c_str());
} else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
- fgSetString("/sim/aircraft-dir", arg.substr(15));
+ fgSetString("/sim/aircraft-dir", arg.substr(15).c_str());
} else if ( arg.find( "--model-hz=" ) == 0 ) {
fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
} else if ( arg.find( "--speed=" ) == 0 ) {
fgSetBool("/sim/hud/net-display", true);
net_hud_display = 1; // FIXME
} else if ( arg.find( "--net-id=") == 0 ) {
- fgSetString("sim/networking/call-sign", arg.substr(9));
+ fgSetString("sim/networking/call-sign", arg.substr(9).c_str());
#endif
} else if ( arg.find( "--prop:" ) == 0 ) {
string assign = arg.substr(7);
}
string name = assign.substr(0, pos);
string value = assign.substr(pos + 1);
- fgSetString(name.c_str(), value);
+ fgSetString(name.c_str(), value.c_str());
// SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
// << name << " to \"" << value << '"');
} else if ( arg.find("--trace-read=") == 0) {
string name = arg.substr(13);
SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
- fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_READ, true);
+ fgGetNode(name.c_str(), true)
+ ->setAttribute(SGPropertyNode::TRACE_READ, true);
} else if ( arg.find("--trace-write=") == 0) {
string name = arg.substr(14);
SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
- fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_WRITE, true);
+ fgGetNode(name.c_str(), true)
+ ->setAttribute(SGPropertyNode::TRACE_WRITE, true);
} else if ( arg.find( "--view-offset=" ) == 0 ) {
// $$$ begin - added VS Renganathan, 14 Oct 2K
// for multi-window outside window imagery
string b = arg.substr( apos + 1 );
printf(" a = %s b = %s\n", a.c_str(), b.c_str() );
if ( a == "value" ) {
- fgSetString( request, urlDecode(b) );
+ fgSetString( request.c_str(), urlDecode(b).c_str() );
}
}
}
request = urlDecode(request);
}
- node = globals->get_props()->getNode(request);
+ node = globals->get_props()->getNode(request.c_str());
string response = "";
response += "<HTML LANG=\"en\">";
for (int i = 0; i < node->nChildren(); i++) {
SGPropertyNode *child = node->getChild(i);
string name = child->getName();
- if ( node->getChild(name, 1) ) {
+ if ( node->getChild(name.c_str(), 1) ) {
char buf[16];
sprintf(buf, "[%d]", child->getIndex());
name += buf;
line += "</A></B>";
line += "/<BR>";
} else {
- string value = node->getStringValue ( name, "" );
+ string value = node->getStringValue ( name.c_str(), "" );
line += "<B>";
line += name;
line += "</B> <A HREF=\"";
string command = tokens[0];
- SGPropertyNode * node = globals->get_props()->getNode(path);
+ SGPropertyNode * node = globals->get_props()->getNode(path.c_str());
if ( command == "ls" ) {
SGPropertyNode * dir = node;
if ( tokens.size() > 2 ) {
if ( tokens[1][0] == '/' ) {
- dir = globals->get_props()->getNode(tokens[1]);
+ dir = globals->get_props()->getNode(tokens[1].c_str());
} else {
- dir = globals->get_props()->getNode(path + "/" + tokens[1]);
+ dir = globals->get_props()->getNode((path + "/" + tokens[1]).c_str());
}
if ( dir == 0 ) {
tokens[1] = "ERR Node \"" + tokens[1] + "\" not found.\n";
SGPropertyNode * child = dir->getChild(i);
string name = child->getName();
string line = name;
- if ( dir->getChild(name, 1) ) {
+ if ( dir->getChild(name.c_str(), 1) ) {
char buf[16];
sprintf(buf, "[%d]", child->getIndex());
line += buf;
line += "/";
} else {
if ( mode == PROMPT ) {
- string value = dir->getStringValue ( name, "" );
+ string value = dir->getStringValue ( name.c_str(), "" );
line += " =\t'" + value + "'\t(";
- line += getValueTypeString( dir->getNode( name ) );
+ line += getValueTypeString( dir->getNode( name.c_str() ) );
line += ")";
}
}
io->writestring( buf.str() );
}
else {
- SGPropertyNode *child = node->getNode(tokens[1]);
+ SGPropertyNode *child = node->getNode(tokens[1].c_str());
if ( child ) {
writeProperties ( buf, child );
io->writestring( buf.str() );
if ( tokens.size() <= 1 ) {
// do nothing
} else {
- SGPropertyNode *child = node->getNode(tokens[1]);
+ SGPropertyNode *child = node->getNode(tokens[1].c_str());
if ( child ) {
node = child;
path = node->getPath();
// do nothing
} else {
string tmp;
- string value = node->getStringValue ( tokens[1], "" );
+ string value = node->getStringValue ( tokens[1].c_str(), "" );
if ( mode == PROMPT ) {
//string ttt = "debug = '" + tokens[1] + "'\n";
//io->writestring( ttt.c_str() );
tmp = tokens[1] + " = '" + value + "' (";
- tmp += getValueTypeString( node->getNode( tokens[1] ) );
+ tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
tmp += ")\n";
} else {
tmp = value + "\n";
if ( tokens.size() <= 2 ) {
// do nothing
} else {
- node->getNode( tokens[1], true )->setStringValue(tokens[2]);
+ node->getNode( tokens[1].c_str(), true )->setStringValue(tokens[2].c_str());
// now fetch and write out the new value as confirmation
// of the change
- string value = node->getStringValue ( tokens[1], "" );
+ string value = node->getStringValue ( tokens[1].c_str(), "" );
string tmp = tokens[1] + " = '" + value + "' (";
- tmp += getValueTypeString( node->getNode( tokens[1] ) );
+ tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
tmp += ")\n";
io->writestring( tmp.c_str() );
// We enable display of netinfos only if user wishes it via cmd-line param
net_hud_display = (net_hud_display == 0) ? 0 : 1;
// Get pilot's name from options, can be modified at runtime via menu
- net_callsign = (char *)(fgGetString("/sim/networking/call-sign").c_str());
+ net_callsign = (char *)(fgGetString("/sim/networking/call-sign"));
// Disable Blast Mode -1 = Disable, 0 = Enable
net_blast_toggle = -1;
// We start unregistered, we reg. later via menu to fgd
int nMaterials = materials.nChildren();
for (int i = 0; i < nMaterials; i++) {
const SGPropertyNode * node = materials.getChild(i);
- if (node->getName() == "material") {
+ if (string(node->getName()) == "material") {
FGNewMat * m = new FGNewMat(node);
vector<const SGPropertyNode *>names = node->getChildren("name");
for (unsigned int j = 0; j < names.size(); j++) {
+ string name = names[j]->getStringValue();
m->ref();
- matlib[names[j]->getStringValue()] = m;
+ std::cerr << "Material " << name << endl;
+ matlib[name] = m;
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
<< names[j]->getStringValue());
}
const SGPropertyNode * node = fgGetNode("/sim/sound", true);
int i;
+ string path_str = node->getStringValue("path");
SGPath path( globals->get_fg_root() );
- if (node->getStringValue("path") == "") {
- SG_LOG(SG_GENERAL, SG_ALERT, "Incorect path in configuration file.");
+ if (path_str == "") {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
return;
}
- path.append(node->getStringValue("path"));
+ path.append(path_str.c_str());
SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
- << " from " << path.str());
+ << " from " << path.str());
SGPropertyNode root;
try {
SG_LOG(SG_GENERAL, SG_INFO,
"Loading sound information for: " << _name );
- if (_node->getStringValue("mode") == "looped") {
+ string mode_str = _node->getStringValue("mode");
+ if (mode_str == "looped") {
_mode = FGSound::LOOPED;
} else {
_mode = FGSound::ONCE;
- if (_node->getStringValue("mode") != (string)"once")
+ if (mode_str != (string)"once")
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound mode, default to 'once'");
}
- if (_node->getStringValue("type") == "flipflop") {
+ string type_str = _node->getStringValue("type");
+ if (type_str == "flipflop") {
_type = FGSound::FLIPFLOP;
-
- } else if (_node->getStringValue("type") == "inverted") {
+ } else if (type_str== "inverted") {
_type = FGSound::INVERTED;
-
- } else if (_node->getStringValue("type") == "raise") {
+ } else if (type_str == "raise") {
_type = FGSound::RAISE;
-
- } else if (_node->getStringValue("type") == "fall") {
+ } else if (type_str == "fall") {
_type = FGSound::FALL;
-
} else {
_type = FGSound::LEVEL;
- if (_node->getStringValue("type") != (string)"level")
+ if (type_str != (string)"level")
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound type, default to 'level'");
}