replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / simulator / ramlparser / raml / jsonSchemaParser / JsonSchema.cpp
index 826e67d..bbd1aaf 100755 (executable)
@@ -90,9 +90,9 @@ namespace RAML
 \r
         cJSON *jsonAdditionalProperties = cJSON_GetObjectItem(m_cjson, "additionalProperties");\r
         if (jsonAdditionalProperties)\r
-            m_additionalProperties = jsonAdditionalProperties->type;\r
+            m_additionalProperties = (jsonAdditionalProperties->type == cJSON_True);\r
         else\r
-            m_additionalProperties = cJSON_True;\r
+            m_additionalProperties = true;\r
 \r
         cJSON *jsonReference = cJSON_GetObjectItem(m_cjson, "$ref");\r
         if (jsonReference)\r
@@ -230,11 +230,11 @@ namespace RAML
         std::string attType;\r
         if (propertyType)\r
         {\r
-            if (propertyType->type == 4)\r
+            if (propertyType->type == cJSON_String)\r
             {\r
                 attType = propertyType->valuestring;\r
             }\r
-            else if (propertyType->type == 5)\r
+            else if (propertyType->type == cJSON_Array)\r
             {\r
                 attType = cJSON_GetArrayItem(propertyType, 0)->valuestring;\r
             }\r
@@ -260,22 +260,22 @@ namespace RAML
     void JsonSchema::readDefaultValue(cJSON *defaultValue,  PropertiesPtr &property,\r
                                       const std::string &attType)\r
     {\r
-        if (defaultValue->type == 4)\r
+        if (defaultValue->type == cJSON_String)\r
         {\r
             property->setValue((std::string)defaultValue->valuestring);\r
         }\r
-        else if (defaultValue->type == 3)\r
+        else if (defaultValue->type == cJSON_Number)\r
         {\r
             if (attType == "number")\r
                 property->setValue((double)defaultValue->valuedouble);\r
             else\r
                 property->setValue((int)defaultValue->valueint );\r
         }\r
-        else if (defaultValue->type == 1)\r
+        else if (defaultValue->type == cJSON_True)\r
         {\r
             property->setValue((bool)true);\r
         }\r
-        else if (defaultValue->type == 0)\r
+        else if (defaultValue->type == cJSON_False)\r
         {\r
             property->setValue((bool)false);\r
         }\r
@@ -284,7 +284,7 @@ namespace RAML
     void JsonSchema::readAllowedValues(cJSON *allowedvalues,  PropertiesPtr &property,\r
                                        std::string &attType)\r
     {\r
-        if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 4)\r
+        if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == cJSON_String)\r
         {\r
             int size = cJSON_GetArraySize(allowedvalues);\r
             int idx = 0;\r
@@ -298,7 +298,7 @@ namespace RAML
             if (attType.empty())\r
                 attType = "string";\r
         }\r
-        else if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 3)\r
+        else if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == cJSON_Number)\r
         {\r
             int size = cJSON_GetArraySize(allowedvalues);\r
             int idx = 0;\r
@@ -325,15 +325,15 @@ namespace RAML
                     attType = "integer";\r
             }\r
         }\r
-        else if (((cJSON_GetArrayItem(allowedvalues, 0)->type) == 1)\r
-                 || ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 0))\r
+        else if (((cJSON_GetArrayItem(allowedvalues, 0)->type) == cJSON_True)\r
+                 || ((cJSON_GetArrayItem(allowedvalues, 0)->type) == cJSON_False))\r
         {\r
             int size = cJSON_GetArraySize(allowedvalues);\r
             int idx = 0;\r
             std::vector<bool> allwdValues;\r
             do\r
             {\r
-                if (cJSON_GetArrayItem(allowedvalues, idx)->type)\r
+                if (cJSON_GetArrayItem(allowedvalues, idx)->type != cJSON_False)\r
                     allwdValues.push_back(true);\r
                 else\r
                     allwdValues.push_back(false);\r
@@ -508,7 +508,7 @@ namespace RAML
         cJSON *itemValues = cJSON_GetObjectItem(childProperties, "items");\r
         if (itemValues)\r
         {\r
-            if (itemValues->type == 5)\r
+            if (itemValues->type == cJSON_Array)\r
             {\r
                 //int item_size = cJSON_GetArraySize(itemValues);\r
                 int item_index = 0;\r
@@ -527,7 +527,7 @@ namespace RAML
         }\r
         cJSON *itemsMax = cJSON_GetObjectItem(childProperties, "maxItems");\r
         int min = INT_MIN, max = INT_MAX;\r
-        bool unique = cJSON_False, addItems = cJSON_False;\r
+        bool unique = false, addItems = false;\r
         if (itemsMax)\r
         {\r
             cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");\r
@@ -558,12 +558,12 @@ namespace RAML
         cJSON *uniqueItems = cJSON_GetObjectItem(childProperties, "uniqueItems");\r
         if (uniqueItems)\r
         {\r
-            unique = uniqueItems->type;\r
+            unique = (uniqueItems->type == cJSON_True);\r
         }\r
         cJSON *additionalItems = cJSON_GetObjectItem(childProperties, "additionalItems");\r
         if (additionalItems)\r
         {\r
-            addItems = additionalItems->type;\r
+            addItems = (additionalItems->type == cJSON_True);\r
         }\r
         property->setValueProperty(std::make_shared<ValueProperty>\r
                                    (ValueProperty::Type::ARRAY, min, max, unique, addItems));\r