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 implementation of CNSConfigParser class.
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
25 ////////////////////////////////////////////////////////////////////////////////////////////////////
26 #include <native_service/ns_config_parser_if.h>
28 #include "ns_config_parser_frameworkunifiedlog.h"
30 CNSConfigParser::CNSConfigParser() : CNSConfigReader(), CNSConfigWriter() { // LCOV_EXCL_BR_LINE 11:except branch
33 CNSConfigParser::CNSConfigParser(const std::string &f_c_filepath): CNSConfigReader(f_c_filepath),
34 CNSConfigWriter(f_c_filepath, TRUE) { // LCOV_EXCL_BR_LINE 11:except branch
35 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
37 // get the data pointer from the config reader
38 PVOID l_pdata = GetDataPtr(); // LCOV_EXCL_BR_LINE 11:except branch
40 // set the same data pointer in config writer
41 SetDataPtr(l_pdata); // LCOV_EXCL_BR_LINE 11:except branch
44 CNSConfigParser::~CNSConfigParser() { // LCOV_EXCL_BR_LINE 11:except branch
45 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
47 // set the data pointer to NULL in writer
48 SetDataPtr(NULL); // LCOV_EXCL_BR_LINE 11:except branch
51 EFrameworkunifiedStatus CNSConfigParser::Parse(const std::string &f_c_filepath) {
52 EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
53 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
55 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
57 // parse and create config document structure with reader
58 if (eFrameworkunifiedStatusOK == (l_e_status = CNSConfigReader::Parse(f_c_filepath))) {
59 // set the data pointer to NULL in writer
62 // sets the same config document structure in writer
63 if (eFrameworkunifiedStatusOK == (l_e_status = CNSConfigWriter::Create(f_c_filepath))) {
64 // get the data pointer from the config reader
65 PVOID l_pdata = GetDataPtr();
67 // set the same data pointer in config writer
72 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");