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 declaration of class CCFGWriter.
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
24 #define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
26 ////////////////////////////////////////////////////////////////////////////////////////////////////
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 #include <native_service/ns_writer.h>
35 * This class provides functionalities to write to CFG config file
37 class CCFGWriter: public IConfigWriter {
39 ////////////////////////////////////////////////////////////////////////////////////////////////
41 /// Constructor of CCFGWriter class
47 ////////////////////////////////////////////////////////////////////////////////////////////////
50 ////////////////////////////////////////////////////////////////////////////////////////////////
52 /// Constructor of CCFGWriter class
54 /// \param [IN] f_c_filepath
55 /// std::string - Full path of the configuration file
59 ////////////////////////////////////////////////////////////////////////////////////////////////
60 explicit CCFGWriter(const std::string &f_c_filepath);
62 ////////////////////////////////////////////////////////////////////////////////////////////////
64 /// Destructor of CCFGWriter class
70 ////////////////////////////////////////////////////////////////////////////////////////////////
73 ////////////////////////////////////////////////////////////////////////////////////////////////
75 /// This function is used to parse the file
77 /// \param [IN] f_c_filepath
78 /// std::string - path of file to parse
80 /// \return EFrameworkunifiedStatus - success or failure
82 ////////////////////////////////////////////////////////////////////////////////////////////////
83 EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath);
85 ////////////////////////////////////////////////////////////////////////////////////////////////
87 /// This function is used to set the value for the key
89 /// \param [IN] f_c_key
90 /// std::string - key to search
91 /// \param [IN] f_c_value
92 /// std::string - value to set
94 /// \return EFrameworkunifiedStatus
95 /// EFrameworkunifiedStatus - error if key not found else eFrameworkunifiedStatusOK
97 ////////////////////////////////////////////////////////////////////////////////////////////////
98 EFrameworkunifiedStatus SetValue(const std::string &f_c_key, std::string f_c_value);
100 ////////////////////////////////////////////////////////////////////////////////////////////////
102 /// This function is used to save the changed value to the cfg config file
106 /// \return EFrameworkunifiedStatus - success or failure
108 ////////////////////////////////////////////////////////////////////////////////////////////////
109 EFrameworkunifiedStatus SaveData();
111 ////////////////////////////////////////////////////////////////////////////////////////////////
113 /// This function is used to set the config file path
115 /// \param [IN] f_c_path
116 /// std::string - Path of file
118 /// \return EFrameworkunifiedStatus - success or failure
120 ////////////////////////////////////////////////////////////////////////////////////////////////
121 EFrameworkunifiedStatus SetPath(const std::string &f_c_path);
123 ////////////////////////////////////////////////////////////////////////////////////////////////
125 /// This function is used to set the data pointer in writer class with data pointer
126 /// created in config reader class.
127 /// This is needed to avoid recreation of same data structure object in both reader and writer
128 /// when we create object of NSConfigParser
130 /// \param [IN] f_p_data
131 /// PVOID - Pointer to data structure
135 ////////////////////////////////////////////////////////////////////////////////////////////////
136 VOID SetDataPtr(PVOID f_p_data);
139 // path of config file
140 std::string m_cFilePath;
142 // CFG file parser object
143 CCFGParser *m_pCFGParser;
146 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_