D:/Zythum/DinoKod/Bsp/BspEntity.cpp

00001 //---------------------------------------------------------------------------------------------
00002 //      This file is a part of "DinoKod".
00003 //      Copyright © 2003 Dino Productions. All Rights Reserved.
00004 //      
00005 //      File                    : BspEntity.cpp
00006 //      Author                  : Sebastien LEIX        sebastien.leix@wanadoo.fr
00007 //      Date                    : 07/09/2002
00008 //      Modification    :
00009 //
00010 //---------------------------------------------------------------------------------------------
00011 #include "Common/Console.h"
00012 
00013 #include "Bsp/BspEntity.h"
00014 
00015 //---------------------------------------------------------------------------------------------------------------------
00016 KBspEntity::KBspEntity()
00017 {
00018         m_pClassName = NULL;
00019         m_Index = 0;
00020 }
00021 
00022 //---------------------------------------------------------------------------------------------------------------------
00023 KBspEntity::~KBspEntity()
00024 {
00025         if( m_pClassName )
00026                 free( m_pClassName );
00027 
00028         for( u32 i = 0; i < m_KeyList.GetSize(); i ++ )
00029         {
00030                 KBspEntityKey*  pEntityKey = m_KeyList[i];
00031 
00032                 if( pEntityKey->m_pKey )        free( pEntityKey->m_pKey );
00033                 if( pEntityKey->m_pValue )      free( pEntityKey->m_pValue );
00034 
00035                 Deletep( pEntityKey );
00036         }
00037         m_KeyList.Clear();
00038 }
00039 
00040 //---------------------------------------------------------------------------------------------------------------------
00041 void KBspEntity::SetClassName( char* pClassName )
00042 {
00043         if( m_pClassName )
00044                 free( m_pClassName );
00045 
00046         m_pClassName = strdup( pClassName );
00047 }
00048 
00049 //---------------------------------------------------------------------------------------------------------------------
00050 void KBspEntity::AddKey( char* pKey, char* pValue )
00051 {
00052         KBspEntityKey*  pEntityKey = new KBspEntityKey;
00053 
00054         pEntityKey->m_pKey              = strdup( pKey );
00055         pEntityKey->m_pValue    = strdup( pValue );
00056 
00057         m_KeyList.Add( pEntityKey );
00058 }
00059 
00060 //---------------------------------------------------------------------------------------------------------------------
00061 void KBspEntity::Dump()
00062 {
00063         g_Console << "CLASS " << m_pClassName << KENDL << "{" << KENDL;
00064         for( u32 i = 0; i < m_KeyList.GetSize(); i ++ )
00065         {
00066                 KBspEntityKey*  pEntityKey = m_KeyList[i];
00067                 
00068                 g_Console << "  " <<  pEntityKey->m_pKey << " " << pEntityKey->m_pValue << KENDL;
00069         }
00070         g_Console << "}" << KENDL << KENDL;
00071 }
00072 
00073 //---------------------------------------------------------------------------------------------------------------------
00074 char* KBspEntity::GetKeyValue( char* pKey )
00075 {
00076         for( u32 i = 0; i < m_KeyList.GetSize(); i ++ )
00077                 if( stricmp( m_KeyList[i]->m_pKey, pKey ) == 0 )
00078                         return m_KeyList[i]->m_pValue;
00079 
00080         return NULL;
00081 }

Generated on Sun Mar 25 20:02:10 2007 for Zythum Project by  doxygen 1.5.1-p1