Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions

nitro::XMLTag Class Reference

Class represents an XML tag. More...

#include <loaders/xml.h>

Inherited by nitro::XMLFile.

Collaboration diagram for nitro::XMLTag:
Collaboration graph
[legend]

List of all members.

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
XMLTagoperator[] (const char *TagName) const
XMLTagoperator[] (const int TagCursor) const
XMLTagoperator[] (const std::size_t TagCursor) const
XMLTagGetTag (std::size_t TagCursor)
XMLTagGetTag (const char *AttributeName, const char *AttributeValue)
XMLTagLastTag (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 &)

Detailed Description

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.


Constructor & Destructor Documentation

nitro::XMLTag::XMLTag ( void   ) 

Default constructor.

Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

Definition at line 89 of file xml.cpp.

Referenced by AddTag(), LoadXML(), and XMLTag().

        {
        }

nitro::XMLTag::XMLTag ( const XMLTag XMLTag  ) 

Copy-constructor.

Parameters:
XMLTag - Assigning object.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

nitro::XMLTag::~XMLTag (  )  [virtual]

Destructor (virtual).

Author:
Dodonov A.A.

Definition at line 198 of file xml.cpp.

References Release().

        {
                try
                {
                        Release();
                }
                catch( ... )
                {
                }
        }

Here is the call graph for this function:


Member Function Documentation

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 ) );
                }
        }

Here is the call graph for this function:

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 ) );
                }
        }

Here is the call graph for this function:

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 ) );
                }
        }

Here is the call graph for this function:

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 ) );
                }
        }

Here is the call graph for this function:

std::size_t nitro::XMLTag::CountOfAttributes ( void   )  const

Function returns count of attributes

Returns:
Count of attributes.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

std::size_t nitro::XMLTag::CountOfChildTags ( void   )  const

Function returns count of shild tags

Returns:
Count of child tags.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::DeleteTag ( std::size_t  TagCursor  ) 

Function deletes tag.

Parameters:
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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::DeleteTag ( const char *  TagName  ) 

Function deletes all tags with name TagName.

Parameters:
TagName -
bool nitro::XMLTag::GetAttribute_bool ( const char *  AttributeName  )  const

Название атрибута.

Returns:
Значение атрибута.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Getting attribute's value.
Parameters:
AttributeName - attribute's name.
Returns:
Attributes value.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

float nitro::XMLTag::GetAttribute_float ( const char *  AttributeName  )  const

Название атрибута.

Returns:
Значение атрибута.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Getting attribute's value.
Parameters:
AttributeName - attribute's name.
Returns:
Attributes value.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

int nitro::XMLTag::GetAttribute_int ( const char *  AttributeName  )  const

Название атрибута.

Returns:
Значение атрибута.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Getting attribute's value.
Parameters:
AttributeName - attribute's name.
Returns:
Attributes value.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

const char * nitro::XMLTag::GetAttribute_string ( const char *  AttributeName  )  const

Название атрибута.

Returns:
Значение атрибута.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Getting attribute's value.
Parameters:
AttributeName - attribute's name.
Returns:
Attributes value.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

const char * nitro::XMLTag::GetAttributeName ( std::size_t  AttributeCursor  )  const

Function returns name of attribute.

Parameters:
AttributeCursor - Cursor of the attribute.
Returns:
Name of the attribute.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag & nitro::XMLTag::GetTag ( std::size_t  TagCursor  ) 

Function returns tag by it's cursor.

Parameters:
TagCursor - Tag's cursor.
Returns:
Tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag& nitro::XMLTag::GetTag ( const char *  AttributeName,
const char *  AttributeValue 
)

Function returns tag with the specified attribute valur.

Parameters:
AttributeName - Attributes name.
AttributeValue - Attributes value.
Returns:
Tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.
int nitro::XMLTag::GetTagCursor ( const char *  TagName  )  const

Function returns tag's cursor by it's name.

Parameters:
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.

Parameters:
Lexemmas - XML file splitted into tag names, tag parameters and special simbols.
i - cursor for array Lexemmas.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Function for detecting closing tags (tags with "/"). Returns true if selected tag is closing. Otherwise returns false.
Parameters:
Lexemmas - XML file splitted into tag names, tag parameters and special simbols.
i - cursor for array Lexemmas.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag & nitro::XMLTag::LastTag ( void   ) 

Function returns last tag.

Returns:
Last tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

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.

Parameters:
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.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::MoveTag ( std::size_t  TagCursor,
XMLTag DestTag 
)

Function copyes tag.

Parameters:
TagCursor - Tag's cursor.
DestTag - Object of the destination tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag nitro::XMLTag::operator= ( const XMLTag  )  [inline, private]

Private assignment operator.

Author:
Dodonov A.A.

Definition at line 874 of file xml.h.

{return(*this);}

XMLTag & nitro::XMLTag::operator[] ( const char *  TagName  )  const

Operator for tag selection.

Parameters:
TagName - tag's name.
Returns:
Tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag & nitro::XMLTag::operator[] ( const std::size_t  TagCursor  )  const

Operator for tag selection.

Parameters:
TagCursor - tag' cursor in Tags.
Returns:
Tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

XMLTag & nitro::XMLTag::operator[] ( const int  TagCursor  )  const

Operator for tag selection.

Parameters:
TagCursor - tag' cursor in Tags.
Returns:
Tag.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

int nitro::XMLTag::ProcessAttributes ( std::vector< std::string > &  Lexemmas,
std::size_t &  i 
) [protected]

Function for processing tag parameters while loading xml file.

Parameters:
Lexemmas - XML file splitted into tag names, tag parameters and special simbols.
i - cursor for array Lexemmas.
Exceptions:
nitro::exception Кидает исключение этого типа при возникновении ошибки.
Author:
Додонов А.А. Function for processing tag parameters while loading xml file.
Parameters:
Lexemmas - XML file splitted into tag names, tag parameters and special simbols.
i - cursor for array Lexemmas.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::Release ( void   ) 

Releasing all memory.

Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::SaveXML ( nitro::FileAbstraction File,
char *  TabSpace 
) const

Function for saving XML file into file.

Parameters:
File - file stream
TabSpace -string formatting output xml
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::SetAttribute ( const char *  AttributeName,
const char *  AttributeValue 
)

Function sets attribute's value.

Parameters:
AttributeName - Name of the setting attribute.
AttributeValue - New value of the attribute.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

void nitro::XMLTag::SetName ( const std::string &  Name  ) 

Function sets tag's name.

Parameters:
Name - Tag's name.
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

bool nitro::XMLTag::TagExists ( char *  TagName  )  const

Function for checking inner tag existence. Returns true if tag exist. Otherwise returns false.

Parameters:
TagName - tag's name
Exceptions:
nitro::exception Function for checking inner tag existence. Returns true if tag exist. Otherwise returns false.
Parameters:
TagName - tag's name
Exceptions:
nitro::exception An exception of that type is thrown if ahy error occured.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:


Member Data Documentation

std::vector< std::string > nitro::XMLTag::Attributes [protected]

Innter data.

Author:
Dodonov A.A.

Definition at line 756 of file xml.h.

std::string nitro::XMLTag::Name

TAg's name.

Author:
Dodonov A.A.

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.

Author:
Dodonov A.A.

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.

Author:
Dodonov A.A.

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().


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.1