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.
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
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
25 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
26 #define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////////////////////////////////////////////
31 #include <native_service/frameworkunified_types.h>
35 // forward declaration of classes
39 typedef std::map<std::string, CBlock *> CFGData_Type;
43 ////////////////////////////////////////////////////////////////////////////////////////////////
45 /// Constructor of CCFGReader class
51 ////////////////////////////////////////////////////////////////////////////////////////////////
54 ////////////////////////////////////////////////////////////////////////////////////////////////
56 /// Constructor of CCFGReader class
58 /// \param [IN] f_c_filepath
59 /// std::string - Full path of the configuration file
63 ////////////////////////////////////////////////////////////////////////////////////////////////
64 explicit CCFGParser(const std::string &f_c_filepath);
66 ////////////////////////////////////////////////////////////////////////////////////////////////
68 /// Destructor of CCFGReader class
74 ////////////////////////////////////////////////////////////////////////////////////////////////
77 ////////////////////////////////////////////////////////////////////////////////////////////////
79 /// This function is used to parse the configuration file and store data in internal structure
81 /// \param [IN] f_c_filepath
82 /// std::string - full path of the configuration file
84 /// \return EFrameworkunifiedStatus - success or failure
86 ////////////////////////////////////////////////////////////////////////////////////////////////
87 EFrameworkunifiedStatus CFGParseFile(const std::string &f_c_filepath);
89 ////////////////////////////////////////////////////////////////////////////////////////////////
91 /// This function is used to get the value associated with the key from internal CFG structure
93 /// \param [IN] f_c_key
94 /// std::string - key to search
96 /// \return std::string - value for key
98 ////////////////////////////////////////////////////////////////////////////////////////////////
99 std::string CFGGetData(const std::string &f_c_key);
101 ////////////////////////////////////////////////////////////////////////////////////////////////
103 /// This function is used to get the value associated with the key from internal CFG structure
105 /// \param [IN] f_c_key
106 /// std::string - key to search
107 /// \param [IN] f_c_value
108 /// std::string - Value of key
110 /// \return EFrameworkunifiedStatus
111 /// EFrameworkunifiedStatus - error if key not founf or else eFrameworkunifiedStatusOK
113 ////////////////////////////////////////////////////////////////////////////////////////////////
114 EFrameworkunifiedStatus CFGGetData(const std::string &f_c_key, std::string &f_c_value); // NOLINT (readability/nolint)
116 ////////////////////////////////////////////////////////////////////////////////////////////////
118 /// This function is used to set the value for the key in internal CFG structure
120 /// \param [IN] f_c_key
121 /// std::string - key to search
122 /// \param [IN] f_c_value
123 /// std::string - value to set
125 /// \return EFrameworkunifiedStatus - success or failure
127 ////////////////////////////////////////////////////////////////////////////////////////////////
128 EFrameworkunifiedStatus CFGSetData(const std::string &f_c_key, std::string f_c_value);
130 ////////////////////////////////////////////////////////////////////////////////////////////////
132 /// This function is used to save the changed value to the cfg config file
134 /// \param [IN] f_c_filepath
135 /// std::string - full path of the configuration file
137 /// \return EFrameworkunifiedStatus - success or failure
139 ////////////////////////////////////////////////////////////////////////////////////////////////
140 EFrameworkunifiedStatus CFGSaveData(const std::string &f_c_filepath);
143 // internal data structure created by parsing the cfg file
144 CFGData_Type *m_pmCFGData;
145 std::string m_cLastComment;
148 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_