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
31 #if defined (__TIZENRT__)
\r
32 #include <apps/netutils/cJSON.h>
\r
36 #include "IncludeResolver.h"
\r
38 #include "JsonSchema.h"
\r
44 * @brief This class provides data Model for RAML Schema.
\r
50 * This method is for getting CJson object of schema.
\r
52 * @return pointer to cJSON.
\r
54 virtual cJSON *getJson() const;
\r
57 * This method is for setting schema as CJson object.
\r
59 * @param cjson - Cjson pointer.
\r
61 virtual void setJson(cJSON *cjson);
\r
64 * This method is for getting schema as string.
\r
68 virtual std::string getSchema() const;
\r
71 * This method is for setting schema as string.
\r
73 * @param schema - schema string.
\r
75 virtual void setSchema(const std::string &schema);
\r
78 * This method is for getting Properties from JsonSchema.
\r
80 * @return pointer to JsonSchema.
\r
82 virtual JsonSchemaPtr const &getProperties() const;
\r
85 * Constructor of Schema.
\r
87 * @param schema - contents of schema to be parsed
\r
88 * @param includeResolver - Reference to IncludeResolver for reading external files
\r
91 Schema(const std::string &schema, const IncludeResolverPtr &includeResolver):
\r
92 m_schema(schema) , m_cjson(cJSON_Parse(schema.c_str())),
\r
93 m_resProperties(std::make_shared<JsonSchema>(m_cjson, includeResolver) ) ,
\r
94 m_includeResolver(includeResolver) {}
\r
97 * Constructor of Schema.
\r
99 Schema(): m_cjson(NULL), m_resProperties(std::make_shared<JsonSchema>()),
\r
100 m_includeResolver(NULL) {}
\r
102 Schema(const Schema&) = delete;
\r
103 Schema& operator=(const Schema&) = delete;
\r
104 Schema(Schema&&) = delete;
\r
105 Schema& operator=(Schema&&) = delete;
\r
108 * Destructor of Schema.
\r
110 ~Schema() { cJSON_Delete(m_cjson); }
\r
113 std::string m_schema;
\r
115 JsonSchemaPtr m_resProperties;
\r
116 IncludeResolverPtr m_includeResolver;
\r
119 /** SchemaPtr - shared Ptr to Schema.*/
\r
120 typedef std::shared_ptr<Schema> SchemaPtr;
\r