Class represents an XML tag. More...
#include <loaders/xml.h>
Inherited by nitro::XMLFile.
Public Member Functions | |
XMLTag (void) | |
XMLTag (const XMLTag &XMLTag) | |
void | AddAttribute (const char *AttributeName, const char *AttributeValue) |
void | AddTag (const char *TagName) |
void | AddTag (const XMLTag &XMLTag) |
bool | AttributeExists (const char *AttributeName) const |
bool | TagExists (char *TagName) const |
void | DeleteTag (std::size_t TagCursor) |
void | DeleteTag (const char *TagName) |
float | GetAttribute_float (const char *AttributeName) const |
bool | GetAttribute_bool (const char *AttributeName) const |
int | GetAttribute_int (const char *AttributeName) const |
const char * | GetAttribute_string (const char *AttributeName) const |
int | GetTagCursor (const char *TagName) const |
std::size_t | CountOfChildTags (void) const |
std::size_t | CountOfAttributes (void) const |
const char * | GetAttributeName (std::size_t AttributeCursor) const |
XMLTag & | operator[] (const char *TagName) const |
XMLTag & | operator[] (const int TagCursor) const |
XMLTag & | operator[] (const std::size_t TagCursor) const |
XMLTag & | GetTag (std::size_t TagCursor) |
XMLTag & | GetTag (const char *AttributeName, const char *AttributeValue) |
XMLTag & | LastTag (void) |
void | MoveTag (std::size_t TagCursor, XMLTag &DestTag) |
void | SaveXML (nitro::FileAbstraction &File, char *TabSpace) const |
void | SetName (const std::string &Name) |
void | SetAttribute (const char *AttributeName, const char *AttributeValue) |
void | Release (void) |
virtual | ~XMLTag () |
Public Attributes | |
std::string | Name |
Protected Member Functions | |
int | ProcessAttributes (std::vector< std::string > &Lexemmas, std::size_t &i) |
bool | IsClosingTag (std::vector< std::string > &Lexemmas, std::size_t &i) |
void | SaveXMLToANSIString (std::string &Str, char *TabSpace) |
void | LoadXML (std::vector< std::string > &Lexemmas, std::size_t &i, std::list< nitro::BinaryData > &CDATA, std::list< nitro::BinaryData >::iterator &j) |
Protected Attributes | |
std::vector< XMLTag * > | Tags |
std::vector< std::string > | Attributes |
std::vector< std::string > | Values |
nitro::BinaryData | InnerData |
Private Member Functions | |
XMLTag | operator= (const XMLTag &) |
Class represents an XML tag.
This class provides main routine for processing xml files (read/write/delete/append).
Definition at line 59 of file xml.h.
nitro::XMLTag::XMLTag | ( | void | ) |
nitro::XMLTag::XMLTag | ( | const XMLTag & | XMLTag | ) |
Copy-constructor.
XMLTag | - Assigning object. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 93 of file xml.cpp.
References Attributes, nitro::exception::code(), Name, Tags, Values, nitro::exception::what(), and XMLTag().
{ try { for( std::size_t i( 0 ) ; i < Tag.Tags.size() ; i++ ) { Tags.push_back( new XMLTag( * Tag.Tags[ i ] ) ); } Name = Tag.Name; std::copy( Tag.Attributes.begin() , Tag.Attributes.end() , std::back_inserter( Attributes ) ); std::copy( Tag.Values.begin() , Tag.Values.end() , std::back_inserter( Values ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::XMLTag( const XMLTag & XMLTag )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::XMLTag( const XMLTag & XMLTag )::An error occured" ) , 1 ) ); } }
nitro::XMLTag::~XMLTag | ( | ) | [virtual] |
void nitro::XMLTag::AddAttribute | ( | const char * | AttributeName, | |
const char * | AttributeValue | |||
) |
Definition at line 233 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
{ try { Attributes.push_back( std::string( AttributeName ) ); Values.push_back( std::string( AttributeValue ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::AddAttribute( const char * AttributeName , const char * AttributeValue )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::AddAttribute( const char * AttributeName , const char * AttributeValue )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::AddTag | ( | const char * | TagName | ) |
Definition at line 250 of file xml.cpp.
References nitro::exception::code(), Tags, nitro::exception::what(), and XMLTag().
{ try { Tags.push_back( new XMLTag() ); Tags.back()->Name = TagName; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::AddTag( const char * TagName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::AddTag( const char * TagName )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::AddTag | ( | const XMLTag & | XMLTag | ) |
Definition at line 267 of file xml.cpp.
References nitro::exception::code(), Tags, nitro::exception::what(), and XMLTag().
{ try { Tags.push_back( new XMLTag( Tag ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::AddTag( const XMLTag & XMLTag )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::AddTag( const XMLTag & XMLTag )::An error occured" ) , 1 ) ); } }
bool nitro::XMLTag::AttributeExists | ( | const char * | AttributeName | ) | const |
Definition at line 283 of file xml.cpp.
References Attributes, nitro::exception::code(), and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( AttributeName == Attributes[ i ] ) { return( true ); } } return( false ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::AttributeExists( const char * AttributeName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::AttributeExists( const char * AttributeName ) const::An error occured" ) , 1 ) ); } }
std::size_t nitro::XMLTag::CountOfAttributes | ( | void | ) | const |
Function returns count of attributes
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 52 of file xml.cpp.
References Attributes, nitro::exception::code(), and nitro::exception::what().
{ try { return( Attributes.size() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::CountOfAttributes( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::CountOfAttributes( void )::An error occured" ) , 1 ) ); } }
std::size_t nitro::XMLTag::CountOfChildTags | ( | void | ) | const |
Function returns count of shild tags
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 36 of file xml.cpp.
References nitro::exception::code(), Tags, and nitro::exception::what().
Referenced by nitro::MVC::Create().
{ try { return( Tags.size() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::CountOfChildTags( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::CountOfChildTags( void )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::DeleteTag | ( | std::size_t | TagCursor | ) |
Function deletes tag.
TagCursor | - |
Definition at line 329 of file xml.cpp.
References nitro::exception::code(), Tags, and nitro::exception::what().
{ try { Tags[ TagCursor ]->Release(); Tags.erase( Tags.begin() + TagCursor ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::DeleteTag( std::size_t TagCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::DeleteTag( std::size_t TagCursor )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::DeleteTag | ( | const char * | TagName | ) |
Function deletes all tags with name TagName.
TagName | - |
bool nitro::XMLTag::GetAttribute_bool | ( | const char * | AttributeName | ) | const |
Название атрибута.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - attribute's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 883 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( Attributes[ i ] == AttributeName ) { return( std::string( "true" ) == Values[ i ] ); } } throw( nitro::exception( ( std::string( "Attribute \"" ) + AttributeName + "\" was not found" ).c_str() , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_bool( const char * AttributeName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_bool( const char * AttributeName ) const::An error occured" ) , 1 ) ); } }
float nitro::XMLTag::GetAttribute_float | ( | const char * | AttributeName | ) | const |
Название атрибута.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - attribute's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 859 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( Attributes[ i ] == AttributeName ) { return( ( float )atof( Values[ i ].c_str() ) ); } } throw( nitro::exception( ( std::string( "Attribute \"" ) + AttributeName + "\" was not found" ).c_str() , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_float( const char * AttributeName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_float( const char * AttributeName ) const::An error occured" ) , 1 ) ); } }
int nitro::XMLTag::GetAttribute_int | ( | const char * | AttributeName | ) | const |
Название атрибута.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - attribute's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 835 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( Attributes[ i ] == AttributeName ) { return( atoi( Values[ i ].c_str() ) ); } } throw( nitro::exception( ( std::string( "Attribute \"" ) + AttributeName + "\" was not found" ).c_str() , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_int( const char * AttributeName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_int( const char * AttributeName ) const::An error occured" ) , 1 ) ); } }
const char * nitro::XMLTag::GetAttribute_string | ( | const char * | AttributeName | ) | const |
Название атрибута.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - attribute's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 907 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
Referenced by nitro::MVC::Create().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( Attributes[ i ] == AttributeName ) { return( Values[ i ].c_str() ); } } throw( nitro::exception( ( std::string( "Attribute \"" ) + AttributeName + "\" was not found" ).c_str() , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_string( const char * AttributeName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetAttribute_string( const char * AttributeName ) const::An error occured" ) , 1 ) ); } }
const char * nitro::XMLTag::GetAttributeName | ( | std::size_t | AttributeCursor | ) | const |
Function returns name of attribute.
AttributeCursor | - Cursor of the attribute. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 68 of file xml.cpp.
References Attributes, nitro::exception::code(), and nitro::exception::what().
{ try { if( Attributes.size() >= AttributeCursor ) { throw( nitro::exception( "Illegal attribute's cursor" , 1 ) ); } return( Attributes[ AttributeCursor ].c_str() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetAttributeName( std::size_t AttributeCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetAttributeName( std::size_t AttributeCursor )::An error occured" ) , 1 ) ); } }
XMLTag & nitro::XMLTag::GetTag | ( | std::size_t | TagCursor | ) |
Function returns tag by it's cursor.
TagCursor | - Tag's cursor. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 418 of file xml.cpp.
References nitro::exception::code(), and nitro::exception::what().
{ try { return( ( * this )[ TagCursor ] ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::GetTag( std::size_t TagCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::GetTag( std::size_t TagCursor )::An error occured" ) , 1 ) ); } }
XMLTag& nitro::XMLTag::GetTag | ( | const char * | AttributeName, | |
const char * | AttributeValue | |||
) |
Function returns tag with the specified attribute valur.
AttributeName | - Attributes name. | |
AttributeValue | - Attributes value. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
int nitro::XMLTag::GetTagCursor | ( | const char * | TagName | ) | const |
Function returns tag's cursor by it's name.
TagName | - |
bool nitro::XMLTag::IsClosingTag | ( | std::vector< std::string > & | Lexemmas, | |
std::size_t & | i | |||
) | [protected] |
Function for detecting closing tags (tags with "/"). Returns true if selected tag is closing. Otherwise returns false.
Lexemmas | - XML file splitted into tag names, tag parameters and special simbols. | |
i | - cursor for array Lexemmas. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
Lexemmas | - XML file splitted into tag names, tag parameters and special simbols. | |
i | - cursor for array Lexemmas. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 981 of file xml.cpp.
References nitro::exception::code(), nitro::IsTagName(), Name, and nitro::exception::what().
Referenced by LoadXML().
{ try { if( i + 3 < Lexemmas.size() ) { if( Lexemmas[ i ] == "<" && Lexemmas[ i + 1 ] == "/" && Lexemmas[ i + 2 ] == Name && Lexemmas[ i + 3 ] == ">" ) { i += 4; return( true ); } else { if( Lexemmas[ i ] == "<" && IsTagName( Lexemmas[ i + 1 ] ) ) { return( false ); } else { throw( nitro::exception( std::string( "Bad XML structure #" ) + Lexemmas[ i ] + "#" + Lexemmas[ i + 1 ] , 1 ) ); } } } return( false ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::IsClosingTag( std::vector< std::string > & Lexemmas , std::size_t & i )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::IsClosingTag( std::vector< std::string > & Lexemmas , std::size_t & i )::An error occured" ) , 1 ) ); } }
XMLTag & nitro::XMLTag::LastTag | ( | void | ) |
Function returns last tag.
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 346 of file xml.cpp.
References nitro::exception::code(), Tags, and nitro::exception::what().
{ try { return( *( Tags.back() ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::LastTag( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::LastTag( void )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::LoadXML | ( | std::vector< std::string > & | Lexemmas, | |
std::size_t & | i, | |||
std::list< nitro::BinaryData > & | CDATA, | |||
std::list< nitro::BinaryData >::iterator & | j | |||
) | [protected] |
Function loads XML files.
Lexemmas | - XML file splitted into tag names, tag parameters and special simbols. | |
i | - cursor for array Lexemmas. | |
CDATA | - List of objects with binary data. | |
j | - Iterator for list CDATA. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 1127 of file xml.cpp.
References nitro::exception::code(), IsClosingTag(), nitro::IsTagName(), Name, ProcessAttributes(), Tags, nitro::exception::what(), and XMLTag().
{ try { if( IsClosingTag( Lexemmas , i ) ) { return; } if( Lexemmas[ i ] == "<" ) { if( i + 1 < Lexemmas.size() ) { if( IsTagName( Lexemmas[ i + 1 ] ) ) { Name = Lexemmas[ i + 1 ]; i += 2; if( !ProcessAttributes( Lexemmas , i ) ) { return; } } else { throw( nitro::exception( "Bad XML structure" , 1 ) ); } } } else { throw( nitro::exception( "Bad XML structure" , 1 ) ); } if( IsClosingTag( Lexemmas , i ) ) { return; } for( ; i < Lexemmas.size() ; ) { Tags.push_back( new XMLTag() ); if( Lexemmas[ i ] == "<![CDATA[" ) { Tags.back()->InnerData.AppendData( j->GetBuffer() , j->GetBufferLength() ); Tags.back()->Name = "cdata"; j++; i++; continue; } Tags.back()->LoadXML( Lexemmas , i , CDATA , j ); if( IsClosingTag( Lexemmas , i ) ) { return; } } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::LoadXML( std::vector< std::string > & Lexemmas , std::size_t & i , std::list< nitro::BinaryData > & CDATA , std::list< nitro::BinaryData >::iterator & j )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::LoadXML( std::vector< std::string > & Lexemmas , std::size_t & i , std::list< nitro::BinaryData > & CDATA , std::list< nitro::BinaryData >::iterator & j )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::MoveTag | ( | std::size_t | TagCursor, | |
XMLTag & | DestTag | |||
) |
Function copyes tag.
TagCursor | - Tag's cursor. | |
DestTag | - Object of the destination tag. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 362 of file xml.cpp.
References nitro::exception::code(), Tags, and nitro::exception::what().
{ try { DestTag.Tags.push_back( Tags[ TagCursor ] ); Tags.erase( Tags.begin() + TagCursor ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::MoveTag( std::size_t TagCursor , XMLTag &DestTag )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::MoveTag( std::size_t TagCursor , XMLTag &DestTag )::An error occured" ) , 1 ) ); } }
XMLTag & nitro::XMLTag::operator[] | ( | const char * | TagName | ) | const |
Operator for tag selection.
TagName | - tag's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 209 of file xml.cpp.
References nitro::exception::code(), Name, Tags, and nitro::exception::what().
{ try { std::string TagName( TagName ); for( std::size_t i( 0 ) ; i < Tags.size() ; i++ ) { if( TagName == Tags[ i ]->Name ) { return( * Tags[ i ] ); } } throw( nitro::exception( std::string( "Tag " ) + TagName + " was not found" , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( const char * TagName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( const char * TagName )::An error occured" ) , 1 ) ); } }
XMLTag & nitro::XMLTag::operator[] | ( | const std::size_t | TagCursor | ) | const |
Operator for tag selection.
TagCursor | - tag' cursor in Tags. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 395 of file xml.cpp.
References nitro::exception::code(), nitro::Converters::itoa(), Tags, and nitro::exception::what().
{ try { if( Tags.size() <= TagCursor ) { std::string StrTagCursor; nitro::Converters::itoa( ( int )TagCursor , StrTagCursor ); throw( nitro::exception( std::string ( "Tag with cursor " ) + StrTagCursor + " was not found" , 1 ) ); } return( * Tags[ TagCursor ] ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( std::size_t TagCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( std::size_t TagCursor )::An error occured" ) , 1 ) ); } }
XMLTag & nitro::XMLTag::operator[] | ( | const int | TagCursor | ) | const |
Operator for tag selection.
TagCursor | - tag' cursor in Tags. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 379 of file xml.cpp.
References nitro::exception::code(), and nitro::exception::what().
{ try { return( ( * this )[ ( std::size_t )TagCursor ] ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( std::size_t TagCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::operator[] ( std::size_t TagCursor )::An error occured" ) , 1 ) ); } }
int nitro::XMLTag::ProcessAttributes | ( | std::vector< std::string > & | Lexemmas, | |
std::size_t & | i | |||
) | [protected] |
Function for processing tag parameters while loading xml file.
Lexemmas | - XML file splitted into tag names, tag parameters and special simbols. | |
i | - cursor for array Lexemmas. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
Lexemmas | - XML file splitted into tag names, tag parameters and special simbols. | |
i | - cursor for array Lexemmas. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 931 of file xml.cpp.
References Attributes, nitro::exception::code(), nitro::IsTagName(), Values, and nitro::exception::what().
Referenced by LoadXML().
{ try { for( ; i < Lexemmas.size() ; ) { // additing attribute if( i + 4 < Lexemmas.size() ) { if( IsTagName( Lexemmas[ i ] ) && Lexemmas[ i + 1 ] == "=" && Lexemmas[ i + 2 ] == "\"" && Lexemmas[ i + 4 ] == "\"" ) { Attributes.push_back( Lexemmas[ i ] ); Values.push_back( Lexemmas[ i + 3 ] ); i += 5; goto end; } } // closing tag was not found if( i + 1 < Lexemmas.size() ) { if( Lexemmas[ i ] == "/" && Lexemmas[ i + 1 ] == ">" ) { i += 2; return( 0 ); } } // there must be closing tag if( Lexemmas[ i ] == ">" ) { i += 1; return( 1 ); } throw( nitro::exception( "Bad XML structure" , 1 ) ); end:; } return( 2 ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::ProcessAttributes( std::vector< std::string > & Lexemmas , std::size_t & i )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::ProcessAttributes( std::vector< std::string > & Lexemmas , std::size_t & i )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::Release | ( | void | ) |
Releasing all memory.
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 177 of file xml.cpp.
References nitro::exception::code(), Tags, and nitro::exception::what().
Referenced by nitro::XMLFile::~XMLFile(), and ~XMLTag().
{ try { for( std::size_t i( 0 ) ; i < Tags.size() ; i++ ) { Tags[ i ]->Release(); } Tags.clear(); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::Release( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::Release( void )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::SaveXML | ( | nitro::FileAbstraction & | File, | |
char * | TabSpace | |||
) | const |
Function for saving XML file into file.
File | - file stream | |
TabSpace | -string formatting output xml |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 672 of file xml.cpp.
References Attributes, nitro::exception::code(), Name, Tags, Values, nitro::exception::what(), and nitro::FileAbstraction::Write().
{ try { std::string str; char new_TabSpace[ 2048 ]; str = TabSpace; str += "<"; str += Name; for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { str += " "; str += Attributes[ i ]; str += "="; str += "\""; str += Values[ i ]; str += "\""; } if( !Tags.size() ) { str += " /"; str += ">\n"; File.Write( str.c_str() , str.length() ); } else { str += ">\n"; File.Write( str.c_str() , str.length() ); strcpy( new_TabSpace , TabSpace ); strcat( new_TabSpace , "\t" ); for( std::size_t i( 0 ) ; i < Tags.size() ; i++ ) { Tags[ i ]->SaveXML( File , new_TabSpace ); } str = TabSpace; str += "<"; str += "/"; str += Name; str += ">\n"; File.Write( str.c_str() , str.length() ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::SaveXML( nitro::FileAbstraction & File , char * TabSpace )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::SaveXML( nitro::FileAbstraction & File , char * TabSpace )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::SaveXMLToANSIString | ( | std::string & | Str, | |
char * | TabSpace | |||
) | [protected] |
Definition at line 1071 of file xml.cpp.
References Attributes, nitro::exception::code(), Name, Tags, Values, and nitro::exception::what().
{ try { char new_TabSpace[ 2048 ]; Str += "\r\n"; Str += TabSpace; Str += "<"; Str += Name; if( Attributes.size() ) { Str += " "; for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { Str += Attributes[ i ]; Str += " "; Str += "="; Str += " "; Str += "\""; Str += Values[ i ]; Str += "\""; } } else { Str += "/"; } Str += ">"; strcpy( new_TabSpace , TabSpace ); strcat( new_TabSpace , "\t" ); for( std::size_t i( 0 ) ; i < Tags.size() ; i++ ) { Tags[ i ]->SaveXMLToANSIString( Str , new_TabSpace ); } Str += "\r\n"; Str += TabSpace; Str += "<"; Str += "/"; Str += Name; Str += ">"; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::SaveXMLToANSIString( std::string & Str , char * TabSpace )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::SaveXMLToANSIString( std::string & Str , char * TabSpace )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::SetAttribute | ( | const char * | AttributeName, | |
const char * | AttributeValue | |||
) |
Function sets attribute's value.
AttributeName | - Name of the setting attribute. | |
AttributeValue | - New value of the attribute. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 747 of file xml.cpp.
References Attributes, nitro::exception::code(), Values, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Attributes.size() ; i++ ) { if( Attributes[ i ] == AttributeName ) { Values[ i ] = AttributeValue; return; } } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::SetAttribute( const char * AttributeName , const char * AttributeValue )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::SetAttribute( const char * AttributeName , const char * AttributeValue )::An error occured" ) , 1 ) ); } }
void nitro::XMLTag::SetName | ( | const std::string & | Name | ) |
Function sets tag's name.
Name | - Tag's name. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 731 of file xml.cpp.
References nitro::exception::code(), Name, and nitro::exception::what().
{ try { Name = NewName.c_str(); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::SetName( const std::string & Name )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::SetName( const std::string & Name )::An error occured" ) , 1 ) ); } }
bool nitro::XMLTag::TagExists | ( | char * | TagName | ) | const |
Function for checking inner tag existence. Returns true if tag exist. Otherwise returns false.
TagName | - tag's name |
nitro::exception | Function for checking inner tag existence. Returns true if tag exist. Otherwise returns false. |
TagName | - tag's name |
nitro::exception | An exception of that type is thrown if ahy error occured. |
Definition at line 306 of file xml.cpp.
References nitro::exception::code(), Name, Tags, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Tags.size() ; i++ ) { if( Tags[ i ]->Name == TagName ) { return( true ); } } return( false ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "XMLTag::TagExists( char * TagName ) const::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "XMLTag::TagExists( char * TagName ) const::An error occured" ) , 1 ) ); } }
std::vector< std::string > nitro::XMLTag::Attributes [protected] |
Names of the attributes.
Definition at line 732 of file xml.h.
Referenced by AddAttribute(), AttributeExists(), CountOfAttributes(), GetAttribute_bool(), GetAttribute_float(), GetAttribute_int(), GetAttribute_string(), GetAttributeName(), ProcessAttributes(), SaveXML(), SaveXMLToANSIString(), SetAttribute(), and XMLTag().
nitro::BinaryData nitro::XMLTag::InnerData [protected] |
std::string nitro::XMLTag::Name |
TAg's name.
Definition at line 110 of file xml.h.
Referenced by IsClosingTag(), LoadXML(), operator[](), SaveXML(), SaveXMLToANSIString(), SetName(), TagExists(), and XMLTag().
std::vector< XMLTag * > nitro::XMLTag::Tags [protected] |
Set of inner tags.
Definition at line 720 of file xml.h.
Referenced by AddTag(), CountOfChildTags(), DeleteTag(), LastTag(), LoadXML(), MoveTag(), operator[](), Release(), SaveXML(), SaveXMLToANSIString(), TagExists(), and XMLTag().
std::vector< std::string > nitro::XMLTag::Values [protected] |
Values of the tag's attributes.
Definition at line 744 of file xml.h.
Referenced by AddAttribute(), GetAttribute_bool(), GetAttribute_float(), GetAttribute_int(), GetAttribute_string(), ProcessAttributes(), SaveXML(), SaveXMLToANSIString(), SetAttribute(), and XMLTag().