DEFINTERNALPROP(float, FLOAT);
DEFINTERNALPROP(double, DOUBLE);
DEFINTERNALPROP(const char *, STRING);
+DEFINTERNALPROP(const char[], STRING);
#undef DEFINTERNALPROP
template<>
*/
const char * getName () const { return _name.c_str(); }
+ /**
+ * Get the node's simple name as a string.
+ */
+ const std::string& getNameString () const { return _name; }
+
/**
* Get the node's pretty display name, with subscript when needed.
*/
/**
* Get the number of child nodes.
*/
- int nChildren () const { return _children.size(); }
+ int nChildren () const { return (int)_children.size(); }
/**
/**
* Get a child node by name and index.
*/
- SGPropertyNode * getChild (const char * name, int index = 0,
- bool create = false);
-
- /**
- * Get a child node by name and index.
- */
+ SGPropertyNode * getChild (const char* name, int index = 0,
+ bool create = false);
SGPropertyNode * getChild (const std::string& name, int index = 0,
- bool create = false)
- { return getChild(name.c_str(), index, create); }
-
-
+ bool create = false);
/**
* Get a const child node by name and index.
*/
bool setValue(const T& val,
typename boost::disable_if_c<simgear::props::PropertyTraits<T>::Internal>
::type* dummy = 0);
+
+ template<int N>
+ bool setValue(const char (&val)[N])
+ {
+ return setValue(&val[0]);
+ }
/**
* Print the value of the property to a stream.
/**
* Get the number of listeners.
*/
- int nListeners () const { return _listeners ? _listeners->size() : 0; }
+ int nListeners () const { return _listeners ? (int)_listeners->size() : 0; }
/**
/**
* Protected constructor for making new nodes on demand.
*/
- SGPropertyNode (const char * name, int index, SGPropertyNode * parent);
-
+ SGPropertyNode (const std::string& name, int index, SGPropertyNode * parent);
+ template<typename Itr>
+ SGPropertyNode (Itr begin, Itr end, int index, SGPropertyNode * parent);
private:
unsigned int _data_length;
bucket ** _data;
};
-
+ // Pass name as a pair of iterators
+ template<typename Itr>
+ SGPropertyNode * getChildImpl (Itr begin, Itr end, int index = 0, bool create = false);
+ // very internal method
+ template<typename Itr>
+ SGPropertyNode* getExistingChild (Itr begin, Itr end, int index, bool create);
+ // very internal path parsing function
+ template<typename SplitItr>
+ friend SGPropertyNode* find_node_aux(SGPropertyNode * current, SplitItr& itr,
+ bool create, int last_index);
};
// Convenience functions for use in templates
case UNSPECIFIED:
return simgear::parseString<T>(make_string());
break;
+ default: // avoid compiler warning
+ break;
}
return SGRawValue<T>::DefaultValue();
}
}
/**
- * Utility function for creation of a child property node
+ * Utility function for creation of a child property node.
*/
inline SGPropertyNode* makeChild(SGPropertyNode* parent, const char* name,
int index = 0)
{
return parent->getChild(name, index, true);
}
+
+/**
+ * Utility function for creation of a child property node using a
+ * relative path.
+ */
+namespace simgear
+{
+template<typename StringType>
+inline SGPropertyNode* makeNode(SGPropertyNode* parent, const StringType& name)
+{
+ return parent->getNode(name, true);
+}
+}
#endif // __PROPS_HXX
// end of props.hxx