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)
 
bool AddElements (const std::vector< Element > &elements)
 Adds Elements to this node using the Element struct.
 
bool SetStringAttribute (const std::string &attribute_name, const std::string &attribute)
 
bool SetIntegerAttribute (const std::string &attribute_name, uint64_t number)
 
bool SetFloatingPointAttribute (const std::string &attribute_name, double number)
 
bool SetId (uint32_t id)
 
void AddContent (const std::string &content)
 Similar to SetContent, but appends to the end of existing content.
 
void AddUrlEncodedContent (const std::string &content)
 
void SetContent (const std::string &content)
 
void SetUrlEncodedContent (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 42 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 151 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 162 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 249 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 279 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 240 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 220 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 227 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 212 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 205 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 255 of file xml_node.cc.


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