Shaka Packager SDK
Public Member Functions | Friends | List of all members
shaka::xml::XmlNode Class Reference

#include <xml_node.h>

Inheritance diagram for shaka::xml::XmlNode:
shaka::xml::RepresentationBaseXmlNode shaka::xml::AdaptationSetXmlNode shaka::xml::RepresentationXmlNode

Public Member Functions

 XmlNode (const std::string &name)
 
 XmlNode (XmlNode &&)
 
XmlNodeoperator= (XmlNode &&)
 
bool AddChild (XmlNode child) WARN_UNUSED_RESULT
 
bool AddElements (const std::vector< Element > &elements) WARN_UNUSED_RESULT
 Adds Elements to this node using the Element struct.
 
bool SetStringAttribute (const std::string &attribute_name, const std::string &attribute) WARN_UNUSED_RESULT
 
bool SetIntegerAttribute (const std::string &attribute_name, uint64_t number) WARN_UNUSED_RESULT
 
bool SetFloatingPointAttribute (const std::string &attribute_name, double number) WARN_UNUSED_RESULT
 
bool SetId (uint32_t id) WARN_UNUSED_RESULT
 
void AddContent (const std::string &content)
 Similar to SetContent, but appends to the end of existing content.
 
void SetContent (const std::string &content)
 
std::set< std::string > ExtractReferencedNamespaces () const
 
std::string ToString (const std::string &comment) const
 
bool GetAttribute (const std::string &name, std::string *value) const
 

Friends

bool shaka::XmlEqual (const std::string &xml1, const xml::XmlNode &xml2)
 

Detailed Description

These classes are wrapper classes for XML elements for generating MPD. None of the pointer parameters should be NULL. None of the methods are meant to be overridden.

Definition at line 44 of file xml_node.h.

Constructor & Destructor Documentation

◆ XmlNode()

shaka::xml::XmlNode::XmlNode ( const std::string &  name)
explicit

Make an XML element.

Parameters
nameis the name of the element, which should not be NULL.

Definition at line 130 of file xml_node.cc.

Member Function Documentation

◆ AddChild()

bool shaka::xml::XmlNode::AddChild ( XmlNode  child)

Add a child element to this element.

Parameters
childis an XmlNode to add as a child for this element.
Returns
true on success, false otherwise.

Definition at line 141 of file xml_node.cc.

◆ ExtractReferencedNamespaces()

std::set< std::string > shaka::xml::XmlNode::ExtractReferencedNamespaces ( ) const
Returns
namespaces used in the node and its descendents.

Definition at line 219 of file xml_node.cc.

◆ GetAttribute()

bool shaka::xml::XmlNode::GetAttribute ( const std::string &  name,
std::string *  value 
) const

Gets the attribute with the given name.

Parameters
nameThe name of the attribute to get.
value[OUT] where to put the resulting value.
Returns
True if the attribute exists, false if not.

Definition at line 249 of file xml_node.cc.

◆ SetContent()

void shaka::xml::XmlNode::SetContent ( const std::string &  content)

Set the contents of an XML element using a string. This cannot set child elements because <> will become < and This should be used to set the text for the element, e.g. setting a URL for <BaseURL> element.

Parameters
contentis a string containing the text-encoded child elements to be added to the element.

Definition at line 214 of file xml_node.cc.

◆ SetFloatingPointAttribute()

bool shaka::xml::XmlNode::SetFloatingPointAttribute ( const std::string &  attribute_name,
double  number 
)

Set a floating point number attribute.

Parameters
attribute_nameis the name of the attribute to set.
numberis the value (rhs) of the attribute.

Definition at line 198 of file xml_node.cc.

◆ SetId()

bool shaka::xml::XmlNode::SetId ( uint32_t  id)

Sets 'id=id' attribute.

Parameters
idis the ID for this element.

Definition at line 205 of file xml_node.cc.

◆ SetIntegerAttribute()

bool shaka::xml::XmlNode::SetIntegerAttribute ( const std::string &  attribute_name,
uint64_t  number 
)

Sets an integer attribute.

Parameters
attribute_nameThe name (lhs) of the attribute.
numberThe value (rhs) of the attribute.

Definition at line 191 of file xml_node.cc.

◆ SetStringAttribute()

bool shaka::xml::XmlNode::SetStringAttribute ( const std::string &  attribute_name,
const std::string &  attribute 
)

Set a string attribute.

Parameters
attribute_nameThe name (lhs) of the attribute.
attributeThe value (rhs) of the attribute.

Definition at line 184 of file xml_node.cc.

◆ ToString()

std::string shaka::xml::XmlNode::ToString ( const std::string &  comment) const
Parameters
commentThe body of a comment to add to the top of the XML.
Returns
A string containing the XML.

Definition at line 225 of file xml_node.cc.


The documentation for this class was generated from the following files: