1 /* |
|
2 * Copyright (c) 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: Defines CATDataSaver class and element type enumeration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CATDATASAVER_H__ |
|
20 #define __CATDATASAVER_H__ |
|
21 |
|
22 #include <xercesc/dom/DOM.hpp> |
|
23 #include <xercesc/framework/LocalFileFormatTarget.hpp> |
|
24 #include "ATCommonDefines.h" |
|
25 |
|
26 /** |
|
27 * Represents element types |
|
28 */ |
|
29 enum element_types |
|
30 { |
|
31 RESULT = 0, |
|
32 RUN, |
|
33 LEAK, |
|
34 CALLSTACK, |
|
35 ITEM, |
|
36 RUN_END, |
|
37 ERROR_IN_RUN, |
|
38 MEM_LEAKS, |
|
39 MEM_LEAK_MODULE, |
|
40 HANDLE_LEAKS, |
|
41 HANDLE_LEAK_MODULE, |
|
42 TEST_START, |
|
43 TEST_END, |
|
44 SUBTEST_MEM_LEAKS, |
|
45 SUBTEST_MEM_LEAK_MODULE, |
|
46 LOGGING_CANCELLED, |
|
47 SUBTEST_HANDLE_LEAKS |
|
48 }; |
|
49 |
|
50 //#define CARBIDE_DATA 0 |
|
51 #define XML_DATA 1 |
|
52 #define TEXT_DATA 2 |
|
53 |
|
54 /** |
|
55 * TProvides features for creating the analyze report in |
|
56 * basic text or XML formats. Uses xerces library for XML output. |
|
57 */ |
|
58 class CATDataSaver |
|
59 { |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * Constructor. |
|
65 */ |
|
66 CATDataSaver( void ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 ~CATDataSaver(void); |
|
72 |
|
73 /** |
|
74 * Save all lines to file with given format. |
|
75 * @param pFileName Pointer to file name. |
|
76 * @param iDataToSave Format of data. |
|
77 */ |
|
78 void SaveLinesToFile( const char* pFileName, int iDataToSave ); |
|
79 |
|
80 /** |
|
81 * Prints all saved lines to screen. |
|
82 */ |
|
83 void PrintLinesToScreen( void ); |
|
84 |
|
85 /** |
|
86 * Adds saved line to first in database. |
|
87 */ |
|
88 void AddLineToFirst( void ); |
|
89 |
|
90 /** |
|
91 * Adds saved line to last in database. |
|
92 */ |
|
93 void AddLineToLast(); |
|
94 |
|
95 /** |
|
96 * Adds string to current line. |
|
97 * @param pData string to add |
|
98 * @param bSaveCarbideData add string to xml? |
|
99 */ |
|
100 void AddString( const char* pData, bool bSaveCarbideData = false ); |
|
101 |
|
102 /** |
|
103 * Converts integer to string and adds it to current line. |
|
104 * @param iValue integer value to add |
|
105 * @param bSaveCarbideData add string to xml? |
|
106 */ |
|
107 void AddInteger( int iValue, bool bSaveCarbideData = false ); |
|
108 |
|
109 /** |
|
110 * Sets logging level. |
|
111 * If value is invalid DEFAULT_LOGGING_LEVEL is used |
|
112 * value must be between MIN_LOGGING_LEVEL and MAX_LOGGING_LEVEL |
|
113 * @param iLoggingLevel Logging level. |
|
114 */ |
|
115 void SetLoggingLevel( int iLoggingLevel ); |
|
116 |
|
117 /** |
|
118 * Gets logging level. |
|
119 * @return Logging level. |
|
120 */ |
|
121 int GetLoggingLevel( void ); |
|
122 |
|
123 /** |
|
124 * Sets print immediately flag. |
|
125 * @param bPrintImmediately |
|
126 */ |
|
127 void SetPrintFlag( bool bPrintImmediately ); |
|
128 |
|
129 /** |
|
130 * Sets data header for carbide data. |
|
131 */ |
|
132 void SaveCarbideDataHeader( void ); |
|
133 |
|
134 /** |
|
135 * Initializes xercer xml parser. |
|
136 */ |
|
137 bool InitXML( void ); |
|
138 |
|
139 /** |
|
140 * Writes data to xml tree. |
|
141 * @param sInput data |
|
142 * @param iElementType element to write |
|
143 */ |
|
144 void SaveXML( string sInput, int iElementType ); |
|
145 |
|
146 /** |
|
147 * Converts char* -> wchar_t*. |
|
148 * @param str |
|
149 * @return LPWSTR |
|
150 */ |
|
151 static LPWSTR CharToWChar( const char* str ); |
|
152 |
|
153 /** |
|
154 * Converts wchar_t* -> char*. |
|
155 * @param sInput |
|
156 * @param Source |
|
157 */ |
|
158 static void WCharToChar( string& sInput, const WCHAR* Source ); |
|
159 |
|
160 /** |
|
161 * Set is build type debug? |
|
162 * @param bUdebBuild true if build type debug |
|
163 */ |
|
164 void SetBuild( bool bUdebBuild ); |
|
165 |
|
166 /** |
|
167 * Add xml data for extension |
|
168 * @param sInput data |
|
169 */ |
|
170 void AddCarbideData( const string& sInput ); |
|
171 |
|
172 /** |
|
173 * Convert given integer to string |
|
174 * @param iValueToConvert |
|
175 * @return string |
|
176 */ |
|
177 static string IntegerToString( int iValueToConvert ); |
|
178 |
|
179 #ifndef MODULE_TEST |
|
180 private: |
|
181 #endif |
|
182 vector<string> m_vLines; |
|
183 string m_sLine; |
|
184 string m_sCarbideDataLine; |
|
185 |
|
186 string m_sCarbideDataHeader; |
|
187 |
|
188 int m_iLoggingLevel; |
|
189 int m_iRunNumber; |
|
190 bool m_bPrintImmediately; |
|
191 bool m_bXMLInitOk; |
|
192 bool m_bUdebBuild; |
|
193 |
|
194 xercesc::DOMDocument* m_pDomDoc; |
|
195 xercesc::DOMElement* m_pRootElem; |
|
196 xercesc::DOMElement* m_pCurrentLeakElem; |
|
197 xercesc::DOMWriter* m_Serializer; |
|
198 xercesc::DOMElement* m_pRunElement; |
|
199 xercesc::DOMElement* m_pMemoryLeaks; |
|
200 xercesc::DOMElement* m_pHandleLeaks; |
|
201 xercesc::DOMElement* m_pCurrentSubTestElem; |
|
202 xercesc::DOMElement* m_pSubtestMemoryLeaks; |
|
203 |
|
204 /** |
|
205 * Utility to get sub string from string using char as separator |
|
206 * @param sInput |
|
207 * @param cCharacter |
|
208 * @return string |
|
209 */ |
|
210 string GetStringUntilNextGivenChar( string& sInput, char cCharacter ); |
|
211 |
|
212 }; |
|
213 |
|
214 #endif |
|