skins/AknSkins/sdcsrc/SDCInput.cpp
changeset 50 c6286dcf6040
parent 0 05e9090e2422
child 53 8f0f421d3d0f
equal deleted inserted replaced
43:1951b3078691 50:c6286dcf6040
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <string.h>
    19 #include <string.h>
       
    20 #include <wchar.h>
    20 #include "SDCGlobals.h"
    21 #include "SDCGlobals.h"
    21 #include "SDCInput.h"
    22 #include "SDCInput.h"
       
    23 #include "SDCCompat.h"
    22 
    24 
    23 // Make std namespace available for compatibility
    25 // Make std namespace available for compatibility
    24 namespace std {}
    26 namespace std {}
    25 using namespace std;
    27 using namespace std;
    26 
    28 
    99     wcscpy( escapeToken, L"" );
   101     wcscpy( escapeToken, L"" );
   100 
   102 
   101     ReadNextChar();
   103     ReadNextChar();
   102     while( iNextChar != L'\"' )
   104     while( iNextChar != L'\"' )
   103         {
   105         {
   104         if( (iNextChar==L'\n') || (iNextChar==L'\r') || (iNextChar==WEOF) ) throw CSDCException( ESDCParseError, "Unterminated string" );
   106         if( (iNextChar==L'\n') || (iNextChar==L'\r') || (iNextChar==WEOF) )
       
   107             throw CSDCException( ESDCParseError, "Unterminated string" );
       
   108 
   105         if( escaped )
   109         if( escaped )
   106             {
   110             {
   107             if( iNextChar == L'>' )
   111             if( iNextChar == L'>' )
   108                 {
   112                 {
   109                 escaped = false;
   113                 escaped = false;
   194     }
   198     }
   195 
   199 
   196 int CSDCInput::ConvertToNumber( const wchar_t* aToken )
   200 int CSDCInput::ConvertToNumber( const wchar_t* aToken )
   197     {
   201     {
   198     bool hexadecimal = false;
   202     bool hexadecimal = false;
   199     if( _wcsnicmp( aToken, L"0x", 2 ) == 0 ) hexadecimal = true;
   203     if( sd_wcsncasecmp( aToken, L"0x", 2 ) == 0 ) hexadecimal = true;
   200 
   204 
   201     int result = 0;
   205     int result = 0;
   202     const wchar_t *p = aToken;
   206     const wchar_t *p = aToken;
   203     if( hexadecimal ) p = p+2;
   207     if( hexadecimal ) p = p+2;
   204 
   208 
   271         }
   275         }
   272     }
   276     }
   273 
   277 
   274 TSDCColorDepth CSDCInput::ConvertToColorDepth( const wchar_t* aToken )
   278 TSDCColorDepth CSDCInput::ConvertToColorDepth( const wchar_t* aToken )
   275     {
   279     {
   276     if( _wcsicmp( aToken, L"1" ) == 0) return ESDCColorDepth1;
   280     if( sd_wcscasecmp( aToken, L"1" ) == 0) return ESDCColorDepth1;
   277     else if( _wcsicmp( aToken, L"2" ) == 0) return ESDCColorDepth2;
   281     else if( sd_wcscasecmp( aToken, L"2" ) == 0) return ESDCColorDepth2;
   278     else if( _wcsicmp( aToken, L"4" ) == 0) return ESDCColorDepth4;
   282     else if( sd_wcscasecmp( aToken, L"4" ) == 0) return ESDCColorDepth4;
   279     else if( _wcsicmp( aToken, L"8" ) == 0) return ESDCColorDepth8;
   283     else if( sd_wcscasecmp( aToken, L"8" ) == 0) return ESDCColorDepth8;
   280     else if( _wcsicmp( aToken, L"c4" ) == 0) return ESDCColorDepthC4;
   284     else if( sd_wcscasecmp( aToken, L"c4" ) == 0) return ESDCColorDepthC4;
   281     else if( _wcsicmp( aToken, L"c8" ) == 0) return ESDCColorDepthC8;
   285     else if( sd_wcscasecmp( aToken, L"c8" ) == 0) return ESDCColorDepthC8;
   282     else if( _wcsicmp( aToken, L"c12" ) == 0) return ESDCColorDepthC12;
   286     else if( sd_wcscasecmp( aToken, L"c12" ) == 0) return ESDCColorDepthC12;
   283     else if( _wcsicmp( aToken, L"c16" ) == 0) return ESDCColorDepthC16;
   287     else if( sd_wcscasecmp( aToken, L"c16" ) == 0) return ESDCColorDepthC16;
   284     else if( _wcsicmp( aToken, L"c24" ) == 0) return ESDCColorDepthC24;
   288     else if( sd_wcscasecmp( aToken, L"c24" ) == 0) return ESDCColorDepthC24;
   285     else if( _wcsicmp( aToken, L"c32" ) == 0) return ESDCColorDepthC32;
   289     else if( sd_wcscasecmp( aToken, L"c32" ) == 0) return ESDCColorDepthC32;
   286     throw CSDCException( ESDCParseError, "Unknown color depth parameter" );
   290     throw CSDCException( ESDCParseError, "Unknown color depth parameter" );
   287     }
   291     }
   288 
   292 
   289 int CSDCInput::ConvertToLayer( const wchar_t* aToken )
   293 int CSDCInput::ConvertToLayer( const wchar_t* aToken )
   290     {
   294     {
   291     if( _wcsicmp( aToken, L"none" ) == 0 ) return 0x0001;
   295     if( sd_wcscasecmp( aToken, L"none" ) == 0 ) return 0x0001;
   292 
   296 
   293     wchar_t buf[512];
   297     wchar_t buf[512];
   294     wcscpy( buf, aToken );
   298     wcscpy( buf, aToken );
   295 
   299 
   296     wchar_t* p = wcsstr( buf, L"/" );
   300     wchar_t* p = wcsstr( buf, L"/" );
   297     if( !p ) throw CSDCException( ESDCParseError, "Slash expected in layer parameter" );
   301     if( !p ) throw CSDCException( ESDCParseError, "Slash expected in layer parameter" );
   298     *p = 0;
   302     *p = 0;
   299     p = p+1;
   303     p = p+1;
   300 
   304 
   301     int layer = ConvertToNumber( buf ) << 8;
   305     int layer = ConvertToNumber( buf ) << 8;
   302     if( _wcsicmp( p, L"RGB" ) == 0 )
   306     if( sd_wcscasecmp( p, L"RGB" ) == 0 )
   303         {
   307         {
   304         layer |= 0x02;
   308         layer |= 0x02;
   305         }
   309         }
   306     else if( _wcsicmp( p, L"A" ) == 0 )
   310     else if( sd_wcscasecmp( p, L"A" ) == 0 )
   307         {
   311         {
   308         layer |= 0x04;
   312         layer |= 0x04;
   309         }
   313         }
   310     else if( _wcsicmp( p, L"RGBA" ) == 0 )
   314     else if( sd_wcscasecmp( p, L"RGBA" ) == 0 )
   311         {
   315         {
   312         layer |= 0x08;
   316         layer |= 0x08;
   313         }
   317         }
   314     else
   318     else
   315         {
   319         {
   323     {
   327     {
   324     int len = wcslen( aFilename );
   328     int len = wcslen( aFilename );
   325     if( len<4 ) return false;
   329     if( len<4 ) return false;
   326 
   330 
   327     const wchar_t* p = aFilename + len - 4;
   331     const wchar_t* p = aFilename + len - 4;
   328     if( _wcsicmp( p, L".svg" ) == 0 )
   332     if( sd_wcscasecmp( p, L".svg" ) == 0 )
   329         {
   333         {
   330         return true;
   334         return true;
   331         }
   335         }
   332     return false;
   336     return false;
   333     }
   337     }