Ver Fonte

add write_prc_variables

David Rose há 20 anos atrás
pai
commit
9219cca32c

+ 39 - 0
dtool/src/prc/configVariableManager.cxx

@@ -230,6 +230,45 @@ write(ostream &out) const {
     }
   }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: ConfigVariableManager::write_prc_variables
+//       Access: Published
+//  Description: Writes all of the prc-set config variables, as they
+//               appear in a prc file somewhere, one per line, very
+//               concisely.  This lists the dominant value in the prc
+//               file; it does not list shadowed values, and it does
+//               not list locally-set values.
+//
+//               This is mainly intended for generating a hash of the
+//               input config file state.
+////////////////////////////////////////////////////////////////////
+void ConfigVariableManager::
+write_prc_variables(ostream &out) const {
+  VariablesByName::const_iterator ni;
+  for (ni = _variables_by_name.begin();
+       ni != _variables_by_name.end();
+       ++ni) {
+    ConfigVariableCore *variable = (*ni).second;
+    if (variable->get_num_trusted_references() != 0) {
+      if (variable->get_value_type() == ConfigVariableCore::VT_list ||
+          variable->get_value_type() == ConfigVariableCore::VT_search_path) {
+        // List all of the values for a "list" variable.
+        int num_references = variable->get_num_trusted_references();
+        for (int i = 0; i < num_references; i++) {
+          out << variable->get_name() << " " 
+              << variable->get_trusted_reference(i)->get_string_value()
+              << "\n";
+        }
+      } else {
+        // List just the one value for a non-list variable.
+        out << variable->get_name() << " " 
+            << variable->get_trusted_reference(0)->get_string_value()
+            << "\n";
+      }
+    }
+  }
+}
   
 ////////////////////////////////////////////////////////////////////
 //     Function: ConfigVariableManager::list_unused_variables

+ 2 - 0
dtool/src/prc/configVariableManager.h

@@ -56,6 +56,8 @@ PUBLISHED:
   void output(ostream &out) const;
   void write(ostream &out) const;
 
+  void write_prc_variables(ostream &out) const;
+
   void list_unused_variables() const;
   void list_variables() const;
   void list_dynamic_variables() const;