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))
238int 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' );
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
SAGA_API_DLL_EXPORT int SG_UI_Msg_Lock(bool bOn)
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
const SG_Char * SG_Translate(const CSG_String &Text)
CSG_Translator & SG_Get_Translator(void)
#define COMPARE(Index, Text)
CSG_Translator gSG_Translator
CSG_String AfterFirst(char Character) const
CSG_String BeforeFirst(char Character) const
const SG_Char * c_str(void) const
CSG_String & Make_Lower(void)
bool Set_Value(int Field, const CSG_String &Value)
bool is_NoData(int Field) const
const SG_Char * asString(int Field, int Decimals=-99) const
sLong Get_Count(void) const
bool Set_Index(CSG_Index &Index, int Field, bool bAscending=true) const
virtual CSG_Table_Record * Get_Record(sLong Index) const
int Get_Field_Count(void) const
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
const SG_Char * Get_Translation(int i) const
bool Create(const CSG_String &File_Name, bool bSetExtension=true, int iText=0, int iTranslation=1, bool bCmpNoCase=false)
int Get_Count(void) const
virtual ~CSG_Translator(void)