22#define TIXML_USE_TICPP
44 if (0 != firstAttribute) {
129 if (0 == attribute) {
130 if (throwIfNoAttribute) {
147 if (0 == attribute) {
148 if (throwIfNoAttribute) {
183 bool rememberSpawnedWrapper)
const {
184 if (0 == tiXmlNode) {
194 switch (tiXmlNode->
Type()) {
223 if (rememberSpawnedWrapper) {
237 if ((0 == parent) && throwIfNoParent) {
249 return FirstChild(value.c_str(), throwIfNoChildren);
255 if (0 == strlen(value)) {
261 if ((0 == childNode) && throwIfNoChildren) {
262 TICPPTHROW(
"Child with the value of \"" << value <<
"\" not found");
273 return LastChild(value.c_str(), throwIfNoChildren);
279 if (0 == strlen(value)) {
285 if ((0 == childNode) && throwIfNoChildren) {
286 TICPPTHROW(
"Child with the value of \"" << value <<
"\" not found");
319 TICPPTHROW(
"Node is a Document and can't be inserted");
334 TICPPTHROW(
"Node is a Document and can't be linked");
349 TICPPTHROW(
"Node is a Document and can't be inserted");
367 TICPPTHROW(
"Node is a Document and can't be inserted");
385 TICPPTHROW(
"Node is a Document and can't be inserted");
404 <<
") is not a child of this Node ("
415 bool throwIfNoSiblings)
const {
422 if (0 == strlen(value)) {
428 if ((0 == sibling) && throwIfNoSiblings) {
429 TICPPTHROW(
"No Siblings found with value, '" << value
430 <<
"', Prior to this Node ("
443 return NextSibling(value.c_str(), throwIfNoSiblings);
449 if (0 == strlen(value)) {
455 if ((0 == sibling) && throwIfNoSiblings) {
456 TICPPTHROW(
"No Siblings found with value, '" << value <<
"', After this Node ("
469 bool throwIfNoSiblings)
const {
474 bool throwIfNoSiblings)
const {
477 if (0 == strlen(value)) {
484 if (throwIfNoSiblings) {
485 TICPPTHROW(
"No Element Siblings found with value, '"
487 <<
"', After this Node ("
495 Element* temp =
new Element(sibling);
506 bool throwIfNoChildren)
const {
513 if (0 == strlen(value)) {
520 if (throwIfNoChildren) {
522 <<
") does NOT contain a child with the value of '"
530 Element* temp =
new Element(element);
531 element->m_spawnedWrappers.push_back(temp);
542 if (throwIfNoDocument) {
543 TICPPTHROW(
"This node (" <<
Value() <<
") is not linked under a document")
626 TICPPTHROW(
"This node (" <<
Value() <<
") is not a StylesheetReference")
642 std::unique_ptr< Node > temp(
NodeFactory(node,
false,
false));
736 bool throwIfParseError,
749 "DefaultValueCausedByCreatingAnElementWithNoParameters")) {
770 if ((0 == attribute) && throwIfNoAttributes) {
774 if (0 == attribute) {
775 if (throwIfNoAttributes) {
792 if ((0 == attribute) && throwIfNoAttributes) {
796 if (0 == attribute) {
797 if (throwIfNoAttributes) {
811 const std::string& defaultValue)
const {
876 const std::string& encoding,
877 const std::string& standalone)
903 const std::string& href)
930 std::vector< Base* >::reverse_iterator wrapper;
941 DeleteSpawnedWrappers();
944 this->m_tiRC->Nullify();
947 this->m_tiRC->DecRef();
TiCppRC * m_tiCppRC
Holds pointer to an object inheriting TiCppRC.
void DecRef()
Decrement Reference Count.
int m_count
Holds reference count to me, and to the node I point to.
TiCppRCImp(TiCppRC *tiCppRC)
Initializes m_tiCppRC pointer, and set reference count to 1.
void Nullify()
Allows the TiCppRC object to set the pointer to itself ( m_tiCppRc ) to nullptr when the TiCppRC obje...
bool IsNull()
Returns state of internal pointer - will be null if the object was deleted.
void IncRef()
Increment Reference Count.
void InitRef()
Set Reference Count to 1 - dangerous!
TiCppRC * Get()
Get internal pointer to the TiCppRC object - not reference counted, use at your own risk.
Base class for reference counting functionality.
void DeleteSpawnedWrappers()
Delete all container objects we've spawned with 'new'.
TiCppRC()
Constructor Spawns new reference counter with a pointer to this.
virtual ~TiCppRC()
Destructor Nullifies the pointer to this held by the reference counter Decrements reference count.
std::vector< ticpp::Base * > m_spawnedWrappers
Remember all wrappers that we've created with 'new' - ( e.g.
An attribute is a name-value pair.
In correct XML the declaration is the first entry in the file.
Always the top level node.
The element is a container class.
The parent class for everything in the Document Object Model.
int Type() const
Query the type (as an enumerated value, above) of this node.
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
const std::string & ValueStr() const
Return Value() as a std::string.
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
void Clear()
Delete all the children of this node. Does not affect 'this'.
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
const TiXmlNode * LastChild() const
TiXmlNode * Parent()
One step up the DOM.
bool NoChildren() const
Returns true if this node has no children.
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
virtual bool Accept(TiXmlVisitor *visitor) const =0
Accept a hierchical visit the nodes in the TinyXML DOM.
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
A stylesheet reference looks like this:
Any tag that tinyXml doesn't recognize is saved as an unknown.
If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Wrapper around TiXmlAttribute.
std::string Name() const
Get the value of this attribute.
std::string Value() const
Get the value of this attribute.
void operator=(const Attribute ©)
virtual void Print(FILE *file, int depth) const
All TinyXml classes can print themselves to a filestream.
void IterateNext(const std::string &, Attribute **next) const
Attribute()
Construct an empty attribute.
Attribute * Previous(bool throwIfNoAttribute=true) const
Get the previous sibling attribute in the DOM.
Attribute * Next(bool throwIfNoAttribute=true) const
Get the next sibling attribute in the DOM.
TiXmlAttribute * m_tiXmlPointer
void SetTiXmlPointer(TiXmlAttribute *newPointer)
void IteratePrevious(const std::string &, Attribute **previous) const
Wrapper around TiXmlBase.
void SetImpRC(TiXmlBase *nodeBase)
TiCppRCImp * m_impRC
Holds status of internal TiXmlPointer - use this to determine if object has been deleted already.
void ValidatePointer() const
Wrapper around TiXmlDeclaration.
std::string Encoding() const
Encoding.
Declaration()
Default Constructor.
std::string Standalone() const
StandAlone.
std::string Version() const
Version.
Wrapper around TiXmlDocument.
void LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Load a file using the current document value.
void Parse(const std::string &xml, bool throwIfParseError=true, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given xml data.
void SaveFile() const
Save a file using the current document value.
Document()
Default Constructor.
Wrapper around TiXmlElement.
bool GetTextImp(std::string *value) const
bool GetAttributeImp(const std::string &name, std::string *value) const
Attribute * LastAttribute(bool throwIfNoAttributes=true) const
Access the last attribute in this element.
void RemoveAttribute(const std::string &name)
Removes attribute from element.
Attribute * FirstAttribute(bool throwIfNoAttributes=true) const
Access the first attribute in this element.
Element()
Default Constructor.
T GetAttribute(const std::string &name, bool throwIfNotFound=true) const
Returns an attribute of name from an element.
bool HasAttribute(const std::string &name) const
Returns true, if attribute exists.
void GetAttributeOrDefault(const std::string &name, T *value, const DefaulT &defaultValue) const
Gets an attribute of name from an element, if it doesn't exist it will return the defaultValue.
std::string m_details
Exception Details.
const char * what() const
Override std::exception::what() to return m_details.
Exception(const std::string &details)
Construct an exception with a message.
NodeImp(TiXmlComment *tiXmlPointer)
TiXmlComment * m_tiXmlPointer
Wrapper around TiXmlNode.
Comment * ToComment() const
Pointer conversion - replaces TiXmlNode::ToComment.
Node * ReplaceChild(Node *replaceThis, Node &withThis)
Replace a child of this node.
Declaration * ToDeclaration() const
Pointer conversion - replaces TiXmlNode::ToDeclaration.
std::unique_ptr< Node > Clone() const
Create an exact duplicate of this node and return it.
StylesheetReference * ToStylesheetReference() const
Pointer conversion - replaces TiXmlNode::ToStylesheetReference.
Element * FirstChildElement(bool throwIfNoChildren=true) const
The first child element of this node.
Node * Parent(bool throwIfNoParent=true) const
The Parent of this Node.
bool Accept(TiXmlVisitor *visitor) const
Accept a hierchical visit the nodes in the TinyXML DOM.
void Clear()
Clear all Nodes below this.
bool NoChildren() const
Check if this node has no children.
void RemoveChild(Node *removeThis)
Delete a child of this node.
Document * ToDocument() const
Pointer conversion - replaces TiXmlNode::ToDocument.
std::string Value() const
Get the value of this node.
Node * NodeFactory(TiXmlNode *tiXmlNode, bool throwIfNull=true, bool rememberSpawnedWrapper=true) const
Element * NextSiblingElement(bool throwIfNoSiblings=true) const
Navigate to a sibling element.
Node * InsertAfterChild(Node *afterThis, Node &addThis)
Adds a child after the specified child.
Node * InsertEndChild(Node &addThis)
Adds a child past the LastChild.
Node * LastChild(bool throwIfNoChildren=true) const
The last child of this node.
Node * InsertBeforeChild(Node *beforeThis, Node &addThis)
Adds a child before the specified child.
Node * NextSibling(bool throwIfNoSiblings=true) const
Navigate to a sibling node.
Document * GetDocument(bool throwIfNoDocument=true) const
Return a pointer to the Document this node lives in.
Node * IterateChildren(Node *previous) const
An alternate way to walk the children of a node.
int Type() const
Query the type (as TiXmlNode::NodeType ) of this node.
Node * PreviousSibling(bool throwIfNoSiblings=true) const
Navigate to a sibling node.
virtual TiXmlNode * GetTiXmlPointer() const =0
Node * LinkEndChild(Node *childNode)
Adds a child past the LastChild.
Node * FirstChild(bool throwIfNoChildren=true) const
The first child of this node.
Element * ToElement() const
Pointer conversion - replaces TiXmlNode::ToElement.
Text * ToText() const
Pointer conversion - replaces TiXmlNode::ToText.
Wrapper around TiXmlStylesheetReference.
std::string Href() const
Href.
StylesheetReference()
Default Constructor.
std::string Type() const
Type.
Wrapper around TiXmlText.
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
ticpp is a TinyXML wrapper that uses a lot more C++ ideals.
ticpp is a TinyXML wrapper that uses a lot more C++ ideals.
#define TICPPTHROW(message)
This allows you to stream your exceptions in.