Changes for JsonSchema and Raml Parser.
[platform/upstream/iotivity.git] / service / simulator / ramlparser / raml / jsonSchemaParser / JsonSchema.cpp
index 9425b0b..67968e2 100755 (executable)
@@ -176,11 +176,6 @@ namespace RAML
     {\r
         PropertiesPtr property = std::make_shared<Properties>(attName);\r
 \r
-        cJSON *propertyUpdateFrequency = cJSON_GetObjectItem(childProperties, "update_frequency");\r
-        if (propertyUpdateFrequency)\r
-        {\r
-            property->setUpdateFrequencyTime(propertyUpdateFrequency->valueint);\r
-        }\r
         cJSON *propertyDescription = cJSON_GetObjectItem(childProperties, "description");\r
         if (propertyDescription)\r
         {\r
@@ -295,7 +290,7 @@ namespace RAML
         }\r
         else if (attType == "integer")\r
         {\r
-            readNumber(childProperties, property);\r
+            readInteger(childProperties, property);\r
         }\r
         else if (attType == "array")\r
         {\r
@@ -303,7 +298,7 @@ namespace RAML
         }\r
         else if (attType == "number")\r
         {\r
-            readNumber(childProperties, property);\r
+            readDouble(childProperties, property);\r
         }\r
     }\r
 \r
@@ -418,7 +413,7 @@ namespace RAML
         }\r
     }\r
 \r
-    void JsonSchema::readNumber(cJSON *childProperties,  PropertiesPtr property)\r
+    void JsonSchema::readInteger(cJSON *childProperties,  PropertiesPtr property)\r
     {\r
         cJSON *Max = cJSON_GetObjectItem(childProperties, "maximum");\r
         if (Max)\r
@@ -455,6 +450,45 @@ namespace RAML
         }\r
 \r
     }\r
+\r
+    void JsonSchema::readDouble(cJSON *childProperties,  PropertiesPtr property)\r
+    {\r
+        cJSON *Max = cJSON_GetObjectItem(childProperties, "maximum");\r
+        if (Max)\r
+        {\r
+            cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");\r
+            if (exclusiveMax)\r
+            {\r
+                if (exclusiveMax->type == cJSON_True)\r
+                    property->setMaxDouble( --(Max->valuedouble));\r
+                else\r
+                    property->setMaxDouble(Max->valuedouble);\r
+            }\r
+            else\r
+                property->setMaxDouble(Max->valuedouble);\r
+        }\r
+        cJSON *Min = cJSON_GetObjectItem(childProperties, "minimum");\r
+        if (Min)\r
+        {\r
+            cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum");\r
+            if (exclusiveMin)\r
+            {\r
+                if (exclusiveMin->type == cJSON_True)\r
+                    property->setMinDouble( ++(Min->valuedouble));\r
+                else\r
+                    property->setMinDouble(Min->valuedouble);\r
+            }\r
+            else\r
+                property->setMinDouble(Min->valuedouble);\r
+        }\r
+        cJSON *multipleOf = cJSON_GetObjectItem(childProperties, "multipleOf");\r
+        if (multipleOf)\r
+        {\r
+            property->setMultipleOf(multipleOf->valueint);\r
+        }\r
+\r
+    }\r
+\r
     DefinitionsPtr JsonSchema::readRef(std::string m_ref)\r
     {\r
         std::string delimiter1 = "#";\r