1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
22 * @file IncludeResolver.h
\r
24 * @brief This file provides APIs for resolving included files.
\r
27 #ifndef INCLUDE_RESOLVER_H
\r
28 #define INCLUDE_RESOLVER_H
\r
31 #include <algorithm>
\r
32 #if defined (__TIZENRT__)
\r
33 #include <apps/netutils/cJSON.h>
\r
37 #include "yaml-cpp/yaml.h"
\r
38 #include "yaml-cpp/exceptions.h"
\r
39 #include "RamlUtils.h"
\r
40 #include "RamlExceptions.h"
\r
45 * @class IncludeResolver
\r
46 * @brief This class provides a set of APIs for resolving included files.
\r
48 class IncludeResolver
\r
51 /** FileType - enumeration for Included File types*/
\r
54 NODE, JSON, FILE, NOTAG , ERROR
\r
59 * This method is for reading a file specified in YamlNode and parse it to
\r
60 * getting the created RootNode from RAML file.
\r
62 * @param yamlFile - Reference to YamlNode specifying the FileName.
\r
64 * @return pointer to root node from the Parsed file.
\r
66 YAML::Node readToYamlNode(const YAML::Node &yamlFile );
\r
69 * This method is for reading a file specified in YamlNode and parse the specified Json file.
\r
71 * @param jsonFile - Reference to YamlNode specifying the FileName.
\r
73 * @return cJSON pointer to CJson object.
\r
75 cJSON *readToJson(const YAML::Node &jsonFile );
\r
78 * This method is for reading a file specified in YamlNode and parse the content of file.
\r
80 * @param file - Reference to YamlNode specifying the FileName.
\r
82 * @return contents of the file.
\r
84 std::string readFromFile(const YAML::Node &file );
\r
87 * This method is checking the file type specified in YamlNode.
\r
89 * @param yamlNode - Reference to YamlNode specifying the FileName.
\r
91 * @return FileType type of file.
\r
93 FileType getFileType(const YAML::Node &yamlNode );
\r
96 * This method is for reading a file specified and parse the content of file.
\r
98 * @param jsonFileName - FileName of Json file to be read.
\r
100 * @return pointer to CJson object.
\r
102 cJSON *readToJson(const std::string &jsonFileName);
\r
105 * Constructor of IncludeResolver.
\r
107 IncludeResolver() {}
\r
110 * Constructor of IncludeResolver.
\r
112 * @param path - configuration file path.
\r
115 IncludeResolver(const std::string &path) : m_path(path) {}
\r
118 std::string m_path;
\r
121 /** IncludeResolverPtr - shared Ptr to IncludeResolver.*/
\r
122 typedef std::shared_ptr<IncludeResolver> IncludeResolverPtr;
\r