Класс представляющий xml тэг. Подробнее...
#include <loaders/xml.h>
Производные классы:nitro::XMLFile.
Открытые члены | |
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 () |
Открытые атрибуты | |
std::string | Name |
Защищенные члены | |
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) |
Защищенные данные | |
std::vector< XMLTag * > | Tags |
std::vector< std::string > | Attributes |
std::vector< std::string > | Values |
nitro::BinaryData | InnerData |
Закрытые члены | |
XMLTag | operator= (const XMLTag &) |
Класс представляющий xml тэг.
Этот класс содержит основные функции для работы с атрибутами xml файлов (чтение/запись/удаление/добавление).
См. определение в файле xml.h строка 59
nitro::XMLTag::XMLTag | ( | void | ) |
Конструктор по умолчанию.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 89
Используется в AddTag(), LoadXML() и XMLTag().
{ }
nitro::XMLTag::XMLTag | ( | const XMLTag & | XMLTag | ) |
Конструктор копирования.
XMLTag | - Тэг, по которому будем конструировать *this. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 93
Перекрестные ссылки Attributes, nitro::exception::code(), Name, Tags, Values, nitro::exception::what() и 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 | |||
) |
Функция добавляет атрибут к тэгу.
AttributeName | - имя атрибута | |
AttributeValue | - значение атрибута |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - имя атрибута | |
AttributeValue | - значение атрибута |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 233
Перекрестные ссылки Attributes, nitro::exception::code(), Values и 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 | ) |
Функция добавляет тэг с одним атрибутом.
TagName | - имя тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
TagName | - имя тэга. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 250
Перекрестные ссылки nitro::exception::code(), Tags, nitro::exception::what() и 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 | ) |
Функция добавления тэга
XMLTag | - тэг, по которому будем конструировать новый тэг. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
XMLTag | - тэг, по которому будем конструировать новый тэг. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 267
Перекрестные ссылки nitro::exception::code(), Tags, nitro::exception::what() и 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 |
Функция проверяет существование атрибута.
AttributeName | - Название атрибута. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
AttributeName | - Название атрибута. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 283
Перекрестные ссылки Attributes, nitro::exception::code() и 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 |
Функция возвращает количество атрибутов.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 52
Перекрестные ссылки Attributes, nitro::exception::code() и 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 |
Функция возвращает количество вложенных тэгов.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 36
Перекрестные ссылки nitro::exception::code(), Tags и nitro::exception::what().
Используется в 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 | ) |
Функция удаления тэга.
TagCursor | - курсор удаляемого тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 329
Перекрестные ссылки nitro::exception::code(), Tags и 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 | ) |
Функция удаляет тэги с именем TagName.
TagName | - имя тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
bool nitro::XMLTag::GetAttribute_bool | ( | const char * | AttributeName | ) | const |
Получение значения атрибута.
AttributeName | - |
См. определение в файле xml.cpp строка 883
Перекрестные ссылки Attributes, nitro::exception::code(), Values и 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 |
Получение значения атрибута.
AttributeName | - |
См. определение в файле xml.cpp строка 859
Перекрестные ссылки Attributes, nitro::exception::code(), Values и 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 |
Получение значения атрибута.
AttributeName | - |
См. определение в файле xml.cpp строка 835
Перекрестные ссылки Attributes, nitro::exception::code(), Values и 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 |
Получение значения атрибута.
AttributeName | - |
См. определение в файле xml.cpp строка 907
Перекрестные ссылки Attributes, nitro::exception::code(), Values и nitro::exception::what().
Используется в 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 |
Функция получения имени атрибута.
AttributeCursor | - Курсор атрибута. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 68
Перекрестные ссылки Attributes, nitro::exception::code() и 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 | ) |
Функция получения тэга по курсору.
TagCursor | - курсор тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 418
Перекрестные ссылки nitro::exception::code() и 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 | |||
) |
Функция получения тэга, у которого атрибут AttributeName со значением AttributeValue.
AttributeName | - название атрибута по которому будем искать. | |
AttributeValue | - значение атрибута по которому будем искать. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
int nitro::XMLTag::GetTagCursor | ( | const char * | TagName | ) | const |
Функция получения курсора тэга по имени тэга.
TagName | - имя тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
bool nitro::XMLTag::IsClosingTag | ( | std::vector< std::string > & | Lexemmas, | |
std::size_t & | i | |||
) | [protected] |
См. определение в файле xml.cpp строка 981
Перекрестные ссылки nitro::exception::code(), nitro::IsTagName(), Name и nitro::exception::what().
Используется в 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 | ) |
Функция возвращает последний тэг.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 346
Перекрестные ссылки nitro::exception::code(), Tags и 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] |
Функция загрузки XML файла.
Lexemmas | - Распарсенный XML файл. | |
i | - Курсор в массиве Lexemmas. | |
CDATA | - Список объектов с бинарными данными XMLя. | |
j | - Итератор в списке CDATA. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 1127
Перекрестные ссылки nitro::exception::code(), IsClosingTag(), nitro::IsTagName(), Name, ProcessAttributes(), Tags, nitro::exception::what() и 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 | |||
) |
Функция перемещения тэга.
TagCursor | - курсор тэга. | |
DestTag | - Корневой таг куда будет перемещен тэг с курсором TagCursor. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 362
Перекрестные ссылки nitro::exception::code(), Tags и 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 |
Оператор выборки тэга по названию.
TagName | - Название тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 209
Перекрестные ссылки nitro::exception::code(), Name, Tags и 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 |
Оператор выборки тэга по курсору.
TagCursor | - Курсор тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 395
Перекрестные ссылки nitro::exception::code(), nitro::Converters::itoa(), Tags и 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 |
Оператор выборки тэга по курсору.
TagCursor | - Курсор тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 379
Перекрестные ссылки nitro::exception::code() и 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] |
См. определение в файле xml.cpp строка 931
Перекрестные ссылки Attributes, nitro::exception::code(), nitro::IsTagName(), Values и nitro::exception::what().
Используется в 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 | ) |
Удаляем всю память которую выделил объект.
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 177
Перекрестные ссылки nitro::exception::code(), Tags и nitro::exception::what().
Используется в nitro::XMLFile::~XMLFile() и ~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 |
Функция сохранения XML в файл.
File | - Файловый поток. | |
TabSpace | - Строка для форматирования сохраняемого XML. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 672
Перекрестные ссылки Attributes, nitro::exception::code(), Name, Tags, Values, nitro::exception::what() и 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] |
Функция выполняет сериализацию XMLя.
Str | - Строка с сериализованным XMLем. | |
TabSpace | - строка с отступами. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
Str | - Строка с сериализованным XMLем. | |
TabSpace | - строка с отступами. |
nitro::exception | An exception of that type is thrown if ahy error occured. |
См. определение в файле xml.cpp строка 1071
Перекрестные ссылки Attributes, nitro::exception::code(), Name, Tags, Values и 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 | |||
) |
Функция установки значения атрибута.
AttributeName | - имя устанавливаемого атрибута. | |
AttributeValue | -новое значение атрибута. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 747
Перекрестные ссылки Attributes, nitro::exception::code(), Values и 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 | ) |
Функция установки названия тэга.
Name | - Название тэга. |
nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 731
Перекрестные ссылки nitro::exception::code(), Name и 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 |
Кидает исключение этого типа при возникновении ошибки.
См. определение в файле xml.cpp строка 306
Перекрестные ссылки nitro::exception::code(), Name, Tags и 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] |
Имена атрибутов тэга.
См. определение в файле xml.h строка 732
Используется в AddAttribute(), AttributeExists(), CountOfAttributes(), GetAttribute_bool(), GetAttribute_float(), GetAttribute_int(), GetAttribute_string(), GetAttributeName(), ProcessAttributes(), SaveXML(), SaveXMLToANSIString(), SetAttribute() и XMLTag().
nitro::BinaryData nitro::XMLTag::InnerData [protected] |
std::string nitro::XMLTag::Name |
Имя тэга.
См. определение в файле xml.h строка 110
Используется в IsClosingTag(), LoadXML(), operator[](), SaveXML(), SaveXMLToANSIString(), SetName(), TagExists() и XMLTag().
std::vector< XMLTag * > nitro::XMLTag::Tags [protected] |
Набор вложенных тэгов.
См. определение в файле xml.h строка 720
Используется в AddTag(), CountOfChildTags(), DeleteTag(), LastTag(), LoadXML(), MoveTag(), operator[](), Release(), SaveXML(), SaveXMLToANSIString(), TagExists() и XMLTag().
std::vector< std::string > nitro::XMLTag::Values [protected] |
Значения атрибутов тэга.
См. определение в файле xml.h строка 744
Используется в AddAttribute(), GetAttribute_bool(), GetAttribute_float(), GetAttribute_int(), GetAttribute_string(), ProcessAttributes(), SaveXML(), SaveXMLToANSIString(), SetAttribute() и XMLTag().