Открытые члены | Закрытые члены | Закрытые данные

Класс nitro::XMLFile

Класс скрывает некоторые детали реализации класса XMLTag. Подробнее...

#include <loaders/xml.h>

Базовые классы:nitro::XMLTag.

Граф связей класса nitro::XMLFile:
Collaboration graph
[см. легенду]

Полный список членов класса

Открытые члены

 XMLFile (void)
 XMLFile (const char *FilePath)
 XMLFile (const std::string &FilePath)
XMLTagGetRoot (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]

Здсь сохраняется путь, по которому был открыт файл.

Автор:
Додонов А.А.

См. определение в файле xml.h строка 1106

Используется в LoadXML(), LoadXMLFromANSIString(), SaveXML() и XMLFile().

std::string nitro::XMLFile::SerializedXML [private]

Буффер для хранения сериализованного XML'y. Является временной переменной.

Автор:
Додонов А.А.

См. определение в файле xml.h строка 1094

std::string nitro::XMLFile::Version [private]

Версия XML стандарта.

Автор:
Додонов А.А.

См. определение в файле xml.h строка 1070

Используется в ParseHeader(), SaveXML() и XMLFile().


Объявления и описания членов классов находятся в файлах:

Generated by  doxygen 1.6.1