]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props.hxx
Effects in models working for transparent materials and chrome animation
[simgear.git] / simgear / props / props.hxx
index dc9871343b176c8f8d309b68c0b13aa1a837cf42..e32d9a64d0811fcb5837220cb073b6c5f1203737 100644 (file)
@@ -161,6 +161,7 @@ DEFINTERNALPROP(long, LONG);
 DEFINTERNALPROP(float, FLOAT);
 DEFINTERNALPROP(double, DOUBLE);
 DEFINTERNALPROP(const char *, STRING);
+DEFINTERNALPROP(const char[], STRING);
 #undef DEFINTERNALPROP
 
 template<>
@@ -804,6 +805,11 @@ public:
    */
   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.
    */
@@ -875,17 +881,10 @@ public:
   /**
    * 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.
    */
@@ -1223,6 +1222,12 @@ public:
   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.
@@ -1604,8 +1609,9 @@ protected:
   /**
    * 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:
 
@@ -1743,7 +1749,16 @@ 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
@@ -1912,13 +1927,26 @@ inline bool SGPropertyNode::setValue(const T& val,
 }
 
 /**
- * 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