Allow incremental writing of picture MXFs.
[libdcp.git] / src / xml.h
index 65eb73994b2528a076fa2d835116ba82a8a1006b..6fc0d0fa6e3acfa93dd5f3c376c6f776b885c7a3 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -18,26 +18,27 @@ namespace xmlpp {
 
 namespace libdcp {
 
+/** @brief A helper class for XML nodes */
 class XMLNode
 {
 public:
        XMLNode ();
        XMLNode (xmlpp::Node const * node);
 
-protected:
-       std::string string_node (std::string);
-       std::string optional_string_node (std::string);
-       ContentKind kind_node (std::string);
-       Fraction fraction_node (std::string);
-       int64_t int64_node (std::string);
-       int64_t optional_int64_node (std::string);
-       float float_node (std::string);
-       void ignore_node (std::string);
+       std::string string_child (std::string);
+       std::string optional_string_child (std::string);
+       ContentKind kind_child (std::string);
+       Fraction fraction_child (std::string);
+       int64_t int64_child (std::string);
+       int64_t optional_int64_child (std::string);
+       float float_child (std::string);
+       void ignore_child (std::string);
        void done ();
 
        Time time_attribute (std::string);
        float float_attribute (std::string);
        std::string string_attribute (std::string);
+       std::string optional_string_attribute (std::string);
        int64_t int64_attribute (std::string);
        int64_t optional_int64_attribute (std::string);
        boost::optional<bool> optional_bool_attribute (std::string);
@@ -46,13 +47,13 @@ protected:
        std::string content ();
 
        template <class T>
-       boost::shared_ptr<T> sub_node (std::string name) {
-               return boost::shared_ptr<T> (new T (xml_node (name)));
+       boost::shared_ptr<T> type_child (std::string name) {
+               return boost::shared_ptr<T> (new T (node_child (name)));
        }
 
        template <class T>
-       boost::shared_ptr<T> optional_sub_node (std::string name) {
-               std::list<xmlpp::Node*> n = xml_nodes (name);
+       boost::shared_ptr<T> optional_type_child (std::string name) {
+               std::list<xmlpp::Node*> n = node_children (name);
                if (n.size() > 1) {
                        throw XMLError ("duplicate XML tag");
                } else if (n.empty ()) {
@@ -63,8 +64,8 @@ protected:
        }
        
        template <class T>
-       std::list<boost::shared_ptr<T> > sub_nodes (std::string name) {
-               std::list<xmlpp::Node*> n = xml_nodes (name);
+       std::list<boost::shared_ptr<T> > type_children (std::string name) {
+               std::list<xmlpp::Node*> n = node_children (name);
                std::list<boost::shared_ptr<T> > r;
                for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) {
                        r.push_back (boost::shared_ptr<T> (new T (*i)));
@@ -73,19 +74,20 @@ protected:
        }
 
        template <class T>
-       std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) {
-               XMLNode p (xml_node (name));
-               return p.sub_nodes<T> (sub);
+       std::list<boost::shared_ptr<T> > type_grand_children (std::string name, std::string sub) {
+               XMLNode p (node_child (name));
+               return p.type_children<T> (sub);
        }
 
        xmlpp::Node const * _node;
 
 private:
-       xmlpp::Node* xml_node (std::string);
-       std::list<xmlpp::Node*> xml_nodes (std::string);
+       xmlpp::Node* node_child (std::string);
+       std::list<xmlpp::Node*> node_children (std::string);
        std::list<Glib::ustring> _taken;
 };
 
+/** @brief A helper class for XML files */     
 class XMLFile : public XMLNode
 {
 public: