本文整理汇总了C++中JsonObject::add方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::add方法的具体用法?C++ JsonObject::add怎么用?C++ JsonObject::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitEnumStatement
void visitEnumStatement(EnumStatement *node) override {
if (!node->name()) {
for (size_t i = 0; i < node->entries()->length(); i++) {
EnumConstant *cs = node->entries()->at(i);
JsonObject *val = new (pool_) JsonObject();
val->add(atom_name_, toJson(cs->name()));
startDoc(val, "enum value", cs->name(), cs->loc());
constants_->add(val);
}
return;
}
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(node->name()));
startDoc(obj, "enum", node->name(), node->loc());
JsonList *list = new (pool_) JsonList();
for (size_t i = 0; i < node->entries()->length(); i++) {
EnumConstant *cs = node->entries()->at(i);
JsonObject *val = new (pool_) JsonObject();
val->add(atom_name_, toJson(cs->name()));
startDoc(val, "enum value", cs->name(), cs->loc());
list->add(val);
}
obj->add(atom_entries_, list);
enums_->add(obj);
}
示例2: visitTypedefDecl
void visitTypedefDecl(TypedefDecl *decl) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(decl->name()));
startDoc(obj, "typedef", decl->name(), decl->loc());
obj->add(atom_type_, toJson(decl->te()));
typedefs_->add(obj);
}
示例3: visitPropertyDecl
void visitPropertyDecl(PropertyDecl *node) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(node->name()));
startDoc(obj, "property", node->name(), node->loc());
obj->add(atom_type_, toJson(node->te()));
obj->add(atom_getter_, new (pool_) JsonBool(!!node->getter()));
obj->add(atom_setter_, new (pool_) JsonBool(!!node->setter()));
props_->add(obj);
}
示例4: visitMethodDecl
void visitMethodDecl(MethodDecl *node) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(node->name()));
startDoc(obj, "method", node->name(), node->loc());
FunctionNode *fun = node->method();
obj->add(atom_returnType_, toJson(fun->signature()->returnType()));
obj->add(atom_parameters_, toJson(fun->signature()->parameters()));
methods_->add(obj);
}
示例5: visitMethodmapDecl
void visitMethodmapDecl(MethodmapDecl *node) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(node->name()));
startDoc(obj, "class", node->name(), node->loc());
SaveAndSet<JsonList *> new_props(&props_, new (pool_) JsonList());
SaveAndSet<JsonList *> new_methods(&methods_, new (pool_) JsonList());
for (size_t i = 0; i < node->body()->length(); i++)
node->body()->at(i)->accept(this);
obj->add(atom_methods_, methods_);
obj->add(atom_properties_, props_);
methodmaps_->add(obj);
}
示例6: visitFunctionStatement
void visitFunctionStatement(FunctionStatement *node) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(node->name()));
startDoc(obj, "function", node->name(), node->loc());
if (node->token() == TOK_FORWARD)
obj->add(atom_kind_, toJson("forward"));
else if (node->token() == TOK_NATIVE)
obj->add(atom_kind_, toJson("native"));
else
obj->add(atom_kind_, toJson("stock"));
obj->add(atom_returnType_, toJson(node->signature()->returnType()));
obj->add(atom_parameters_, toJson(node->signature()->parameters()));
functions_->add(obj);
}
示例7: results
void SWorker::results(int total_ms) {
JsonObject r;
r.add("elapsed", total_ms);
// results are really out there...
r.add("file", "results.dat");
stringstream ss;
r.write(true, &ss);
StringMsg msg(0, 0, ss.str());
zmq::message_t message(2);
msg.set(&message);
result->send(message);
}
示例8: visitTypesetDecl
void visitTypesetDecl(TypesetDecl *decl) override {
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_name_, toJson(decl->name()));
startDoc(obj, "typeset", decl->name(), decl->loc());
JsonList *list = new (pool_) JsonList();
for (size_t i = 0; i < decl->types()->length(); i++) {
const TypesetDecl::Entry &entry = decl->types()->at(i);
JsonObject *te = new (pool_) JsonObject();
te->add(atom_type_, toJson(entry.te));
unsigned start, end;
if (comments_.findCommentFor(entry.loc, &start, &end)) {
te->add(atom_doc_start_, new (pool_) JsonInt(start));
te->add(atom_doc_end_, new (pool_) JsonInt(end));
}
list->add(te);
}
obj->add(cc_.add("types"), list);
typesets_->add(obj);
}
示例9: new
JsonList *toJson(const ParameterList *params) {
JsonList *list = new (pool_) JsonList();
for (size_t i = 0; i < params->length(); i++) {
VarDecl *decl = params->at(i);
JsonObject *obj = new (pool_) JsonObject();
obj->add(atom_type_, toJson(decl, false));
if (decl->name()) {
obj->add(atom_name_, toJson(decl->name()));
obj->add(atom_decl_, toJson(decl, true));
} else {
obj->add(atom_name_, toJson("..."));
AutoString builder = BuildTypeName(decl->te(), nullptr, TypeDiagFlags::Names);
builder = builder + " ...";
obj->add(atom_decl_, toJson(builder.ptr()));
}
list->add(obj);
}
return list;
}
示例10: createObject
JsonObject createObject() {
// {"x":{"a":{"b":1}},"y":{"d":{"e":2},"g":{"h":3,"o":{"p":9}},"z":[{"i"5},{"j":6},{"l":{"m":7,"n":8}}]}
JsonObject o;
{
JsonObject x;
{
JsonObject a;
a.add("b", 1);
x.add("a", a);
}
o.add("x", x);
}
{
JsonObject y;
{
JsonObject d;
d.add("e", 2);
y.add("d", d);
}
{
JsonObject g;
g.add("h", 3);
JsonObject oo;
oo.add("p", 9);
g.add("o", oo);
y.add("g", g);
}
o.add("y", y);
}
{
JsonArray z;
{
JsonObject i;
i.add("i", 5);
z.add(i);
}
{
JsonObject j;
j.add("j", 6);
z.add(j);
}
{
JsonObject l;
JsonObject s;
s.add("m", 7);
s.add("n", 8);
l.add("l", s);
z.add(l);
}
o.add("z", z);
}
return o;
}