fun with XML
authorjhurst <jhurst@cinecert.com>
Thu, 19 Mar 2009 05:36:45 +0000 (05:36 +0000)
committerjhurst <>
Thu, 19 Mar 2009 05:36:45 +0000 (05:36 +0000)
src/KM_xml.cpp
src/KM_xml.h
src/S12MTimecode.h

index 4792e9beeed0aeb216d921faf06bdc1fa9622882..5b053fae9962247d2d85a7765d2b5100f3927184 100644 (file)
@@ -137,6 +137,13 @@ Kumu::XMLElement::AppendBody(const std::string& value)
   m_Body += value;
 }
 
+//
+void
+Kumu::XMLElement::SetBody(const std::string& value)
+{
+  m_Body = value;
+}
+
 //
 Kumu::XMLElement*
 Kumu::XMLElement::AddChildWithContent(const char* name, const char* value)
@@ -291,6 +298,73 @@ Kumu::XMLElement::GetChildrenWithName(const char* name, ElementList& outList) co
   return outList;
 }
 
+//
+void
+Kumu::XMLElement::DeleteAttributes()
+{
+  m_AttrList.clear();
+}
+
+//
+void
+Kumu::XMLElement::DeleteAttrWithName(const char* name)
+{
+  assert(name);
+  AttributeList::iterator i;
+  for ( i = m_AttrList.begin(); i != m_AttrList.end(); i++ )
+    {
+      if ( i->name == std::string(name) )
+       m_AttrList.erase(i);
+    }
+}
+
+//
+void
+Kumu::XMLElement::DeleteChildren()
+{
+  for ( ElementList::iterator i = m_ChildList.begin(); i != m_ChildList.end(); i++ )
+    {
+      delete *i;
+      m_ChildList.erase(i);
+    }
+}
+
+//
+void
+Kumu::XMLElement::DeleteChild(const XMLElement* element)
+{
+  if ( element != 0 )
+    {
+      for ( ElementList::iterator i = m_ChildList.begin(); i != m_ChildList.end(); i++ )
+       {
+         if ( *i == element )
+           {
+             delete *i;
+             m_ChildList.erase(i);
+             return;
+           }
+       }
+    }
+}
+
+//
+void
+Kumu::XMLElement::ForgetChild(const XMLElement* element)
+{
+  if ( element != 0 )
+    {
+      for ( ElementList::iterator i = m_ChildList.begin(); i != m_ChildList.end(); i++ )
+       {
+         if ( *i == element )
+           {
+             m_ChildList.erase(i);
+             return;
+           }
+       }
+    }
+}
+
+
 //----------------------------------------------------------------------------------------------------
 
 #ifdef HAVE_EXPAT
index d8a444b4fe16eb88767fb626c324907e2978f329..8e0259662010b8cc468fa9379cb98c4b67c5e1ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005-2008, John Hurst
+Copyright (c) 2005-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -100,6 +100,7 @@ namespace Kumu
 
       // building
       void        SetName(const char* name);
+      void        SetBody(const std::string& value);
       void        AppendBody(const std::string& value);
       void        SetAttr(const char* name, const char* value);
       XMLElement* AddChild(XMLElement* element);
@@ -121,6 +122,12 @@ namespace Kumu
       const ElementList& GetChildrenWithName(const char* name, ElementList& outList) const;
       bool               HasName(const char* name) const;
 
+      // altering
+      void        DeleteAttributes();
+      void        DeleteAttrWithName(const char* name);
+      void        DeleteChildren();
+      void        DeleteChild(const XMLElement* element);
+      void        ForgetChild(const XMLElement* element);
     };
 } // namespace Kumu
 
index 88c16f8bbce3a2a8b0e3fab2761e6b0507380a30..1e8c5a2e075095ceb14c8a8430e5dbc0e9bf584a 100644 (file)
@@ -45,6 +45,7 @@ namespace ASDCP {
 
  class S12MTimecode : public Kumu::IArchive
 {
+ protected:
   ui32_t m_FrameCount;
   ui32_t m_FPS;