Samchon Framework for CPP
1.0.0
|
#include <XML.hpp>
Public Member Functions | |
XML () | |
Default Constructor. More... | |
XML (const XML &xml) | |
Copy Constructor. More... | |
XML (XML &&xml) | |
Move Constructor. More... | |
XML (WeakString wstr) | |
auto | getTag () const -> std::string |
Get tag. More... | |
auto | hasProperty (const std::string &key) const -> bool |
auto | getPropertyMap () const -> const HashMap< std::string, std::string > & |
template<class T = std::string> | |
auto | getValue () const -> T |
Get value. More... | |
template<class T = std::string> | |
auto | getProperty (const std::string &key) const -> T |
Get property. More... | |
auto | findProperty (const std::string &key) -> HashMap< std::string, std::string >::iterator |
void | setTag (const std::string &val) |
template<typename T > | |
void | setValue (const T &val) |
template<typename T > | |
void | setProperty (const std::string &key, const T &val) |
void | push_back (WeakString wstr) |
Add children xml objects by string representing them. More... | |
void | push_back (const std::shared_ptr< XML > xml) |
Add children xml. More... | |
void | insertAllProperties (const std::shared_ptr< XML > xml) |
void | eraseProperty (const std::string &key) |
void | clearProperties () |
auto | toString (size_t level=0) const -> std::string |
Public Member Functions inherited from samchon::HashMap< std::string, std::shared_ptr< XMLList > > | |
auto | has (const std::string &key) const -> bool |
Whether have the item or not. More... | |
auto | get (const std::string &key) -> std::shared_ptr< XMLList > & |
Get element. More... | |
void | set (const std::string &key, const std::shared_ptr< XMLList > &val) |
Set element. More... | |
auto | pop (const std::string &key) -> std::shared_ptr< XMLList > |
Pop item. More... | |
A tree-structured XML object.
The class contains methods and properties for working with XML objects. The XML class (along with the XMLList) implements the powerful XML-handling standards defined in ECMAScript for XML (E4X) specification (ECMA-357 edition 2).
An XML object, it is composed with three members; tag, properties and value. As you know, XML is a tree structured data expression method. The tree-stucture; XML class realizes it by extending std.HashMap<string, XMLList>
. Child XML objects are contained in the matched XMLList object being grouped by their tag name. The XMLList objects, they're stored in the std.HashMap (XML itself) with its key; common tag name of children XML objects.
Use the toString() method to return a string representation of the XML object regardless of whether the XML object has simple content or complex content.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html https://github.com/samchon/framework/wiki/CPP-Library-XML
|
inline |
Default Constructor.
Definition at line 93 of file XML.hpp.
Referenced by push_back(), and XML().
|
inline |
|
inline |
|
inline |
Construct from string.
Creates XML object by parsing a string who represents xml structure.
str | A string represents XML structure. |
Definition at line 144 of file XML.hpp.
References samchon::WeakString::between(), samchon::WeakString::find(), push_back(), samchon::WeakString::rfind(), samchon::HashMap< Key, T, Hash, Pred, Alloc >::set(), samchon::WeakString::size(), samchon::WeakString::substr(), samchon::WeakString::substring(), and XML().
|
inline |
|
inline |
Test whether a property exists.
Definition at line 461 of file XML.hpp.
References samchon::HashMap< Key, T, Hash, Pred, Alloc >::has().
Referenced by findProperty().
|
inline |
|
inline |
|
inline |
Get property.
Get property by its key, property name. If the matched key does not exist, then exception std.OutOfRange is thrown. Thus, it would better to test whether the key exits or not by calling the hasProperty() method before calling this getProperty().
This method can be substituted by getPropertyMap() such below:
getPropertyMap().get(key, value);
getPropertyMap().find(key).second;
Definition at line 537 of file XML.hpp.
References samchon::HashMap< Key, T, Hash, Pred, Alloc >::get().
|
inline |
Get iterator to property element.
Searches the properties for an element with a identifier equivalent to key and returns an iterator to it if found, otherwise it returns an iterator to end().
Two keys are considered equivalent if the properties' comparison object returns false reflexively (i.e., no matter the order in which the elements are passed as arguments).
Another member function, hasProperty() can be used to just check whether a particular key exists.
key | Key to be searched for |
Definition at line 580 of file XML.hpp.
References hasProperty().
|
inline |
Set tag.
Set tag name, identifier of this XML object.
If this XML object is belonged to, a child of, an XMLList and its related XML objects, then calling this setTag() method direclty is not recommended. Erase this XML object from parent objects and insert this object again.
val | To be new tag. |
|
inline |
Set value.
val | To be new value. |
Definition at line 635 of file XML.hpp.
References samchon::WeakString::str().
|
inline |
Set property.
Set a property value with its key. If the key already exists, then the value will be overwritten to the property. Otherwise the key is not exist yet, then insert the key and value pair to property map.
This method can be substituted by getPropertyMap() such below:
getPropertyMap().set(key, value);
getPropertyMap().emplace(key, value);
getPropertyMap().insert([key, value]);
getPropertyMap().insert(std.make_pair(key, value));
key | Key, identifier of property to be newly inserted. |
value | Value of new property to be newly inserted. |
Definition at line 682 of file XML.hpp.
References samchon::HashMap< Key, T, Hash, Pred, Alloc >::set(), and samchon::WeakString::str().
|
inline |
Add children xml objects by string representing them.
str | A string representing xml objects whould be belonged to this XML |
Definition at line 713 of file XML.hpp.
References samchon::WeakString::empty(), and XML().
Referenced by push_back(), and XML().
|
inline |
Add children xml.
xml | An xml object you want to add |
Definition at line 737 of file XML.hpp.
References samchon::HashMap< std::string, std::shared_ptr< XMLList > >::has(), push_back(), and XML().
|
inline |
Add all properties from other XML object.
All the properties in the obj are copied to this XML object. If this XML object has same property key in the obj, then value of the property will be replaced to obj's own. If you don't want to overwrite properties with same key, then use getPropertyMap() method.
obj | Target XML object to copy properties. |
|
inline |
Erase property.
Erases a property by its key, property name. If the matched key does not exist, then exception std.OutOfRange is thrown. Thus, it would better to test whether the key exits or not by calling the hasProperty() method before calling this eraseProperty().
This method can be substituted by getPropertyMap().erase(key)
``.
key | Key of the property to erase |
{ |
|
inline |
Clear properties.
Remove all properties. It's same with calling getPropertyMap().clear()
.
Definition at line 819 of file XML.hpp.
References samchon::WeakString::replaceAll().
|
inline |