Пример #1
0
void json_parser::on_null()
{
  if (state_stack_.top().first) {
    state_stack_.top().second[key_] = json_value();
  } else {
    state_stack_.top().second.push_back(json_value());
  }
}
Пример #2
0
Room new_Room( ResourceManager rm, Window win, const char *bg, const char *map)
{
    Room ret = malloc(sizeof(*ret));
    ret->bg = malloc(sizeof(Sprite_s));
    ret->window = win;
    

    ret->bg->tex = ResourceManager_loadImage(rm, win, bg);
    ret->bg->rect.pos.x = ret->bg->rect.pos.y = 0;
    ret->bg->rect.w = 640;
    ret->bg->rect.h = 480;
    ret->offsetX = ret->offsetY = 0;
    ret->cameraFocus = NULL;
    ret->entities = new_List(0);

    if (map)
    {
	json_t *maproot, *entities;
	json_error_t jsonError;

	maproot = ResourceManager_loadMap(rm, map);
	ret->width = json_value(integer, maproot, "width");
	ret->width = json_value(integer, maproot, "height");

	entities = json_object_get(maproot, "entities");
	for(unsigned int i = 0; i < json_array_size(entities); i++)
	{
	    json_t *elm, *args;
	    char *type;
	    elm = json_array_get(entities, i);
	    assert(json_is_object(elm));
	    type = (char*)json_value(string, elm, "type");

	    Entity (*constructor)(json_t*);
	    if (constructor = FHash_get(constructors, type))
		constructor(elm);
	}
    }
    return ret;
}
Пример #3
0
json_array::json_array(size_t size)
    : json_type("json_array")
    , value_vector_(size, json_value())
{}
Пример #4
0
void some_value() {
	json_value();some_value_();
}
Пример #5
0
void some_value_() {
	if(look_ahead == ','){
		match(',');json_value();some_value_();
	}else
	;
}
Пример #6
0
void name_value() {
	std::string name;
	name = match_str();match(':');json_value();
	std::cout << "Get Name: " << name << std::endl;
}