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
24 * @brief This file provides data Model for RAML Schema.
\r
32 #include "IncludeResolver.h"
\r
34 #include "JsonSchema.h"
\r
40 * @brief This class provides data Model for RAML Schema.
\r
46 * This method is for getting CJson object of schema.
\r
48 * @return pointer to cJSON.
\r
50 virtual cJSON *getJson() const;
\r
53 * This method is for setting schema as CJson object.
\r
55 * @param cjson - Cjson pointer.
\r
57 virtual void setJson(cJSON *cjson);
\r
60 * This method is for getting schema as string.
\r
64 virtual std::string getSchema() const;
\r
67 * This method is for setting schema as string.
\r
69 * @param schema - schema string.
\r
71 virtual void setSchema(const std::string &schema);
\r
74 * This method is for getting Properties from JsonSchema.
\r
76 * @return pointer to JsonSchema.
\r
78 virtual JsonSchemaPtr const &getProperties() const;
\r
81 * Constructor of Schema.
\r
83 * @param schema - contents of schema to be parsed
\r
84 * @param includeResolver - Reference to IncludeResolver for reading external files
\r
87 Schema(const std::string &schema, const IncludeResolverPtr &includeResolver):
\r
88 m_schema(schema) , m_cjson(cJSON_Parse(schema.c_str())),
\r
89 m_resProperties(std::make_shared<JsonSchema>(m_cjson, includeResolver) ) ,
\r
90 m_includeResolver(includeResolver) {}
\r
93 * Constructor of Schema.
\r
95 Schema(): m_cjson(NULL), m_resProperties(std::make_shared<JsonSchema>()),
\r
96 m_includeResolver(NULL) {}
\r
99 * Destructor of Schema.
\r
101 ~Schema() { cJSON_Delete(m_cjson); }
\r
104 std::string m_schema;
\r
106 JsonSchemaPtr m_resProperties;
\r
107 IncludeResolverPtr m_includeResolver;
\r
110 /** SchemaPtr - shared Ptr to Schema.*/
\r
111 typedef std::shared_ptr<Schema> SchemaPtr;
\r