Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / nsframework / framework_unified / client / NS_ConfigParser / include / ns_cfg_parser.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 /// \ingroup  tag_NS_ConfigParser
19 /// \brief    This file contains the declaration of class CCFGParser.
20 ///       This class contains the parsing logic for reading and writing from and to cfg files
21 ///       respectively.
22 ///
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24
25 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
26 #define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
27
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 // Include Files
30 ////////////////////////////////////////////////////////////////////////////////////////////////////
31 #include <native_service/frameworkunified_types.h>
32 #include <string>
33 #include <map>
34
35 // forward declaration of classes
36 class CNode;
37 class CBlock;
38
39 typedef std::map<std::string, CBlock *> CFGData_Type;
40
41 class CCFGParser {
42  public:
43   ////////////////////////////////////////////////////////////////////////////////////////////////
44   /// CCFGParser
45   /// Constructor of CCFGReader class
46   ///
47   /// \param
48   ///
49   /// \return
50   ///
51   ////////////////////////////////////////////////////////////////////////////////////////////////
52   CCFGParser();
53
54   ////////////////////////////////////////////////////////////////////////////////////////////////
55   /// CCFGParser
56   /// Constructor of CCFGReader class
57   ///
58   /// \param  [IN] f_c_filepath
59   ///     std::string - Full path of the configuration file
60   ///
61   /// \return
62   ///
63   ////////////////////////////////////////////////////////////////////////////////////////////////
64   explicit CCFGParser(const std::string &f_c_filepath);
65
66   ////////////////////////////////////////////////////////////////////////////////////////////////
67   /// ~CCFGParser
68   /// Destructor of CCFGReader class
69   ///
70   /// \param
71   ///
72   /// \return
73   ///
74   ////////////////////////////////////////////////////////////////////////////////////////////////
75   ~CCFGParser();
76
77   ////////////////////////////////////////////////////////////////////////////////////////////////
78   /// CFGParseFile
79   /// This function is used to parse the configuration file and store data in internal structure
80   ///
81   /// \param  [IN] f_c_filepath
82   ///     std::string - full path of the configuration file
83   ///
84   /// \return EFrameworkunifiedStatus - success or failure
85   ///
86   ////////////////////////////////////////////////////////////////////////////////////////////////
87   EFrameworkunifiedStatus CFGParseFile(const std::string &f_c_filepath);
88
89   ////////////////////////////////////////////////////////////////////////////////////////////////
90   /// CFGGetData
91   /// This function is used to get the value associated with the key from internal CFG structure
92   ///
93   /// \param  [IN] f_c_key
94   ///     std::string - key to search
95   ///
96   /// \return std::string - value for key
97   ///
98   ////////////////////////////////////////////////////////////////////////////////////////////////
99   std::string CFGGetData(const std::string &f_c_key);
100
101   ////////////////////////////////////////////////////////////////////////////////////////////////
102   /// CFGGetData
103   /// This function is used to get the value associated with the key from internal CFG structure
104   ///
105   /// \param  [IN] f_c_key
106   ///     std::string - key to search
107   /// \param  [IN] f_c_value
108   ///     std::string - Value of key
109   ///
110   /// \return EFrameworkunifiedStatus
111   ///     EFrameworkunifiedStatus - error if key not founf or else eFrameworkunifiedStatusOK
112   ///
113   ////////////////////////////////////////////////////////////////////////////////////////////////
114   EFrameworkunifiedStatus CFGGetData(const std::string &f_c_key, std::string &f_c_value);  // NOLINT (readability/nolint)
115
116   ////////////////////////////////////////////////////////////////////////////////////////////////
117   /// CFGSetData
118   /// This function is used to set the value for the key in internal CFG structure
119   ///
120   /// \param  [IN] f_c_key
121   ///     std::string - key to search
122   /// \param  [IN] f_c_value
123   ///     std::string - value to set
124   ///
125   /// \return EFrameworkunifiedStatus - success or failure
126   ///
127   ////////////////////////////////////////////////////////////////////////////////////////////////
128   EFrameworkunifiedStatus CFGSetData(const std::string &f_c_key, std::string f_c_value);
129
130   ////////////////////////////////////////////////////////////////////////////////////////////////
131   /// CFGSaveData
132   /// This function is used to save the changed value to the cfg config file
133   ///
134   /// \param  [IN] f_c_filepath
135   ///     std::string - full path of the configuration file
136   ///
137   /// \return EFrameworkunifiedStatus - success or failure
138   ///
139   ////////////////////////////////////////////////////////////////////////////////////////////////
140   EFrameworkunifiedStatus CFGSaveData(const std::string &f_c_filepath);
141
142  private:
143   // internal data structure created by parsing the cfg file
144   CFGData_Type *m_pmCFGData;
145   std::string m_cLastComment;
146 };
147
148 #endif  // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_