Класс скрывает некоторые детали реализации класса XMLTag. Подробнее...
#include <loaders/xml.h>
Базовые классы:nitro::XMLTag.
Открытые члены | |
| XMLFile (void) | |
| XMLFile (const char *FilePath) | |
| XMLFile (const std::string &FilePath) | |
| XMLTag & | GetRoot (void) |
| void | LoadXML (const char *FilePath) |
| void | LoadXML (const std::string &FilePath) |
| void | LoadXMLFromANSIString (const char *str) |
| void | SaveXML (const char *FilePath=NULL) |
| virtual | ~XMLFile () |
Закрытые члены | |
| void | ParseHeader (std::vector< std::string > &Lexemmas, std::size_t &i) |
Закрытые данные | |
| std::string | Version |
| std::string | Encoding |
| std::string | SerializedXML |
| std::string | OpenFilePath |
Класс скрывает некоторые детали реализации класса XMLTag.
См. определение в файле xml.h строка 887
| nitro::XMLFile::XMLFile | ( | void | ) |
Конструктор по-умолчанию.
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 117
Перекрестные ссылки nitro::exception::code(), Encoding, OpenFilePath, Version и nitro::exception::what().
{
try
{
Version = "";
Encoding = "";
OpenFilePath = "";
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( void )::An error occured" ) , 1 ) );
}
}

