|
1 /* |
|
2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Constants for compiler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <stdio.h> |
|
20 #include "SDCGlobals.h" |
|
21 #include "SDCIIDConstants.h" |
|
22 #include "SDCInput.h" |
|
23 |
|
24 // Make std namespace available for compatibility |
|
25 namespace std {} |
|
26 using namespace std; |
|
27 |
|
28 ////////////////////////////////////////////////////////////////////// |
|
29 // Globals |
|
30 ////////////////////////////////////////////////////////////////////// |
|
31 |
|
32 vector<TSDCIIDEntry*> gIIDVector; |
|
33 |
|
34 ////////////////////////////////////////////////////////////////////// |
|
35 // Constants |
|
36 ////////////////////////////////////////////////////////////////////// |
|
37 |
|
38 struct TSDCIIDDefaultEntry |
|
39 { |
|
40 const wchar_t* iName; |
|
41 int iMajor; |
|
42 int iMinor; |
|
43 }; |
|
44 |
|
45 TSDCIIDDefaultEntry gDefaultIIDList[] = { |
|
46 #include "AknsConvertedConstants_NR.inl" |
|
47 { NULL, 0, 0 } |
|
48 }; |
|
49 |
|
50 ////////////////////////////////////////////////////////////////////// |
|
51 // Methods |
|
52 ////////////////////////////////////////////////////////////////////// |
|
53 |
|
54 void SDCIIDConstants::Initialize( const char* aFilename ) |
|
55 { |
|
56 // Copy default items to the vector |
|
57 TSDCIIDDefaultEntry* defEntry = gDefaultIIDList; |
|
58 while( defEntry->iName ) |
|
59 { |
|
60 TSDCIIDEntry* newEntry = new TSDCIIDEntry; |
|
61 wcscpy( newEntry->iName, defEntry->iName ); |
|
62 newEntry->iMajor = defEntry->iMajor; |
|
63 newEntry->iMinor = defEntry->iMinor; |
|
64 gIIDVector.push_back( newEntry ); |
|
65 |
|
66 defEntry = defEntry+1; |
|
67 } |
|
68 |
|
69 // If no file given, return |
|
70 if( (!aFilename) || (strlen(aFilename)<1) ) return; |
|
71 |
|
72 printf("NOTE: Reading item ID extensions from %s\n", aFilename ); |
|
73 |
|
74 CSDCInput input; |
|
75 input.Open( aFilename ); |
|
76 |
|
77 while( input.NextTokenAllowLF() ) |
|
78 { |
|
79 if( _wcsicmp( input.iToken, L"IID" ) == 0 ) |
|
80 { |
|
81 // Parse string token |
|
82 input.NextStringToken(); |
|
83 wchar_t nameBuf[256]; |
|
84 wcscpy( nameBuf, input.iToken ); |
|
85 // Parse major token |
|
86 input.NextToken(); |
|
87 int major = input.ConvertToNumber( input.iToken ); |
|
88 // Parse minor token |
|
89 input.NextToken(); |
|
90 int minor = input.ConvertToNumber( input.iToken ); |
|
91 |
|
92 TSDCIIDEntry* newEntry = new TSDCIIDEntry; |
|
93 wcscpy( newEntry->iName, nameBuf ); |
|
94 newEntry->iMajor = major; |
|
95 newEntry->iMinor = minor; |
|
96 gIIDVector.push_back( newEntry ); |
|
97 |
|
98 /*char debugBuf[512]; |
|
99 CSDCInput::ConvertToAscii( debugBuf, nameBuf ); |
|
100 printf("DEBUG: \"%s\" %i %i\n", debugBuf, major, minor );*/ |
|
101 } |
|
102 else throw CSDCException( ESDCParseError, "IID token expected" ); |
|
103 } |
|
104 |
|
105 printf("NOTE: Item ID extensions read and appended.\n\n"); |
|
106 } |
|
107 |
|
108 SDCIIDConstants::~SDCIIDConstants() |
|
109 { |
|
110 while( gIIDVector.size()>0 ) |
|
111 { |
|
112 delete gIIDVector.back(); |
|
113 gIIDVector.pop_back(); |
|
114 } |
|
115 } |
|
116 |
|
117 const TSDCIIDEntry* SDCIIDConstants::Find( const wchar_t* aName ) |
|
118 { |
|
119 for( int i=0; i<gIIDVector.size(); i++ ) |
|
120 { |
|
121 if( _wcsicmp( aName, gIIDVector[i]->iName ) == 0 ) |
|
122 return gIIDVector[i]; |
|
123 } |
|
124 return NULL; |
|
125 } |
|
126 |
|
127 const TSDCIIDEntry* SDCIIDConstants::FindPlain( const wchar_t* aName ) |
|
128 { |
|
129 wchar_t buf[512]; |
|
130 wcscpy( buf, L"KAknsIID" ); |
|
131 wcscat( buf, aName ); |
|
132 return Find( buf ); |
|
133 } |
|
134 |
|
135 const TSDCIIDEntry* SDCIIDConstants::FindBmpName( const wchar_t* aName ) |
|
136 { |
|
137 wchar_t buf[512]; |
|
138 |
|
139 wcscpy( buf, L"" ); |
|
140 const wchar_t* p = aName; |
|
141 |
|
142 // Strip the separator to allow compound members to be named correctly |
|
143 const wchar_t* separator = wcsstr( aName, L"%" ); |
|
144 if( separator ) |
|
145 { |
|
146 char warningBuf[512]; |
|
147 CSDCInput::ConvertToAscii( warningBuf, aName ); |
|
148 printf( "WARNING: Restriction stripped for IID match (%s)\n", warningBuf ); |
|
149 p = separator + 1; |
|
150 } |
|
151 |
|
152 while( *p ) |
|
153 { |
|
154 if( *p == L'.' ) break; |
|
155 if( *p != L'_' ) |
|
156 { |
|
157 wcsncat( buf, p, 1 ); |
|
158 } |
|
159 p = p+1; |
|
160 }; |
|
161 return FindPlain( buf ); |
|
162 } |
|
163 |
|
164 // End of file |