Browse Source

undo changes testing rapidjson schema validation

master
cinnaboot 8 years ago
parent
commit
5aaacc6a0b
  1. 3
      .gitmodules
  2. 2
      Makefile
  3. 3
      data/hashmap_scene.json
  4. 1
      data/scene_schema.json
  5. 1
      ext/rapidjson
  6. 8
      src/scene_loader.cpp

3
.gitmodules vendored

@ -7,6 +7,3 @@
[submodule "ext/stb_libs"]
path = ext/stb_libs
url = https://github.com/nothings/stb.git
[submodule "ext/rapidjson"]
path = ext/rapidjson
url = https://github.com/Tencent/rapidjson.git

2
Makefile

@ -1,7 +1,7 @@
CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I/usr/include/SDL2 -Iext/aixlog/include -Iext/stb_libs -Iext/rapidjson/include
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I/usr/include/SDL2 -Iext/aixlog/include -Iext/stb_libs
SRC_DIR = src
OBJ_DIR = build

3
data/hashmap_scene.json

@ -38,8 +38,7 @@
"model_file" : "block2.dae",
"position" : {"x":140,"y":-100,"z":0},
"rotation" : {"x":0,"y":0,"z":0,"w":0},
"scale" : {"x":10,"y":10,"z":10},
"potato": 2
"scale" : {"x":10,"y":10,"z":10}
},
{
"name" : "ground",

1
data/scene_schema.json

@ -82,7 +82,6 @@
"scale": { "$ref": "#/definitions/vector3" },
"grid_pos": { "$ref": "#/definitions/vector3" }
},
"additionalItems": false,
"required" : ["name", "model_file", "position", "rotation", "scale", "grid_pos"]
},

1
ext/rapidjson

@ -1 +0,0 @@
Subproject commit bfdcf4911047688fec49014d575433e2e5eb05be

8
src/scene_loader.cpp

@ -2,7 +2,6 @@
#include <string>
#include <glm/glm.hpp>
#include <rapidjson/cursorstreamwrapper.h>
#include <rapidjson/document.h>
#include <rapidjson/schema.h>
#include <rapidjson/stringbuffer.h>
@ -325,14 +324,11 @@ loadTextFile(char*& output, const char* data_dir, const char* file_name)
bool
parseFile(rapidjson::Document* doc, const char* file_contents, const char* file_name)
{
rapidjson::StringStream ss(file_contents);
rapidjson::CursorStreamWrapper<rapidjson::StringStream> csw(ss);
rapidjson::ParseResult pr = doc->ParseStream(csw);
rapidjson::ParseResult pr = doc->Parse(file_contents);
if (!pr || !doc->IsObject()) {
LOG(ERROR) << "Error parrsing json file: " << file_name;
LOG(ERROR) << " at line " << csw.GetLine() << ", col " << csw.GetColumn() << "\n";
LOG(ERROR) << "Error desscription: " << rapidjson::GetParseError_En(pr.Code())
LOG(ERROR) << ". Error desscription: " << rapidjson::GetParseError_En(pr.Code())
<< " (" << pr.Offset() << ")\n";
return false;
}

Loading…
Cancel
Save