| nitro::XMLFile::XMLFile | ( | const char * | FilePath | ) |
Конструктор, который загружает XML файл.
| FilePath | - Путь к загружаемому файлу. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 135
Перекрестные ссылки nitro::exception::code(), Encoding, LoadXML(), OpenFilePath, Version и nitro::exception::what().
{
try
{
Version = "";
Encoding = "";
OpenFilePath = FilePath;
LoadXML( FilePath );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( const char * FilePath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( const char * FilePath )::An error occured" ) , 1 ) );
}
}

| nitro::XMLFile::XMLFile | ( | const std::string & | FilePath | ) |
Конструктор, который загружает XML файл.
| FilePath | - Путь к загружаемому файлу. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 156
Перекрестные ссылки nitro::exception::code(), Encoding, LoadXML(), OpenFilePath, Version и nitro::exception::what().
{
try
{
Version = "";
Encoding = "";
OpenFilePath = FilePath;
LoadXML( FilePath );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( const std::string & FilePath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::XMLFile( const std::string & FilePath )::An error occured" ) , 1 ) );
}
}

| nitro::XMLFile::~XMLFile | ( | ) | [virtual] |
Деструктор (виртуальный).
См. определение в файле xml.cpp строка 824
Перекрестные ссылки nitro::XMLTag::Release().
{
try
{
this->Release();
}
catch( ... )
{
}
}

| XMLTag & nitro::XMLFile::GetRoot | ( | void | ) |
Функция возвращает корневой элемент файла.
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 604
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в nitro::MVC::Create().
{
try
{
return( dynamic_cast< XMLTag & >( *this ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::GetRoot( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::GetRoot( void )::An error occured" ) , 1 ) );
}
}

| void nitro::XMLFile::LoadXML | ( | const char * | FilePath | ) |
Функция загрузки XML файла.
| FilePath | - Путь к загружаемому файлу. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 620
Перекрестные ссылки nitro::exception::code(), nitro::DispatchBuffer(), nitro::BinaryData::GetBuffer(), nitro::BinaryData::GetBufferLength(), nitro::File::LoadBinDataFromFile(), OpenFilePath, ParseHeader() и nitro::exception::what().
Используется в nitro::MVC::Create(), LoadXML(), LoadXMLFromANSIString() и XMLFile().
{
try
{
OpenFilePath = FilePath;
std::vector< std::string > ProtoText;
std::vector< std::string > Lexemmas;
std::list< nitro::BinaryData > CDATA;
BinaryData BinaryData;
File::LoadBinDataFromFile( BinaryData , std::string( FilePath ) );
DispatchBuffer( BinaryData.GetBuffer() , Lexemmas , BinaryData.GetBufferLength() , CDATA );
std::size_t i( 0 );
std::list< nitro::BinaryData >::iterator j( CDATA.begin() );
ParseHeader( Lexemmas , i );
XMLTag::LoadXML( Lexemmas , i , CDATA , j );
ProtoText.clear();
Lexemmas.clear();
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::LoadXML( const char * FilePath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::LoadXML( const char * FilePath )::An error occured" ) , 1 ) );
}
}

| void nitro::XMLFile::LoadXML | ( | const std::string & | FilePath | ) |
Функция загрузки XML файла.
| FilePath | - Путь к загружаемому файлу. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 656
Перекрестные ссылки nitro::exception::code(), LoadXML() и nitro::exception::what().
{
try
{
LoadXML( FilePath.c_str() );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::LoadXML( const std::string & FilePath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::LoadXML( const std::string & FilePath )::An error occured" ) , 1 ) );
}
}

| void nitro::XMLFile::LoadXMLFromANSIString | ( | const char * | str | ) |
Функция загружает XML из строки.
| str | - Обрабатываемая строка. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 576
Перекрестные ссылки nitro::DispatchBuffer(), LoadXML(), OpenFilePath, ParseHeader() и nitro::exception::what().
{
try
{
OpenFilePath = "";
std::vector< std::string > Lexemmas;
std::list< nitro::BinaryData > CDATA;
DispatchBuffer( str , Lexemmas , strlen( str ) , CDATA );
std::size_t i( 0 );
std::list< nitro::BinaryData >::iterator j( CDATA.begin() );
ParseHeader( Lexemmas , i );
XMLTag::LoadXML( Lexemmas , i , CDATA , j );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::LoadXMLFromANSIString( const char * str )::" ) + e.what() , 1 ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::LoadXMLFromANSIString( const char * str )::An error occured" ) , 1 ) );
}
}

| void nitro::XMLFile::ParseHeader | ( | std::vector< std::string > & | Lexemmas, | |
| std::size_t & | i | |||
| ) | [private] |
Функция парсит заголовок XMLя <?xml version=....?>
| Lexemmas | - Массив лексемм. | |
| i | - Курсор массива Lexemmas. |
См. определение в файле xml.cpp строка 1016
Перекрестные ссылки nitro::exception::code(), Encoding, nitro::IsTagName(), Version и nitro::exception::what().
Используется в LoadXML() и LoadXMLFromANSIString().
{
try
{
if( Lexemmas.size() < 6 )
{
throw( nitro::exception( "Bad XML structure" , 1 ) );
}
if( Lexemmas[ 0 ] != "<" || Lexemmas[ 1 ] != "?" || Lexemmas[ 2 ] != "xml" )
{
return;
}
i = 3;
for( std::size_t k( 3 ) ; k < Lexemmas.size() ; k += 5 , i += 5 )
{
if( IsTagName( Lexemmas[ k ] ) && Lexemmas[ k + 1 ] == "=" && Lexemmas[ k + 2 ] == "\"" )
{
if( Lexemmas[ k ] == "version" )
{
Version = Lexemmas[ k + 3 ];
goto next_iter;
}
if( Lexemmas[ k ] == "encoding" )
{
Encoding = Lexemmas[ k + 3 ];
goto next_iter;
}
}
else
{
if( Lexemmas[ k ] == "?" && Lexemmas[ k + 1 ] == ">" )
{
i += 2;
return;
}
else
{
throw( nitro::exception( "Bad XML structure" , 1 ) );
}
}
next_iter:;
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::ParseHeader( std::vector< std::string > & Lexemmas , std::size_t & i )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::ParseHeader( std::vector< std::string > & Lexemmas , std::size_t & i )::An error occured" ) , 1 ) );
}
}

| void nitro::XMLFile::SaveXML | ( | const char * | FilePath = NULL |
) |
Сохранение XML файла.
| FilePath | - Путь, по которому будет сохранятся XML файл. |
| nitro::exception | Кидает исключение этого типа при возникновении ошибки. |
См. определение в файле xml.cpp строка 770
Перекрестные ссылки nitro::exception::code(), Encoding, nitro::FA_FILE_BINARY, nitro::FA_FILE_TRUNCATE, nitro::FA_FILE_WRITE, nitro::FileAbstraction::Open(), OpenFilePath, Version, nitro::exception::what() и nitro::FileAbstraction::Write().
{
try
{
nitro::FileAbstraction File;
if( FilePath )
{
OpenFilePath = FilePath;
File.Open( FilePath , nitro::FA_FILE_WRITE | nitro::FA_FILE_BINARY | nitro::FA_FILE_TRUNCATE );
}
else
{
File.Open( OpenFilePath.c_str() , nitro::FA_FILE_WRITE | nitro::FA_FILE_BINARY | nitro::FA_FILE_TRUNCATE );
}
if( Version != "" || Encoding != "" )
{
std::string str;
str = "<?xml ";
File.Write( str.c_str() , str.length() );
if( Version != "" )
{
str = "version=\"";
str += Version;
str += "\" ";
File.Write( str.c_str() , str.length() );
}
if( Encoding != "" )
{
str = "encoding=\"";
str += Encoding;
str += "\" ";
File.Write( str.c_str() , str.length() );
}
str = "?>\n";
File.Write( str.c_str() , str.length() );
}
XMLTag::SaveXML( File , "" );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "XMLFile::SaveXML( const char * FilePath /* = NULL */ )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "XMLFile::SaveXML( const char * FilePath /* = NULL */ )::An error occured" ) , 1 ) );
}
}

std::string nitro::XMLFile::Encoding [private] |
Название кодировки файла.
См. определение в файле xml.h строка 1082
Используется в ParseHeader(), SaveXML() и XMLFile().
std::string nitro::XMLFile::OpenFilePath [private] |
std::string nitro::XMLFile::SerializedXML [private] |
std::string nitro::XMLFile::Version [private] |
Версия XML стандарта.
См. определение в файле xml.h строка 1070
Используется в ParseHeader(), SaveXML() и XMLFile().
1.6.1