109 m_Translations = NULL;
115 m_Translations = NULL;
117 Create(File_Name, bSetExtension, iText, iTranslation, bCmpNoCase);
123 m_Translations = NULL;
125 Create(pTable, iText, iTranslation, bCmpNoCase);
139 for(
int i=0; i<m_nTranslations; i++)
141 delete(m_Translations[i]);
147 m_Translations = NULL;
168 Create(&Translations, iText, iTranslation, bCmpNoCase);
173 return( m_nTranslations > 0 );
187 m_bCmpNoCase = bCmpNoCase;
191 for(i=0; i<pTranslations->
Get_Count(); i++)
206 m_Translations = (CSG_Translation **)
SG_Malloc(pTranslations->
Get_Count() *
sizeof(CSG_Translation *));
208 for(i=0; i<pTranslations->
Get_Count(); i++)
214 m_Translations[m_nTranslations++] =
new CSG_Translation(pRecord->
asString(iText), pRecord->
asString(iTranslation));
218 if( m_nTranslations < pTranslations->
Get_Count() )
220 m_Translations = (CSG_Translation **)
SG_Realloc(m_Translations, m_nTranslations *
sizeof(CSG_Translation *));
226 return( m_nTranslations > 0 );
235 #define COMPARE(Index, Text) (m_bCmpNoCase ? m_Translations[Index]->m_Text.CmpNoCase(Text) : m_Translations[Index]->m_Text.Cmp(Text))
238 int CSG_Translator::_Get_Index(
const CSG_String &Text)
const
242 if( m_nTranslations == 1 )
246 return( c >= 0 ? 0 : 1 );
249 if( m_nTranslations > 1 )
251 for(a=0, b=m_nTranslations-1; b - a > 1; )
274 return( m_nTranslations );
286 return( m_nTranslations );
299 if( m_nTranslations > 0 )
309 if( (i = _Get_Index(s)) < m_nTranslations && !
COMPARE(i, s) )
311 return( m_Translations[i]->m_Translation );
315 if( bReturnNullOnNotFound )
323 do { Text++; }
while( *Text !=
'}' && *Text !=
'\0' );
324 do { Text++; }
while( *Text ==
' ' && *Text !=
'\0' );
336 if( m_nTranslations > 0 )
346 if( (i = _Get_Index(s)) < m_nTranslations && !
COMPARE(i, s) )
348 Translation = m_Translations[i]->m_Translation;
357 do { Text++; }
while( *Text !=
'}' && *Text !=
'\0' );
358 do { Text++; }
while( *Text ==
' ' && *Text !=
'\0' );