| author | noe\swadi |
| Mon, 26 Apr 2010 16:28:13 +0530 | |
| changeset 3 | ebe3f8f03b59 |
| parent 0 | 638b9c697799 |
| permissions | -rw-r--r-- |
| 0 | 1 |
/* |
2 |
* Copyright (c) 2006-2009 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef __UTILS_H__ |
|
20 |
#define __UTILS_H__ |
|
21 |
||
22 |
#ifdef __WIN__ |
|
23 |
#pragma warning(disable:4786) |
|
24 |
#endif |
|
25 |
||
26 |
#include <stdio.h> |
|
27 |
#include <string> |
|
28 |
#include <list> |
|
29 |
#include <map> |
|
30 |
#include <vector> |
|
31 |
#include <stdarg.h> |
|
32 |
||
33 |
using namespace std; |
|
34 |
||
35 |
#define _X(s) XMLString::transcode(s) |
|
36 |
#define _XX(s) XMLString::release(&s) |
|
37 |
||
38 |
#define __FUN_MANGLED__ "__MANGLED__" |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
39 |
#define __Q_OBJECT_METAOBJECT__ "metaObject( ) const" |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
40 |
#define __Q_OBJECT_METACALL__ "qt_metacall( ::QMetaObject::Call, int, void** )" |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
41 |
#define __Q_OBJECT_METACAST__ "qt_metacast( const char* )" |
| 0 | 42 |
|
43 |
// Mostly used for implementation of headeranalyser |
|
44 |
enum TValue |
|
45 |
{
|
|
46 |
ELeftValue = 0, |
|
47 |
ERightValue |
|
48 |
}; |
|
49 |
||
50 |
// Used for implementation of testing program for headeranalyser |
|
51 |
const string KEmpty = "_DEADBEEF_DEADBEEF_"; |
|
52 |
||
53 |
||
54 |
/** |
|
55 |
* Convert integer to string |
|
56 |
* @param value value to convert |
|
57 |
* @param str reference to string where to convert |
|
58 |
* @param radix numeric base into which to convert |
|
59 |
* @return number converted to string |
|
60 |
*/ |
|
61 |
string itoa(int value, string& str, int radix); |
|
62 |
||
63 |
/** |
|
64 |
* Convert long to string |
|
65 |
* @param value value to convert |
|
66 |
* @param str reference to string where to convert |
|
67 |
* @param radix numeric base into which to convert |
|
68 |
* @return number converted to string |
|
69 |
*/ |
|
70 |
string ltoa(long value, string& str, int radix); |
|
71 |
||
72 |
/** |
|
73 |
* Find from list |
|
74 |
* @param aValue value to find |
|
75 |
* @param aList where to find |
|
76 |
* @param comparator comparator funtion |
|
77 |
* @param comparatorparam true, if comparator is used |
|
78 |
* @return string list |
|
79 |
*/ |
|
80 |
list<string>::iterator FindFromList(const string& aValue, list<string>& aList, bool(*comparator)(const string&,const string&,bool)=0, bool comparatorparam=true); |
|
81 |
||
82 |
/** |
|
83 |
* Find from list of paired string |
|
84 |
* @param aValue value to find |
|
85 |
* @param aList where to find |
|
86 |
* @param comparator comparator funtion |
|
87 |
* @param comparatorparam true, if comparator is used |
|
88 |
* @return string list |
|
89 |
*/ |
|
90 |
list<pair<string, string> >::iterator FindFromList(const string& aValue, list<pair<string,string> >& aList, bool(*comparator)(const string&,const string&,bool)=0, bool comparatorparam=true); |
|
91 |
||
92 |
/** |
|
93 |
* Find from list |
|
94 |
* @param aValue value to find |
|
95 |
* @param aList where to find |
|
96 |
* @param compareTo compare left or right value |
|
97 |
* @param comparator comparator funtion |
|
98 |
* @param comparatorparam true, if comparator is used |
|
99 |
* @return string list |
|
100 |
*/ |
|
101 |
list<pair<string, string> >::iterator FindFromList(const string& aValue, list<pair<string, string> >& aList, TValue compareTo, bool(*comparator)(const pair<string,string>&, const string&,bool)=0, bool comparatorparam=true, bool comparewholeString=false); |
|
102 |
||
103 |
/** |
|
104 |
* Find from list of paired string |
|
105 |
* @param aValue value to find |
|
106 |
* @param aList where to find |
|
107 |
* @param compareTo compare left or right value |
|
108 |
* @param comparator comparator funtion |
|
109 |
* @param comparatorparam true, if comparator is used |
|
110 |
* @return string list |
|
111 |
*/ |
|
112 |
list<pair<pair<string, string>,string> >::iterator FindFromList(const string& aValue, list<pair<pair<string, string>,string> >& aList, TValue compareTo, bool(*comparator)(const pair<string,string>&, const string&,bool)=0, bool comparatorparam=true, bool comparewholeString=false); |
|
113 |
/** |
|
114 |
* Convert integer to string |
|
115 |
* @param aString string to convert |
|
116 |
* @return lowercase string |
|
117 |
*/ |
|
118 |
string toLowerCaseWin(string aString); |
|
119 |
||
120 |
/** |
|
121 |
* Convert integer to string |
|
122 |
* @param aString string to convert |
|
123 |
* @return lowercase string |
|
124 |
*/ |
|
125 |
string toLowerCase(string aString); |
|
126 |
||
127 |
/** |
|
128 |
* Convert integer to string |
|
129 |
* @param aString string to convert |
|
130 |
* @return uppercase string |
|
131 |
*/ |
|
132 |
string toUpperCase(string aString); |
|
133 |
||
134 |
/** |
|
135 |
* Compare files |
|
136 |
* @param tocompare to which to compare |
|
137 |
* @param comparestr what to compare |
|
138 |
* @param tryfilename if this is true, bare filenames are compared to each other |
|
139 |
* @return true if match found |
|
140 |
*/ |
|
141 |
bool compareFiles(const string& tocompare, const string& comparestr, bool tryfilename = true); |
|
142 |
||
143 |
/** |
|
144 |
* Compare files |
|
145 |
* @param tocompare to which to compare |
|
146 |
* @param comparestr what to compare |
|
147 |
* @param tryfilename if this is true, bare filenames are compared to each other |
|
148 |
* @return true if match found |
|
149 |
*/ |
|
150 |
bool compareFiles(const pair<string, string>& tocompare, const string& comparestr, bool tryfilename = true); |
|
151 |
||
152 |
/** |
|
153 |
* Return the index of the rightmost directory separator in |
|
154 |
* the given string |
|
155 |
* |
|
156 |
* @param aFilename filename to search for |
|
157 |
* @return index |
|
158 |
*/ |
|
159 |
string::size_type rightmostDirSeparatorIndex(const string& aFilename); |
|
160 |
||
161 |
/** |
|
162 |
* Removes leading and trailing whitespace from given string between start and |
|
163 |
* end position and returns that trimmed string (without parts outside specified |
|
164 |
* scope). |
|
165 |
* |
|
166 |
* @param aString value |
|
167 |
* @param aStartpos where to start trimming |
|
168 |
* @param aEndpos where to end trimming |
|
169 |
* @return trimmed string |
|
170 |
*/ |
|
171 |
string trimWhiteSpace(string& aString, string::size_type aStartpos = 0, string::size_type aEndpos = string::npos); |
|
172 |
||
173 |
||
174 |
/** |
|
175 |
* Get line from input stream |
|
176 |
* @param aInput value |
|
177 |
* @return line as string |
|
178 |
*/ |
|
179 |
string getLine(istream& aInput); |
|
180 |
||
181 |
||
182 |
/** |
|
183 |
* Parses commandline parameters |
|
184 |
* @param args commandline arguments as string |
|
185 |
* @return command line parameters as list |
|
186 |
*/ |
|
187 |
//list<string> parseCommandlineParameters(string args); |
|
188 |
||
189 |
||
190 |
/** |
|
191 |
* Check if the given string is numeric |
|
192 |
* @param str string to check |
|
193 |
* @return true, if string is numeric |
|
194 |
*/ |
|
195 |
bool isNum(string str); |
|
196 |
||
197 |
||
198 |
/** |
|
199 |
* Check if the given string is alpha |
|
200 |
* @param str string to check |
|
201 |
* @return true, if string is alpha |
|
202 |
*/ |
|
203 |
bool isAlpha(string str); |
|
204 |
||
205 |
||
206 |
/** |
|
207 |
* Check if the given string is alphanumeric |
|
208 |
* @param str string to check |
|
209 |
* @return true, if string is alphanumeric |
|
210 |
*/ |
|
211 |
bool isAlphaNum(string str); |
|
212 |
||
213 |
||
214 |
/** |
|
215 |
* Split string |
|
216 |
* @param str string to split |
|
217 |
* @param separator separator char |
|
218 |
* @return splitted string |
|
219 |
*/ |
|
220 |
vector<string> splitString(const string& str, char separator=' '); |
|
221 |
||
222 |
||
223 |
/** |
|
224 |
* Trims white space |
|
225 |
* @param aControlString format string |
|
226 |
* @return formated string |
|
227 |
*/ |
|
228 |
//string printToString(string& aControlString, ...); |
|
229 |
||
230 |
||
231 |
/** |
|
232 |
* Trims white space |
|
233 |
* @param aControlString format string |
|
234 |
* @param params list of params to format |
|
235 |
* @return formatted string |
|
236 |
*/ |
|
237 |
string printToString(string& aControlString, list<string> params); |
|
238 |
||
239 |
/** |
|
240 |
* Replaces all occurences of the given character in a string by another one. |
|
241 |
* @param str reference to the string, which should be converted. |
|
242 |
* @param replaceFrom character that should be replaced by another. |
|
243 |
* @param replaceTo The replacing character. |
|
244 |
*/ |
|
245 |
void replaceChar(string& str, char replaceFrom, char replaceTo); |
|
246 |
||
247 |
/** |
|
248 |
* Remove base part from a string |
|
249 |
* @param aString string to be processed |
|
250 |
* @param aBase string to be removed |
|
251 |
* @return string with base part removed |
|
252 |
*/ |
|
253 |
string removeBase(string aString, string aBase); |
|
254 |
||
255 |
/** |
|
256 |
* Remove any leading directory separators from a string |
|
257 |
* @param aString string to be trimmed |
|
258 |
* @return leading directory separator trimmed string |
|
259 |
*/ |
|
260 |
string trimLeadingDirSeparator(string aString); |
|
261 |
||
262 |
/** |
|
263 |
* Comare base file with current file |
|
264 |
* after excluding sub dirs each time until string ends |
|
265 |
* @param aBasestr base file string |
|
266 |
* @param aCurstr base file string |
|
267 |
* @return true if base string matches with current string anytime after |
|
268 |
* excluding sub dirs.Else false. |
|
269 |
*/ |
|
270 |
bool compareWholeFileStrings(const string& aBasestr,const string& aCurstr); |
|
271 |
||
272 |
#define KEY_STRUCT "struct " |
|
273 |
#define KEY_ENUM "enum" |
|
274 |
#define KEY_MACRO "#define " |
|
275 |
||
276 |
#endif |