Re-organized sub-directory by category
[staging/basesystem.git] / service / native / framework_unified / client / NS_ConfigParser / include / ns_cfg_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 /// \ingroup  tag_NS_ConfigParser
19 /// \brief    This file contains declaration of class CCFGWriter.
20 ///
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
24 #define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
25
26 ////////////////////////////////////////////////////////////////////////////////////////////////////
27 // Include Files
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 #include <native_service/ns_writer.h>
30 #include <string>
31
32 class CCFGParser;
33
34 /*
35  * This class provides functionalities to write to CFG config file
36  */
37 class CCFGWriter: public IConfigWriter {
38  public:
39   ////////////////////////////////////////////////////////////////////////////////////////////////
40   /// CCFGWriter
41   /// Constructor of CCFGWriter class
42   ///
43   /// \param
44   ///
45   /// \return
46   ///
47   ////////////////////////////////////////////////////////////////////////////////////////////////
48   CCFGWriter();
49
50   ////////////////////////////////////////////////////////////////////////////////////////////////
51   /// CCFGWriter
52   /// Constructor of CCFGWriter class
53   ///
54   /// \param  [IN] f_c_filepath
55   ///     std::string - Full path of the configuration file
56   ///
57   /// \return
58   ///
59   ////////////////////////////////////////////////////////////////////////////////////////////////
60   explicit CCFGWriter(const std::string &f_c_filepath);
61
62   ////////////////////////////////////////////////////////////////////////////////////////////////
63   /// ~CCFGWriter
64   /// Destructor of CCFGWriter class
65   ///
66   /// \param
67   ///
68   /// \return
69   ///
70   ////////////////////////////////////////////////////////////////////////////////////////////////
71   ~CCFGWriter();
72
73   ////////////////////////////////////////////////////////////////////////////////////////////////
74   /// ParseFile
75   /// This function is used to parse the file
76   ///
77   /// \param  [IN] f_c_filepath
78   ///     std::string - path of file to parse
79   ///
80   /// \return EFrameworkunifiedStatus - success or failure
81   ///
82   ////////////////////////////////////////////////////////////////////////////////////////////////
83   EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath);
84
85   ////////////////////////////////////////////////////////////////////////////////////////////////
86   /// SetValue
87   /// This function is used to set the value for the key
88   ///
89   /// \param  [IN] f_c_key
90   ///     std::string - key to search
91   /// \param  [IN] f_c_value
92   ///     std::string - value to set
93   ///
94   /// \return EFrameworkunifiedStatus
95   ///     EFrameworkunifiedStatus - error if key not found else eFrameworkunifiedStatusOK
96   ///
97   ////////////////////////////////////////////////////////////////////////////////////////////////
98   EFrameworkunifiedStatus SetValue(const std::string &f_c_key, std::string f_c_value);
99
100   ////////////////////////////////////////////////////////////////////////////////////////////////
101   /// SaveData
102   /// This function is used to save the changed value to the cfg config file
103   ///
104   /// \param
105   ///
106   /// \return EFrameworkunifiedStatus - success or failure
107   ///
108   ////////////////////////////////////////////////////////////////////////////////////////////////
109   EFrameworkunifiedStatus SaveData();
110
111   ////////////////////////////////////////////////////////////////////////////////////////////////
112   /// SetDataPtr
113   /// This function is used to set the config file path
114   ///
115   /// \param  [IN] f_c_path
116   ///     std::string - Path of file
117   ///
118   /// \return EFrameworkunifiedStatus - success or failure
119   ///
120   ////////////////////////////////////////////////////////////////////////////////////////////////
121   EFrameworkunifiedStatus SetPath(const std::string &f_c_path);
122
123   ////////////////////////////////////////////////////////////////////////////////////////////////
124   /// SetDataPtr
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
129   ///
130   /// \param  [IN] f_p_data
131   ///     PVOID - Pointer to data structure
132   ///
133   /// \return VOID
134   ///
135   ////////////////////////////////////////////////////////////////////////////////////////////////
136   VOID SetDataPtr(PVOID f_p_data);
137
138  private:
139   // path of config file
140   std::string m_cFilePath;
141
142   // CFG file parser object
143   CCFGParser *m_pCFGParser;
144 };
145
146 #endif  // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_