* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
*\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
*\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
*\r
******************************************************************/\r
\r
+/**\r
+ * @file Schema.h\r
+ *\r
+ * @brief This file provides data Model for RAML Schema.\r
+ */\r
+\r
#ifndef SCHEMAS_H\r
#define SCHEMAS_H\r
\r
#include <string>\r
+#if defined (__TIZENRT__)\r
+#include <apps/netutils/cJSON.h>\r
+#else\r
#include "cJSON.h"\r
+#endif\r
#include "IncludeResolver.h"\r
\r
-#include "ResourceProperties.h"\r
+#include "JsonSchema.h"\r
\r
namespace RAML\r
{\r
+ /**\r
+ * @class Schema\r
+ * @brief This class provides data Model for RAML Schema.\r
+ */\r
class Schema\r
{\r
public:\r
+ /**\r
+ * This method is for getting CJson object of schema.\r
+ *\r
+ * @return pointer to cJSON.\r
+ */\r
virtual cJSON *getJson() const;\r
+\r
+ /**\r
+ * This method is for setting schema as CJson object.\r
+ *\r
+ * @param cjson - Cjson pointer.\r
+ */\r
virtual void setJson(cJSON *cjson);\r
+\r
+ /**\r
+ * This method is for getting schema as string.\r
+ *\r
+ * @return string.\r
+ */\r
virtual std::string getSchema() const;\r
+\r
+ /**\r
+ * This method is for setting schema as string.\r
+ *\r
+ * @param schema - schema string.\r
+ */\r
virtual void setSchema(const std::string &schema);\r
- virtual ResourceProperties *getProperties() const;\r
\r
- Schema(cJSON *cjson): m_cjson(cjson) {}\r
- Schema(const std::string &schema): m_schema(schema) , m_cjson(cJSON_Parse(schema.c_str())),\r
- m_resProperties(new ResourceProperties(m_cjson) ) {}\r
- Schema() {}\r
+ /**\r
+ * This method is for getting Properties from JsonSchema.\r
+ *\r
+ * @return pointer to JsonSchema.\r
+ */\r
+ virtual JsonSchemaPtr const &getProperties() const;\r
+\r
+ /**\r
+ * Constructor of Schema.\r
+ *\r
+ * @param schema - contents of schema to be parsed\r
+ * @param includeResolver - Reference to IncludeResolver for reading external files\r
+ *\r
+ */\r
+ Schema(const std::string &schema, const IncludeResolverPtr &includeResolver):\r
+ m_schema(schema) , m_cjson(cJSON_Parse(schema.c_str())),\r
+ m_resProperties(std::make_shared<JsonSchema>(m_cjson, includeResolver) ) ,\r
+ m_includeResolver(includeResolver) {}\r
+\r
+ /**\r
+ * Constructor of Schema.\r
+ */\r
+ Schema(): m_cjson(NULL), m_resProperties(std::make_shared<JsonSchema>()),\r
+ m_includeResolver(NULL) {}\r
+\r
+ Schema(const Schema&) = delete;\r
+ Schema& operator=(const Schema&) = delete;\r
+ Schema(Schema&&) = delete;\r
+ Schema& operator=(Schema&&) = delete;\r
+\r
+ /**\r
+ * Destructor of Schema.\r
+ */\r
+ ~Schema() { cJSON_Delete(m_cjson); }\r
\r
private:\r
- cJSON *m_cjson;\r
std::string m_schema;\r
- ResourceProperties *m_resProperties;\r
+ cJSON *m_cjson;\r
+ JsonSchemaPtr m_resProperties;\r
+ IncludeResolverPtr m_includeResolver;\r
};\r
\r
+ /** SchemaPtr - shared Ptr to Schema.*/\r
+ typedef std::shared_ptr<Schema> SchemaPtr;\r
+\r
}\r
#endif\r