Skip to content

Commit

Permalink
update submodule 'rapidjson'
Browse files Browse the repository at this point in the history
  • Loading branch information
plenluno committed Jan 4, 2015
1 parent 058f049 commit 4142eed
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion deps/rapidjson
52 changes: 33 additions & 19 deletions src/glue/json.cpp
@@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 Plenluno All rights reserved.
// Copyright (c) 2012-2015 Plenluno All rights reserved.

#include <libj/error.h>
#include <libj/js_array.h>
Expand Down Expand Up @@ -117,67 +117,81 @@ class JsonHandler {
}
}

void Null() {
bool Null() {
add(Object::null());
return true;
}

void Bool(bool b) {
bool Bool(bool b) {
add(b);
return true;
}

void Int(int i) {
bool Int(int i) {
add(static_cast<Long>(i));
return true;
}

void Uint(unsigned ui) {
bool Uint(unsigned ui) {
add(static_cast<Long>(ui));
return true;
}

void Int64(int64_t l) {
bool Int64(int64_t l) {
add(longToValue(l));
return true;
}

void Uint64(uint64_t ul) {
bool Uint64(uint64_t ul) {
add(ulongToValue(ul));
return true;
}

void Double(double d) {
bool Double(double d) {
add(doubleToValue(d));
return true;
}

void String(const Char* s, rapidjson::SizeType len, bool copy) {
String::CPtr str = createString(s, len);
if (object_ && !name_) {
name_ = str;
} else {
add(str);
}
bool String(const Char* str, rapidjson::SizeType len, bool copy) {
assert(!object_ || name_);
add(createString(str, len));
return true;
}

void StartObject() {
bool StartObject() {
JsObject::Ptr obj = JsObject::create();
add(obj);
push();
object_ = obj;
return true;
}

bool Key(const Char* str, rapidjson::SizeType len, bool copy) {
assert(object_ && !name_);
name_ = createString(str, len);
return true;
}

void EndObject(rapidjson::SizeType size) {
bool EndObject(rapidjson::SizeType size) {
assert(object_->size() == size);
object_ = JsObject::null();
pop();
return true;
}

void StartArray() {
bool StartArray() {
JsArray::Ptr ary = JsArray::create();
add(ary);
push();
array_ = ary;
return true;
}

void EndArray(rapidjson::SizeType len) {
bool EndArray(rapidjson::SizeType len) {
assert(array_->length() == len);
array_ = JsArray::null();
pop();
return true;
}

private:
Expand Down

0 comments on commit 4142eed

Please sign in to comment.