00001 /// \file CATStringTable.cpp 00002 /// \brief String table for internationalization 00003 /// \ingroup CAT 00004 /// 00005 /// Copyright (c) 2007-2008 by Michael Ellison. 00006 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00007 /// 00008 // $Author: mikeellison $ 00009 // $Date: 2008-01-12 11:38:12 -0600 (Sat, 12 Jan 2008) $ 00010 // $Revision: $ 00011 // $NoKeywords: $ 00012 00013 #include "CATStringTable.h" 00014 00015 CATStringTable::CATStringTable() 00016 { 00017 } 00018 00019 CATStringTable::~CATStringTable() 00020 { 00021 } 00022 00023 CATResult CATStringTable::AddSubTable( CATStringTable* childTable ) 00024 { 00025 fSubTables.push_back(childTable); 00026 return CAT_SUCCESS; 00027 } 00028 00029 CATResult CATStringTable::RemoveSubTable( CATStringTable* childTable ) 00030 { 00031 std::vector<CATStringTable*>::iterator iter; 00032 00033 for (iter = fSubTables.begin(); iter != fSubTables.end(); ++iter) 00034 { 00035 if ( *iter == childTable) 00036 { 00037 fSubTables.erase(iter); 00038 return CAT_SUCCESS; 00039 } 00040 } 00041 return CAT_ERR_STRINGTABLE_NOT_FOUND; 00042 } 00043 00044 const CATWChar* CATStringTable::GetString(CATResult stringId, 00045 CATLangId languageId) const 00046 { 00047 // Scan subtables for string 00048 for (size_t i = 0; i < fSubTables.size(); i++) 00049 { 00050 const CATWChar* theString = fSubTables[i]->GetString(stringId,languageId); 00051 if (theString) 00052 return theString; 00053 } 00054 00055 return 0; 00056 }