Changeset 6226

Show
Ignore:
Timestamp:
05/29/08 02:57:12 (6 months ago)
Author:
flynd
Message:

Added const to translator functions so we can call it from const context. iconv() doesn't declare it's inbuf parameter as const but it doesn't change the data so it's safe to const_cast it.

Location:
trunk/licq
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/include/licq_translate.h

    r6217 r6226  
    3434  char* nameForIconv(const char* licqName); 
    3535 
    36   char* ToUnicode(char* array, const char* fromEncoding = ""); 
    37   char* FromUnicode(char* array, const char* toEncoding = ""); 
     36  char* ToUnicode(const char* array, const char* fromEncoding = ""); 
     37  char* FromUnicode(const char* array, const char* toEncoding = ""); 
    3838 
    39   char* FromUTF16(char* array, const char* toEncoding, int length = -1); 
    40   char* ToUTF16(char* array, const char* fromEncoding, size_t& outDone); 
     39  char* FromUTF16(const char* array, const char* toEncoding, int length = -1); 
     40  char* ToUTF16(const char* array, const char* fromEncoding, size_t& outDone); 
    4141 
    4242  char* NToRN(const char* array); 
     
    5252  unsigned char clientToServerTab[256]; 
    5353 
    54   char* iconvConvert(char* array, const char* to, const char* from, bool& ok, 
    55       int length = -1, size_t* outDone = NULL); 
     54  char* iconvConvert(const char* array, const char* to, const char* from, 
     55      bool& ok, int length = -1, size_t* outDone = NULL); 
    5656}; 
    5757 
  • trunk/licq/src/translate.cpp

    r6217 r6226  
    232232} 
    233233 
    234 char* CTranslator::ToUnicode(char* array, const char* fromEncoding) 
     234char* CTranslator::ToUnicode(const char* array, const char* fromEncoding) 
    235235{ 
    236236  if (array == NULL) 
     
    257257} 
    258258 
    259 char* CTranslator::FromUnicode(char* array, const char* toEncoding) 
     259char* CTranslator::FromUnicode(const char* array, const char* toEncoding) 
    260260{ 
    261261  if (array == NULL) 
     
    277277} 
    278278 
    279 char* CTranslator::FromUTF16(char* array, const char* toEncoding, int length) 
     279char* CTranslator::FromUTF16(const char* array, const char* toEncoding, int length) 
    280280{ 
    281281  if (array == NULL) 
     
    297297} 
    298298 
    299 char* CTranslator::ToUTF16(char* array, const char* fromEncoding, size_t& outDone) 
     299char* CTranslator::ToUTF16(const char* array, const char* fromEncoding, size_t& outDone) 
    300300{ 
    301301  if (array == NULL) 
     
    439439} 
    440440 
    441 char* CTranslator::iconvConvert(char* array, const char* to, const char* from, 
     441char* CTranslator::iconvConvert(const char* array, const char* to, const char* from, 
    442442    bool& ok, int length, size_t* outDone) 
    443443{ 
     
    456456  char* result = new char[outLen + 1]; 
    457457 
    458   char* inPtr = array; 
     458  // iconv() has inbuf parameter declared as char** even though the data is 
     459  // never modified so it's safe to cast away the const here. 
     460  char* inPtr = const_cast<char*>(array); 
    459461  char* outPtr = result; 
    460462  iconv_t tr;