Remove unused directories and files in video_in_hal
[staging/basesystem.git] / nsframework / framework_unified / client / include / native_service / ns_xml_writer.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file ns_xml_writer.h
19  * @brief \~english This file contains declaration of class CXMLWriter.
20  */
21 /** @addtogroup BaseSystem
22  *  @{
23  */
24 /** @addtogroup native_service
25  *  @ingroup BaseSystem
26  *  @{
27  */
28 /** @addtogroup framework_unified
29  *  @ingroup native_service
30  *  @{
31  */
32
33 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 /// \ingroup  tag_NS_ConfigParser
35 /// \brief    This file contains declaration of class CXMLWriter.
36 ///
37 ////////////////////////////////////////////////////////////////////////////////////////////////////
38
39 #ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__  // NOLINT  (build/header_guard)
40 #define __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__
41
42 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 // Include Files
44 ////////////////////////////////////////////////////////////////////////////////////////////////////
45 #include <libxml/tree.h>
46
47 #include <native_service/frameworkunified_types.h>
48 #include <native_service/ns_writer.h>
49
50 #include <string>
51
52 /**
53  * @class CXMLWriter
54  * \~english @brief this file has the CXMLWriter class definitions
55  * \~english @par   Brief Introduction
56  *        This class provides functionalities to write to XML config file
57  *
58  */
59 class CXMLWriter: public IConfigWriter {
60  public:
61   ////////////////////////////////////////////////////////////////////////////////
62   /// \ingroup CXMLWriter
63   /// \~english @par Brief
64   ///       Parameterless Constructor of CXMLWriter class
65   /// \~english @param  None
66   /// \~english @retval None
67   /// \~english @par Prerequisite
68   ///       - Load the shared library first
69   /// \~english @par Inside state change
70   ///       - The API no inside state change
71   /// \~english @par None
72   /// \~english @par Classification
73   ///       Public
74   /// \~english @par Type
75   ///       Sync
76   /// \~english @par Detail
77   ///       This API should be called by ServiceA and create a new object without file path of CXMLWriter
78   /// \~english @see GetCXMLWriterObjectNoParam
79   ////////////////////////////////////////////////////////////////////////////////
80
81   CXMLWriter();
82   ////////////////////////////////////////////////////////////////////////////////
83   /// \ingroup CXMLWriter
84   /// \~english @par Brief
85   ///       Constructor of CXMLWriter class
86   /// \~english @param  [IN] f_cFilePath
87   ///       std::string - Full path of the configuration file
88   /// \~english @retval None
89   /// \~english @par Prerequisite
90   ///       - Load the shared library first
91   /// \~english @par Inside state change
92   ///       - The API no inside state change
93   /// \~english @par None
94   /// \~english @par Classification
95   ///       Public
96   /// \~english @par Type
97   ///       Sync
98   /// \~english @par Detail
99   ///       This API should be called by ServiceA and create a new object with file path of CXMLWriter
100   /// \~english @see GetCXMLWriterObject
101   ////////////////////////////////////////////////////////////////////////////////
102   CXMLWriter(const std::string &f_cFilePath);  // NOLINT  (readability/nolint)
103
104   ////////////////////////////////////////////////////////////////////////////////////////////////
105   /// \ingroup ~CXMLWriter
106   /// \~english @par CXMLWriter
107   ///        Destructor of CXMLWriter class.
108   /// \~english @param None
109   /// \~english @retval none
110   /// \~english @par Preconditons
111   ///           - None
112   /// \~english @par Change of internal status
113   ///           -None
114   /// \~english @par Conditions of processing failure
115   ///           -None
116   /// \~english @par Detail
117   ///           Destruct the object of CXMLWriter
118   /// \~english @par Classification
119   ///           - Public
120   /// \~english @par Type
121   ///           - sync only
122   /// \~english @see CXMLWriter
123   ////////////////////////////////////////////////////////////////////////////////////////////////
124   ~CXMLWriter();
125
126   ////////////////////////////////////////////////////////////////////////////////
127   /// \ingroup ParseFile
128   /// \~english @par Brief
129   ///       Parse file
130   /// \~english @param  [IN] f_cFilePath
131   ///       std::string - path of file to parse
132   /// \~english @retval eFrameworkunifiedStatusOK Success
133   /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
134   /// \~english @par Prerequisite
135   ///       - Load the shared library first
136   ///       - Create CXMLWriter object
137   /// \~english @par Inside state change
138   ///       - The API no inside state change
139   /// \~english @par None
140   /// \~english @par Classification
141   ///       Public
142   /// \~english @par Type
143   ///       Sync
144   /// \~english @par Detail
145   ///       This function is used to parse the file
146   /// \~english @see CXMLWriter
147   ////////////////////////////////////////////////////////////////////////////////
148
149   EFrameworkunifiedStatus ParseFile(const std::string &f_cFilePath);
150
151   ////////////////////////////////////////////////////////////////////////////////
152   /// \ingroup SetValue
153   /// \~english @par Brief
154   ///       Set vaule for key
155   /// \~english @param  [IN] f_cKey
156   ///       std::string - key to search
157   /// \~english @param  [IN] f_cValue
158   ///       std::string - value to set
159   /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
160   /// \~english @retval eFrameworkunifiedStatusFail Failed
161   /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
162   /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
163   /// \~english @par Prerequisite
164   ///       - Load the shared library first
165   ///       - Create CXMLWriter object
166   ///       - ParseFile set the path
167   /// \~english @par Inside state change
168   ///       - The API no inside state change
169   /// \~english @par None
170   /// \~english @par Classification
171   ///       Public
172   /// \~english @par Type
173   ///       Sync
174   /// \~english @par Detail
175   ///       This function is used to set the value for the key
176   /// \~english @see CXMLWriter,ParseFile
177   ////////////////////////////////////////////////////////////////////////////////
178
179   EFrameworkunifiedStatus SetValue(const std::string &f_cKey, std::string f_cValue);
180   ////////////////////////////////////////////////////////////////////////////////
181   /// \ingroup SaveData
182   /// \~english @par Brief
183   ///       Save changed data
184   /// \~english @param  None
185   /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
186   /// \~english @retval eFrameworkunifiedStatusFail Failed
187   /// \~english @par Prerequisite
188   ///       - Load the shared library first
189   ///       - Create CXMLWriter object
190   ///       - ParseFile set the path
191   ///       - Change the data
192   /// \~english @par Inside state change
193   ///       - The API no inside state change
194   /// \~english @par None
195   /// \~english @par Classification
196   ///       Public
197   /// \~english @par Type
198   ///       Sync
199   /// \~english @par Detail
200   ///       This function is used to save the changed value to the xml config file
201   /// \~english @see GetCXMLWriterObjectNoParam
202   ////////////////////////////////////////////////////////////////////////////////
203
204   EFrameworkunifiedStatus SaveData();
205   ////////////////////////////////////////////////////////////////////////////////
206   /// \ingroup SetPath
207   /// \~english @par Brief
208   ///       Updata file path
209   /// \~english @param  [IN] f_cPath
210   ///       std::string - Path of file
211   /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
212   /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
213   /// \~english @par Prerequisite
214   ///       - Load the shared library first
215   ///       - Create CXMLWriter object
216   /// \~english @par Inside state change
217   ///       - The API no inside state change
218   /// \~english @par None
219   /// \~english @par Classification
220   ///       Public
221   /// \~english @par Type
222   ///       Sync
223   /// \~english @par Detail
224   ///       This function is used to set the config file path
225   /// \~english @see GetCXMLWriterObjectNoParam
226   ////////////////////////////////////////////////////////////////////////////////
227
228   EFrameworkunifiedStatus SetPath(const std::string &f_cPath);
229   ////////////////////////////////////////////////////////////////////////////////
230   /// \ingroup SetDataPtr
231   /// \~english @par Brief
232   ///       Parse file
233   /// \~english @param  [IN] f_pData
234   ///       PVOID - Pointer to data structure
235   /// \~english @retval VOID
236   /// \~english @par Prerequisite
237   ///       - Load the shared library first
238   ///       - Create CXMLWriter object
239   /// \~english @par Inside state change
240   ///       - The API no inside state change
241   /// \~english @par None
242   /// \~english @par Classification
243   ///       Public
244   /// \~english @par Type
245   ///       Sync
246   /// \~english @par Detail
247   ///       This function is used to set the data pointer in config writer class
248   /// \~english @see CXMLWriter
249   ////////////////////////////////////////////////////////////////////////////////
250
251   VOID SetDataPtr(PVOID f_pData);
252
253  private:
254 ////////////////////////////////////////////////////////////////////////////////////////////////
255 /// XMLSetValue
256 /// This function is used to parse the value from xml file
257 ///
258 /// \param  [IN] f_pCurrNode
259 ///     xmlNodePtr - pointer to current node in xml
260 /// \param  [IN] f_cUserKey
261 ///     std::string - Key to be searched for
262 /// \param  [IN] f_cValue
263 ///     std::string - Required Value for key
264 /// \param  [IN] f_bKeyFound
265 ///     std::string - Flag to check whether key is present in xml file
266 ///
267 /// \return EFrameworkunifiedStatus- success or failure
268 ///
269 ////////////////////////////////////////////////////////////////////////////////////////////////
270   EFrameworkunifiedStatus XMLSetValue(xmlNodePtr f_pCurrNode,
271                          const std::string &f_cUserKey,  // NOLINT  (readability/nolint)
272                          std::string &f_cValue,  // NOLINT  (readability/nolint)
273                          BOOL &f_bKeyFound);  // NOLINT  (readability/nolint)
274
275 // pointer of xml document structure(DOM)
276   xmlDocPtr m_pXmlDoc;
277
278 // path of config file
279   std::string m_cFilePath;
280 };
281
282 #ifdef __cplusplus
283 extern "C" {
284 #endif
285   ////////////////////////////////////////////////////////////////////////////////
286   /// \ingroup GetCXMLWriterObject
287   /// \~english @par Brief
288   ///      Get CXMLWriter object.
289   /// \~english @param  [IN] f_cFilePath
290   ///      std::string - path of file to parse
291   /// \~english @retval CXMLWriter *
292   /// \~english @par Prerequisite
293   ///       - Load the shared library first.
294   /// \~english @par Inside state change
295   ///       - The API no inside state change
296   /// \~english @par None
297   /// \~english @par Classification
298   ///       Public
299   /// \~english @par Type
300   ///       Sync
301   /// \~english @par Detail
302   ///       This API is used to create CXMLWriter object with file path and return the CXMLWriter pointer.
303   /// \~english @see None
304   ////////////////////////////////////////////////////////////////////////////////
305 CXMLWriter *GetCXMLWriterObject(CHAR *f_cFilePath);
306
307   ////////////////////////////////////////////////////////////////////////////////
308   /// \ingroup GetCXMLWriterObjectNoParam
309   /// \~english @par Brief
310   ///      Get CXMLWriter object.
311   /// \~english @param  None
312   /// \~english @retval CXMLWriter *
313   /// \~english @par Prerequisite
314   ///       - Load the shared library first.
315   /// \~english @par Inside state change
316   ///       - The API no inside state change
317   /// \~english @par None
318   /// \~english @par Classification
319   ///       Public
320   /// \~english @par Type
321   ///       Sync
322   /// \~english @par Detail
323   ///       This API is used to create CXMLWriter object without file path and return the CXMLWriter pointer.
324   /// \~english @see None
325   ////////////////////////////////////////////////////////////////////////////////
326
327 CXMLWriter *GetCXMLWriterObjectNoParam();
328 #ifdef __cplusplus
329 }
330 #endif
331
332 #endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__ */  // NOLINT  (build/header_guard)
333 /** @}*/
334 /** @}*/
335 /** @}*/
336 /** @}*/