2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file ns_config_parser_if.h
19 * @brief \~english This file contains declaration of class CNSConfigReader, CNSConfigWriter and CNSConfigParser. -- API
23 /** @addtogroup BaseSystem
26 /** @addtogroup native_service
30 /** @addtogroup framework_unified
31 * @ingroup Native_service
34 /** @addtogroup native
35 * @ingroup framework_unified
38 #ifndef NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_ // NOLINT (build/header_guard)
39 #define NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_
41 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 ////////////////////////////////////////////////////////////////////////////////////////////////////
45 #include <native_service/frameworkunified_types.h>
48 // forward declaration of classes
53 * @class CNSConfigReader
54 * @brief \~english Configuration File Read Service Class
55 * @par \~english Brief Introduction
56 * \~english This class provides API's to application to read from configuration files.
59 class CNSConfigReader {
61 ////////////////////////////////////////////////////////////////////////////////////////////////
62 /// \ingroup CNSConfigReader
63 /// \~english @par Brief
64 /// Constructor of CNSConfigReader class
65 /// This constructor can only be called by derived class. Application cannot use this constructor
66 /// to create object of CNSConfigReader class.
67 /// \~english @retval none
68 /// \~english @par Prerequisite
70 /// \~english @par Change of internal state
72 /// \~english @par Conditions of processing failure
74 /// \~english @par Classification
76 /// \~english @par Type
78 /// \~english @par Detail
79 /// It is called when generating the instance of CNSConfigParser class.
80 /// \~english @see CNSConfigReader::~CNSConfigReader
81 ////////////////////////////////////////////////////////////////////////////////////////////////
84 ////////////////////////////////////////////////////////////////////////////////////////////////
85 /// \ingroup CNSConfigReader
86 /// \~english @par Brief
87 /// Constructor of CNSConfigReader class
88 /// This is depricated. Use parameterless constructor instead to create object and
89 /// Parse(filepath) to parse the file using reader object.
90 /// \~english @param [in] f_c_filepath
91 /// const std::string& - Name of the configuration file
92 /// \~english @retval none
93 /// \~english @par Prerequisite
95 /// \~english @par Change of internal state
97 /// \~english @par Conditions of processing failure
99 /// \~english @par Classification
101 /// \~english @par Type
103 /// \~english @par Detail
104 /// It doesn't need to call Parse() function to execute parse process of configuration file,
105 /// when using the constructor with file path. However, because we don't execute error process,
106 /// if it needs to reply error about parse process, we must to use the constructor without parameter
107 /// and call Parse() function.
108 /// \~english @see CNSConfigReader::~CNSConfigReader
109 ////////////////////////////////////////////////////////////////////////////////////////////////
110 explicit CNSConfigReader(const std::string &f_c_filepath);
112 ////////////////////////////////////////////////////////////////////////////////////////////////
114 /// \~english @par Brief
115 /// This function is used to parse configuration file
116 /// \~english @param [in] f_c_filepath
117 /// const std::string& - Name of the configuration file
118 /// \~english @retval eFrameworkunifiedStatusOK - success
119 /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document is not proper
120 /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
121 /// \~english @retval eFrameworkunifiedStatusInvldParam invalid parameter
122 /// \~english @retval eFrameworkunifiedStatusErrOther - file data error
123 /// \~english @par Prerequisite
125 /// \~english @par Change of internal state
127 /// \~english @par Conditions of processing failure
128 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
129 /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
130 /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
131 /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
132 /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
133 /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
134 /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
135 /// \~english @par Classification
137 /// \~english @par Type
139 /// \~english @par Detail
140 /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
141 /// and store the parsed contents in it.
142 /// \~english @see CNSConfigWriter::Parse, CNSConfigParser::Parse
143 ////////////////////////////////////////////////////////////////////////////////////////////////
144 EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
146 ////////////////////////////////////////////////////////////////////////////////////////////////
147 /// \ingroup ~CNSConfigReader
148 /// \~english @par Brief
149 /// Destructor of CNSConfigReader class.
150 /// It is used when release the instance.
151 /// \~english @retval none
152 /// \~english @par Prerequisite
153 /// - Call the construct of CNSConfigReader
154 /// \~english @par Change of internal state
156 /// \~english @par Conditions of processing failure
158 /// \~english @par Classification
160 /// \~english @par Type
162 /// \~english @par Detail
163 /// Release the used memory and the parsed result of configuration file.
164 /// \~english @see CNSConfigReader::CNSConfigReader
165 ////////////////////////////////////////////////////////////////////////////////////////////////
168 ////////////////////////////////////////////////////////////////////////////////////////////////
170 /// \~english @par Brief
171 /// This function is used to get the bool value associated with key.
172 /// If there are multiple values associated with the same key, then the first value is returned.
173 /// This API has been depricated, use GetBool(key, ref_value)
174 /// \~english @param [in] f_c_key
175 /// const std::string& - key to search
176 /// \~english @retval TRUE - value associated with key
177 /// \~english @retval FALSE - Failed to get value associated with key
178 /// \~english @par Prerequisite
179 /// - Call the construct of CNSConfigReader
180 /// \~english @par Change of internal state
182 /// \~english @par Conditions of processing failure
183 /// - Memory allocation failed [FALSE]
184 /// - Data of search key(f_c_key) designated by parameter is NULL [FALSE]
185 /// - Can not find search key(f_c_key) designated by parameter [FALSE]
186 /// - Value getted from configuration file is not true or false [FALSE]
187 /// \~english @par Classification
189 /// \~english @par Type
191 /// \~english @par Detail
192 /// Return the value(TRUE/FALSE) associated with key.
193 /// If there are multiple values associated with the same key, return the first value.
194 /// This API has been depricated, please use GetBool(const std::string& f_c_key, BOOL& f_bValue).
195 /// \~english @see CNSConfigWriter::SetBool
196 ////////////////////////////////////////////////////////////////////////////////////////////////
197 BOOL GetBool(const std::string &f_c_key);
199 ////////////////////////////////////////////////////////////////////////////////////////////////
200 /// \ingroup GetDouble
201 /// \~english @par Brief
202 /// This function is used to get the double value associated with key.
203 /// If there are multiple values associated with the same key, then the first value is returned.
204 /// This API has been depricated, use GetDouble(key, ref_value)
205 /// \~english @param [in] f_c_key
206 /// const std::string& - key to search
207 /// \~english @param [out] - none
208 /// \~english @retval F_64 - value associated with key
209 /// \~english @retval 0 - Failed to get value associated with key(64bit)
210 /// \~english @par Prerequisite
211 /// - Call the construct of CNSConfigReader
212 /// \~english @par Change of internal state
214 /// \~english @par Conditions of processing failure
215 /// - Memory allocation failed [0]
216 /// - Data of search key(f_c_key) designated by parameter is NULL [0]
217 /// - Can not find search key(f_c_key) designated by parameter [0]
218 /// - Failed to change data getted from configuration file from string type to double type [0]
219 /// \~english @par Classification
222 /// Please pay attention to the following points when you use this API.\n
223 /// - We can take the value in specification only if it is in the range of
224 /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
225 /// \~english @par Type
227 /// \~english @par Detail
228 /// Return the value(64bit) associated with key.
229 /// If there are multiple values associated with the same key, return the first value.
230 /// This API has been depricated, please use GetDouble(const std::string& f_c_key, F_64& f_f_value).
231 /// \~english @see CNSConfigWriter::Set
232 ////////////////////////////////////////////////////////////////////////////////////////////////
233 F_64 GetDouble(const std::string &f_c_key);
235 ////////////////////////////////////////////////////////////////////////////////////////////////
236 /// \ingroup GetFloat
237 /// \~english @par Brief
238 /// This function is used to get the float value associated with key
239 /// If there are multiple values associated with the same key, then the first value is returned.
240 /// This API has been depricated, use GetFloat(key, ref_value)
241 /// \~english @param [in] f_c_key
242 /// const std::string& - key to search
243 /// \~english @retval F_32 value associated with key
244 /// \~english @retval 0 - Failed to get value associated with key(32bit)
245 /// \~english @par Prerequisite
246 /// - Call the construct of CNSConfigReader
247 /// \~english @par Change of internal state
249 /// \~english @par Conditions of processing failure
250 /// - Memory allocation failed [0]
251 /// - Data of search key(f_c_key) designated by parameter is NULL [0]
252 /// - Can not find search key(f_c_key) designated by parameter [0]
253 /// - Can not change the data string, because that data string getted
254 /// from configuration file is over range [9.8765436e+12]
255 /// \~english @par Classification
257 /// \~english @par Type
259 /// \~english @par Detail
260 /// Return the value(32bit) associated with key.
261 /// If there are multiple values associated with the same key, return the first value.
262 /// This API has been depricated, please use GetFloat(const std::string& f_c_key, F_32& f_f_value).
263 /// \~english @see CNSConfigWriter::Set
264 ////////////////////////////////////////////////////////////////////////////////////////////////
265 F_32 GetFloat(const std::string &f_c_key);
267 ////////////////////////////////////////////////////////////////////////////////////////////////
269 /// \~english @par Brief
270 /// This function is used to get the integer value associated with key
271 /// If there are multiple values associated with the same key, then the first value is returned.
272 /// This API has been depricated, use GetInt(key, ref_value)
273 /// \~english @param [in] f_c_key
274 /// const std::string& - key to search
275 /// \~english @retval SI_32 - value associated with key
276 /// \~english @retval 0.0f - Failed to get value associated with key(32bit)
277 /// \~english @par Prerequisite
278 /// - Call the construct of CNSConfigReader
279 /// \~english @par Change of internal state
281 /// \~english @par Conditions of processing failure
282 /// - Memory allocation failed [0]
283 /// - Data of search key(f_c_key) designated by parameter is NULL [0]
284 /// - Can not find search key(f_c_key) designated by parameter [0]
285 /// - Failed to change data getted from Configuration file from string type to Int type [0]
286 /// \~english @par Classification
288 /// \~english @par Type
290 /// \~english @par Detail
291 /// Return the value(32bit) associated with key.
292 /// If there are multiple values associated with the same key, return the first value.
293 /// This API has been depricated, please use GetInt(const std::string& f_c_key, SI_32& f_si_value).
295 /// Please pay attention to the following points when you use this API.\n
296 /// - If data string getted from file is larger than INT_MAX(2147483648), return -1.
297 /// \~english @see CNSConfigWriter::Set
298 ////////////////////////////////////////////////////////////////////////////////////////////////
299 SI_32 GetInt(const std::string &f_c_key);
301 ////////////////////////////////////////////////////////////////////////////////////////////////
302 /// \ingroup GetString
303 /// \~english @par Brief
304 /// This function is used to get the string value associated with key
305 /// If there are multiple values associated with the same key, all the values separated by
306 /// delimiter "\n" are returned.
307 /// This API has been depricated, use GetString(key, ref_value)
308 /// \~english @param [in] f_c_key
309 /// const std::string& - key to search
310 /// \~english @retval std::string value(string) associated with key
311 /// \~english @retval nullbuffer - Failed to get value associated with key
312 /// \~english @par Prerequisite
313 /// - Call the construct of CNSConfigReader
314 /// \~english @par Change of internal state
316 /// \~english @par Conditions of processing failure
317 /// - Memory allocation failed [null buffer]
318 /// - Data of search key(f_c_key) designated by parameter is NULL [null buffer]
319 /// - Can not find search key(f_c_key) designated by parameter [null buffer]
320 /// \~english @par Classification
322 /// \~english @par Type
324 /// \~english @par Detail
325 /// Return the value(string) associated with key.
326 /// If there are multiple values associated with the same key,
327 /// return all the values separated by delimiter "\n".
328 /// This API has been depricated, please use GetString(
329 /// const std::string& f_c_key, std::string& f_cValue).
330 /// \~english @see CNSConfigWriter::Set
331 ////////////////////////////////////////////////////////////////////////////////////////////////
332 std::string GetString(const std::string &f_c_key);
334 ////////////////////////////////////////////////////////////////////////////////////////////////
336 /// \~english @par Brief
337 /// This function is used to get the bool value associated with key
338 /// If there are multiple values associated with the same key, then the first value is returned.
339 /// \~english @param [in] f_c_key
340 /// const std::string& - key string
341 /// \~english @param [in] f_b_value
342 /// BOOL& - value associated with key
343 /// \~english @retval eFrameworkunifiedStatusOK - success
344 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
345 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
346 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
347 /// \~english @retval eFrameworkunifiedStatusErrOther - value is not bool type
348 /// \~english @par Prerequisite
349 /// - Call the construct of CNSConfigReader
350 /// \~english @par Change of internal state
352 /// \~english @par Conditions of processing failure
353 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
354 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
355 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
356 /// - Value getted from configuration file is not true or false [eFrameworkunifiedStatusErrOther]
357 /// \~english @par Classification
359 /// \~english @par Type
361 /// \~english @par Detail
362 /// Return the value(TRUE/FALSE) associated with key.
363 /// If there are multiple values associated with the same key, return the first value.
364 /// \~english @see CNSConfigWriter::SetBool
365 ////////////////////////////////////////////////////////////////////////////////////////////////
366 EFrameworkunifiedStatus GetBool(const std::string &f_c_key, BOOL &f_b_value); // NOLINT (readability/nolint)
368 ////////////////////////////////////////////////////////////////////////////////////////////////
369 /// \ingroup GetDouble
370 /// \~english @par Brief
371 /// This function is used to get the double value associated with key.
372 /// If there are multiple values associated with the same key, then the first value is returned.
373 /// \~english @param [in] f_c_key
374 /// const std::string& - key to search
375 /// \~english @param [in] f_f_value
376 /// F_64& - value associated with key
377 /// \~english @retval eFrameworkunifiedStatusOK - success
378 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
379 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
380 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
381 /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
382 /// \~english @par Prerequisite
383 /// - Call the construct of CNSConfigReader
384 /// \~english @par Change of internal state
386 /// \~english @par Conditions of processing failure
387 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
388 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
389 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
390 /// - Changed result of data string getted from configuration file is overflow or underflow [eFrameworkunifiedStatusInvldBuf]
391 /// \~english @par Classification
394 /// Please pay attention to the following points when you use this API.\n
395 /// - Return eFrameworkunifiedStatusOK if we didn't excute the changing operation
396 /// - We can take the value in specification only if it is in the range of
397 /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
398 /// \~english @par Type
400 /// \~english @par Detail
401 /// Return the value(64bit) associated with key.
402 /// If there are multiple values associated with the same key, return the first value.
403 /// \~english @see CNSConfigWriter::Set
404 ////////////////////////////////////////////////////////////////////////////////////////////////
405 EFrameworkunifiedStatus GetDouble(const std::string &f_c_key, F_64 &f_f_value); // NOLINT (readability/nolint)
407 ////////////////////////////////////////////////////////////////////////////////////////////////
408 /// \ingroup GetFloat
409 /// \~english @par Brief
410 /// This function is used to get the float value associated with key
411 /// If there are multiple values associated with the same key, then the first value is returned.
412 /// \~english @param [in] f_c_key
413 /// const std::string& - key to search
414 /// \~english @param [in] f_f_value
415 /// F_32& - value associated with key
416 /// \~english @retval eFrameworkunifiedStatusOK - success
417 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
418 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
419 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
420 /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
421 /// \~english @par Prerequisite
422 /// - Call the construct of CNSConfigReader
423 /// \~english @par Change of internal state
425 /// \~english @par Conditions of processing failure
426 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
427 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
428 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
429 /// - Can not change the data string, because that data string getted
430 /// from configuration file is over range [9.8765436e+12]
431 /// \~english @par Classification
433 /// \~english @par Type
435 /// \~english @par Detail
436 /// Return the value(32bit) associated with key.
437 /// If there are multiple values associated with the same key, return the first value.
438 /// \~english @see CNSConfigWriter::Set
439 ////////////////////////////////////////////////////////////////////////////////////////////////
440 EFrameworkunifiedStatus GetFloat(const std::string &f_c_key, F_32 &f_f_value); // NOLINT (readability/nolint)
442 ////////////////////////////////////////////////////////////////////////////////////////////////
444 /// \~english @par Brief
445 /// This function is used to get the integer value associated with key
446 /// If there are multiple values associated with the same key, then the first value is returned.
447 /// \~english @param [in] f_c_key
448 /// const std::string& - key to search
449 /// \~english @param [out] f_si_value
450 /// SI_32& - value associated with key
451 /// \~english @retval eFrameworkunifiedStatusOK - success
452 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
453 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
454 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
455 /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
456 /// \~english @par Prerequisite
457 /// - Call the construct of CNSConfigReader
458 /// \~english @par Change of internal state
460 /// \~english @par Conditions of processing failure
461 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
462 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
463 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
464 /// - Failed to change data getted from Configuration file from string type to Int type [eFrameworkunifiedStatusInvldBuf]
465 /// \~english @par Classification
467 /// \~english @par Type
469 /// \~english @par Detail
470 /// Return the value(32bit) associated with key.
471 /// If there are multiple values associated with the same key, return all the values separated by delimiter "\n".
472 /// \~english @see CNSConfigWriter::Set
473 ////////////////////////////////////////////////////////////////////////////////////////////////
474 EFrameworkunifiedStatus GetInt(const std::string &f_c_key, SI_32 &f_si_value); // NOLINT (readability/nolint)
476 ////////////////////////////////////////////////////////////////////////////////////////////////
477 /// \ingroup GetString
478 /// \~english @par Brief
479 /// This function is used to get the string value associated with key
480 /// If there are multiple values associated with the same key, all the values separated by
481 /// delimiter "\n" are returned.
482 /// \~english @param [in] f_c_key
483 /// const std::string& - key to search
484 /// \~english @param [in] f_c_value
485 /// std::string& - value(string) associated with key
486 /// \~english @retval eFrameworkunifiedStatusOK - success
487 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
488 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
489 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
490 /// \~english @par Prerequisite
491 /// - Call the construct of CNSConfigReader
492 /// \~english @par Change of internal state
494 /// \~english @par Conditions of processing failure
495 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
496 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
497 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
498 /// \~english @par Classification
500 /// \~english @par Type
502 /// \~english @par Detail
503 /// Return the value(string) associated with key.
504 /// If there are multiple values associated with the same key,
505 /// return all the values separated by delimiter "\n".
506 /// \~english @see CNSConfigWriter::Set
507 ////////////////////////////////////////////////////////////////////////////////////////////////
508 EFrameworkunifiedStatus GetString(const std::string &f_c_key, std::string &f_c_value); // NOLINT (readability/nolint)
511 ////////////////////////////////////////////////////////////////////////////////////////////////
513 /// This function is used to get the data pointer. This pointer is then set in config writer.
514 /// This is needed to avoid recreation of same data structure object in both reader and writer
515 /// when we create object of NSConfigParser.
517 /// \return PVOID - pointer of data structure
519 ////////////////////////////////////////////////////////////////////////////////////////////////
523 ////////////////////////////////////////////////////////////////////////////////////////////////
525 /// This function is used to remove the line feed or carriage return from string
527 /// \param [in] f_cValue
528 /// std::string - value
530 /// \return std::string - formated data
532 ////////////////////////////////////////////////////////////////////////////////////////////////
533 std::string FormatValue(const std::string &f_c_value);
535 // config reader pointer
536 IConfigReader *m_pReader;
537 static HANDLE m_hNSXMLLibHandle; // NOLINT (readability/nolint)
542 * @class CNSConfigWriter
543 * @brief \~english File Write Service Class
544 * @par \~english Brief Introduction
545 * \~english This class provides API's to application to write to configuration files.
548 class CNSConfigWriter {
550 ////////////////////////////////////////////////////////////////////////////////////////////////
551 /// \ingroup CNSConfigWriter
552 /// \~english @par Brief
553 /// Constructor of CNSConfigWriter class
554 /// \~english @retval none
555 /// \~english @par Prerequisite
557 /// \~english @par Change of internal state
559 /// \~english @par Conditions of processing failure
561 /// \~english @par Classification
563 /// \~english @par Type
565 /// \~english @par Detail
566 /// It is called when generating the instance of CNSConfigWriter class.
567 /// \~english @see CNSConfigWriter::~CNSConfigWriter
568 ////////////////////////////////////////////////////////////////////////////////////////////////
571 ////////////////////////////////////////////////////////////////////////////////////////////////
572 /// \ingroup CNSConfigWriter
573 /// \~english @par Brief
574 /// Constructor of CNSConfigWriter class
575 /// This is depricated. Use parameterless constructor instead to create object and
576 /// Parse(filepath) to parse the file using writer object.
577 /// \~english @param [in] f_c_filepath
578 /// const std::string& - Full path of the configuration file
579 /// \~english @retval none
580 /// \~english @par Prerequisite
582 /// \~english @par Change of internal state
584 /// \~english @par Conditions of processing failure
586 /// \~english @par Classification
588 /// \~english @par Type
590 /// \~english @par Detail
591 /// It doesn't need to call Parse() function to execute parse process of configuration File,
592 /// when using the constructor with file path. However, because we don't execute error process,
593 /// if it needs to reply error about parse process, we must to use the constructor without parameter
594 /// and call Parse() function.
595 /// \~english @see CNSConfigWriter::~CNSConfigWriter
596 ////////////////////////////////////////////////////////////////////////////////////////////////
597 explicit CNSConfigWriter(const std::string &f_c_filepath);
599 ////////////////////////////////////////////////////////////////////////////////////////////////
600 /// \ingroup ~CNSConfigWriter
601 /// \~english @par Brief
602 /// Destructor of CNSConfigWriter class
603 /// \~english @retval none
604 /// \~english @par Prerequisite
605 /// - Call the construct of CNSConfigWriter
606 /// \~english @par Change of internal state
608 /// \~english @par Conditions of processing failure
610 /// \~english @par Classification
612 /// \~english @par Type
614 /// \~english @par Detail
615 /// Release the used memory and the parsed result of Configuration File.
616 /// \~english @see CNSConfigWriter::CNSConfigWriter
617 ////////////////////////////////////////////////////////////////////////////////////////////////
620 ////////////////////////////////////////////////////////////////////////////////////////////////
622 /// \~english @par Brief
623 /// This function is used to parse the configuration file
624 /// \~english @param [in] f_c_filepath
625 /// const std::string& - Name of the configuration file
626 /// \~english @retval eFrameworkunifiedStatusOK - success
627 /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document not proper
628 /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
629 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
630 /// \~english @retval eFrameworkunifiedStatusErrOther - file data error
631 /// \~english @par Prerequisite
632 /// - Call the construct of CNSConfigWriter
633 /// \~english @par Change of internal state
635 /// \~english @par Conditions of processing failure
636 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
637 /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
638 /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
639 /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
640 /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
641 /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
642 /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
643 /// \~english @par Classification
645 /// \~english @par Type
647 /// \~english @par Detail
648 /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
649 /// and store the parsed contents in it.
650 /// \~english @see CNSConfigParser::Parse, CNSConfigWriter::Parse
651 ////////////////////////////////////////////////////////////////////////////////////////////////
652 EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
654 ////////////////////////////////////////////////////////////////////////////////////////////////
656 /// \~english @par Brief
657 /// This function is used to save the configuration settings to config file
658 /// \~english @retval eFrameworkunifiedStatusOK - success
659 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
660 /// \~english @retval eFrameworkunifiedStatusFail - file access fail
661 /// \~english @par Prerequisite
662 /// - Call the construct of CNSConfigWriter
663 /// \~english @par Change of internal state
665 /// \~english @par Conditions of processing failure
666 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
667 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
668 /// - File doesn't exit [eFrameworkunifiedStatusFail]
669 /// - File access error [eFrameworkunifiedStatusFail]
670 /// - Can't open file [eFrameworkunifiedStatusFail]
671 /// \~english @par Classification
673 /// \~english @par Type
675 /// \~english @par Detail
676 /// Save the data stored in memory to configuration file.
677 /// \~english @see CNSConfigWriter::SetBool, CNSConfigWriter::Set
678 ////////////////////////////////////////////////////////////////////////////////////////////////
679 EFrameworkunifiedStatus Save();
681 ////////////////////////////////////////////////////////////////////////////////////////////////
683 /// \~english @par Brief
684 /// This function is used to set the bool value corresponding to key
685 /// This function is not overloaded with other Set() API's of this class because
686 /// BOOL is typedef of UI_32 so when we pass integer or BOOL to Set API it would have
687 /// called the same API.
688 /// If multiple identical keys are found it sets the value for all the keys.
689 /// \~english @param [in] f_c_key
690 /// const std::string& - key
691 /// \~english @param [in] f_b_value
692 /// BOOL - bool value to set for key
693 /// \~english @retval eFrameworkunifiedStatusOK - success
694 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
695 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
696 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
697 /// \~english @retval eFrameworkunifiedStatusErrOther - if passsed value is invalid
698 /// \~english @par Prerequisite
699 /// - Call the construct of CNSConfigWriter
700 /// \~english @par Change of internal state
702 /// \~english @par Conditions of processing failure
703 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
704 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
705 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
706 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
707 /// - Data(f_bValue) of search key designated by parameter is not bool [eFrameworkunifiedStatusInvldParam]
708 /// \~english @par Classification
711 /// Please pay attention to the following points when you use this API.\n
712 /// - Valid condition of search key string: there is no separator and line feed in config tag
713 /// \~english @par Type
715 /// \~english @par Detail
716 /// Set the value(bool type) associated with key to data stored in memory.
717 /// If there are multiple keys, set the values associated with all keys.
718 /// \~english @see CNSConfigReader::GetBool
719 ////////////////////////////////////////////////////////////////////////////////////////////////
720 EFrameworkunifiedStatus SetBool(const std::string &f_c_key, BOOL f_b_value);
722 ////////////////////////////////////////////////////////////////////////////////////////////////
724 /// \~english @par Brief
725 /// This function is used to set the double value corresponding to key.
726 /// If multiple identical keys are found it sets the value for all the keys.
727 /// \~english @param [in] f_c_key
728 /// const std::string& - key
729 /// \~english @param [in] f_f_value
730 /// F_64 - double value to set for key
731 /// \~english @retval eFrameworkunifiedStatusOK - success
732 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
733 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
734 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
735 /// \~english @par Prerequisite
736 /// - Call the construct of CNSConfigWriter
737 /// \~english @par Change of internal state
739 /// \~english @par Conditions of processing failure
740 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
741 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
742 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
743 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
744 /// \~english @par Classification
747 /// Please pay attention to the following points when you use this API.\n
748 /// - We can take the value in specification only if it is in the range of
749 /// [2.22507385850720138309e-308L, 1.7976931348623157e+308L](min value of double, max value of double).
750 /// - Valid condition of search key string: there is no separator and line feed in config tag
751 /// \~english @par Type
753 /// \~english @par Detail
754 /// Set the bool type value(64bit) associated with key to data stored in memory.
755 /// If there are multiple keys, set the values associated with all keys.
756 /// \~english @see CNSConfigReader::GetDouble
757 ////////////////////////////////////////////////////////////////////////////////////////////////
758 EFrameworkunifiedStatus Set(const std::string &f_c_key, F_64 f_f_value);
760 ////////////////////////////////////////////////////////////////////////////////////////////////
762 /// \~english @par Brief
763 /// This function is used to set the float value corresponding to key.
764 /// If multiple identical keys are found it sets the value for all the keys.
765 /// \~english @param [in] f_c_key
766 /// const std::string& - key
767 /// \~english @param [in] f_f_value
768 /// F_32 - float value to set for key
769 /// \~english @retval eFrameworkunifiedStatusOK - success
770 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
771 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
772 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
773 /// \~english @par Prerequisite
774 /// - Call the construct of CNSConfigWriter
775 /// \~english @par Change of internal state
777 /// \~english @par Conditions of processing failure
778 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
779 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
780 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
781 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
782 /// \~english @par Classification
785 /// Please pay attention to the following points when you use this API.\n
786 /// - We can take the value in specification only if it is in the range of
787 /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
788 /// - Valid condition of search key string: there is no separator and line feed in config tag
789 /// \~english @par Type
791 /// \~english @par Detail
792 /// Set the float type value(32bit) associated with key to data stored in memory.
793 /// If there are multiple keys, set the values associated with all keys.
794 /// \~english @see CNSConfigReader::GetFloat
795 ////////////////////////////////////////////////////////////////////////////////////////////////
796 EFrameworkunifiedStatus Set(const std::string &f_c_key, F_32 f_f_value);
798 ////////////////////////////////////////////////////////////////////////////////////////////////
800 /// \~english @par Brief
801 /// This function is used to set the integer value corresponding to key.
802 /// If multiple identical keys are found it sets the value for all the keys.
803 /// \~english @param [in] f_c_key
804 /// const std::string& - key
805 /// \~english @param [in] f_si_value
806 /// SI_32 - integer value to set for key
807 /// \~english @retval eFrameworkunifiedStatusOK - success
808 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
809 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
810 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
811 /// \~english @par Prerequisite
812 /// - Call the construct of CNSConfigWriter
813 /// \~english @par Change of internal state
815 /// \~english @par Conditions of processing failure
816 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
817 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
818 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
819 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
820 /// \~english @par Classification
823 /// Please pay attention to the following points when you use this API.\n
824 /// - Valid condition of search key string: there is no separator and line feed in config tag
825 /// \~english @par Type
827 /// \~english @par Detail
828 /// Set the int type value(32bit) associated with key to data stored in memory.
829 /// If there are multiple keys, set the values associated with all keys.
830 /// \~english @see CNSConfigReader::GetInt
831 ////////////////////////////////////////////////////////////////////////////////////////////////
832 EFrameworkunifiedStatus Set(const std::string &f_c_key, SI_32 f_si_value);
834 ////////////////////////////////////////////////////////////////////////////////////////////////
836 /// \~english @par Brief
837 /// This function is used to set the string value corresponding to key.
838 /// If multiple identical keys are found it sets the value for all the keys.
839 /// \~english @param [in] f_c_key
840 /// const std::string& - key
841 /// \~english @param [in] f_s_value
842 /// const std::string& - string value to set for key
843 /// \~english @retval eFrameworkunifiedStatusOK - success
844 /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
845 /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
846 /// \~english @retval eFrameworkunifiedStatusFail - can not find key
847 /// \~english @par Prerequisite
848 /// - Call the construct of CNSConfigWriter
849 /// \~english @par Change of internal state
851 /// \~english @par Conditions of processing failure
852 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
853 /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
854 /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
855 /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
856 /// \~english @par Classification
859 /// Please pay attention to the following points when you use this API.\n
860 /// - Valid condition of search key string: there is no separator and line feed in config tag
861 /// \~english @par Type
863 /// \~english @par Detail
864 /// Set the string type value associated with key to data stored in memory.
865 /// If there are multiple keys, set the values associated with all keys.
866 /// \~english @see CNSConfigReader::GetString
867 ////////////////////////////////////////////////////////////////////////////////////////////////
868 EFrameworkunifiedStatus Set(const std::string &f_c_key, const std::string &f_s_value);
871 ////////////////////////////////////////////////////////////////////////////////////////////////
873 /// Constructor of CNSConfigWriter class
875 /// \param [in] f_c_filepath
876 /// const std::string& - Full path of the configuration file
877 /// \param [in] f_b_noload
878 /// BOOL - load writer with no data
882 ////////////////////////////////////////////////////////////////////////////////////////////////
883 CNSConfigWriter(const std::string &f_c_filepath, BOOL f_b_noload);
885 ////////////////////////////////////////////////////////////////////////////////////////////////
887 /// This function is used to set the data pointer in writer class with data pointer
888 /// created in config reader class.
889 /// This is needed to avoid recreation of same data structure object in both reader and writer
890 /// when we create object of NSConfigParser
892 /// \param [in] f_p_data
893 /// PVOID - Pointer to data structure
897 ////////////////////////////////////////////////////////////////////////////////////////////////
898 VOID SetDataPtr(PVOID f_p_data);
900 ////////////////////////////////////////////////////////////////////////////////////////////////
902 /// This function is used to create config object
904 /// \param [in] f_c_filepath
905 /// const std::string& - Name of the configuration file
907 /// \return EFrameworkunifiedStatus - success or failure
909 ////////////////////////////////////////////////////////////////////////////////////////////////
910 EFrameworkunifiedStatus Create(const std::string &f_c_filepath);
913 // config writer pointer
914 IConfigWriter *m_pWriter;
915 static HANDLE m_hNSXMLLibHandle; // NOLINT (readability/nolint)
920 * @class CNSConfigParser
921 * @brief \~english File both Reade and Write Service Class
922 * @par \~english Brief Introduction
923 * \~english This class provides API's to application for both reading and writing into configuration files.
926 class CNSConfigParser: public CNSConfigReader, public CNSConfigWriter {
928 ////////////////////////////////////////////////////////////////////////////////////////////////
929 /// \ingroup CNSConfigParser
930 /// \~english @par Brief
931 /// Constructor of CNSConfigParser class
932 /// \~english @retval none
933 /// \~english @par Prerequisite
935 /// \~english @par Change of internal state
937 /// \~english @par Conditions of processing failure
939 /// \~english @par Classification
941 /// \~english @par Type
943 /// \~english @par Detail
944 /// It is called when generating the instance of CNSConfigParser class.
945 /// \~english @see CNSConfigParser::~CNSConfigParser
946 ////////////////////////////////////////////////////////////////////////////////////////////////
949 ////////////////////////////////////////////////////////////////////////////////////////////////
950 /// \ingroup CNSConfigParser
951 /// \~english @par Brief
952 /// Constructor of CNSConfigParser class
953 /// This is depricated. Use parameterless constructor instead to create object and
954 /// Parse(filepath) to parse the file using parser object.
955 /// \~english @param [in] f_c_filepath
956 /// const std::string& - Full path of the configuration file
957 /// \~english @retval none
958 /// \~english @par Prerequisite
960 /// \~english @par Change of internal state
962 /// \~english @par Conditions of processing failure
964 /// \~english @par Classification
966 /// \~english @par Type
968 /// \~english @par Detail
969 /// It doesn't need to call Parse() function to execute parse process of configuration File,
970 /// when using the constructor with file path. However, because we don't execute error process,
971 /// if it needs to reply error about parse process, we must to use the constructor without parameter
972 /// and call Parse() function.
973 /// \~english @see CNSConfigParser::~CNSConfigParser
974 ////////////////////////////////////////////////////////////////////////////////////////////////
975 explicit CNSConfigParser(const std::string &f_c_filepath);
977 ////////////////////////////////////////////////////////////////////////////////////////////////
978 /// \ingroup ~CNSConfigParser
979 /// \~english @par Brief
980 /// Destructor of CNSConfigParser class
981 /// \~english @retval none
982 /// \~english @par Prerequisite
983 /// - Call the construct of CNSConfigParser
984 /// \~english @par Change of internal state
986 /// \~english @par Conditions of processing failure
988 /// \~english @par Classification
990 /// \~english @par Type
992 /// \~english @par Detail
993 /// Release the used memory and the parsed result of Configuration File.
994 /// \~english @see CNSConfigParser::CNSConfigParser
995 ////////////////////////////////////////////////////////////////////////////////////////////////
998 ////////////////////////////////////////////////////////////////////////////////////////////////
1000 /// \~english @par Brief
1001 /// This function is used to create config reader object and config writer object
1002 /// which then parses the configuration file.
1003 /// \~english @param [in] f_c_filepath
1004 /// const std::string& - Name of the configuration file
1005 /// \~english @retval eFrameworkunifiedStatusOK on success
1006 /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document not proper
1007 /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
1008 /// \~english @retval eFrameworkunifiedStatusInvldParam invalid parameter
1009 /// \~english @retval eFrameworkunifiedStatusErrOther file data error
1010 /// \~english @par Prerequisite
1011 /// - Call the construct of CNSConfigParser
1012 /// \~english @par Change of internal state
1014 /// \~english @par Conditions of processing failure
1015 /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
1016 /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
1017 /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
1018 /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
1019 /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
1020 /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
1021 /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
1022 /// \~english @par Classification
1024 /// \~english @par Type
1026 /// \~english @par Detail
1027 /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
1028 /// and store the parsed contents in it.
1029 /// \~english @see CNSConfigReader::Parse, CNSConfigWriter::Parse
1030 ////////////////////////////////////////////////////////////////////////////////////////////////
1031 EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
1034 #endif // NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_ // NOLINT (build/header_guard)