예제 #1
0
mValue EndScenarioCommand::run(mValue &jsonArgs) {
    if (jsonArgs.is_null() || !jsonArgs.get_obj()["tags"].is_null()) {
        commands.endScenario();
        return success_response();
    } else {
        return fail_response();
    }
}
	shared_ptr<Obstacle> Obstacle::fromJson(mValue data)
	{
		auto height = data.get_obj().at("height").get_int();
		auto width = data.get_obj().at("width").get_int();
		auto location = data.get_obj().at("location");
		auto x = location.get_obj().at("x").get_int();
		auto y = location.get_obj().at("y").get_int();
		return make_shared<Obstacle>(x, y, width, height);
	}
예제 #3
0
mValue BeginScenarioCommand::run(mValue &jsonArgs) {
    TagExpression::tag_list *tags = new TagExpression::tag_list;
    if (!jsonArgs.is_null()) {
        mArray &jsonTags = jsonArgs.get_obj()["tags"].get_array();
        for (mArray::const_iterator i = jsonTags.begin(); i != jsonTags.end(); ++i) {
            std::string tag = i->get_str();
            tags->push_back(tag);
        }
    }
    commands.beginScenario(tags);
    return success_response();
}
예제 #4
0
mValue WireProtocol::invokeCommand(mValue &decodedRequestValue) {
    mArray decodedRequest = decodedRequestValue.get_array();
    if (decodedRequest.size() > 0) {
        std::string commandName = decodedRequest[0].get_str();
        JSONCommand *requestedCommand = jsonCommands[commandName].get();
        if (requestedCommand != 0) {
            mValue args;
            if (decodedRequest.size() > 1) {
                args = decodedRequest[1];
            }
            return requestedCommand->run(args);
        }
    }
    return JSONCommand::fail_response();
}
	CarLikeControl CarLikeControl::fromJson(mValue data)
	{
		auto step = data.get_obj().at("step").get_real();
		auto turn = data.get_obj().at("turn").get_real();
		return CarLikeControl(step, turn);
	}
예제 #6
0
step_id_type InvokeCommand::getInvokeId(mValue &jsonArgs) {
    std::string idString(jsonArgs.get_obj()["id"].get_str());
    return fromString<step_id_type> (idString);
}
예제 #7
0
mValue SnippetTextCommand::run(mValue &jsonArgs) {
    mObject args = jsonArgs.get_obj();
    const std::string stepKeyword(args["step_keyword"].get_str());
    const std::string stepName(args["step_name"].get_str());
    return formatResponse(commands.snippetText(stepKeyword, stepName));
}
예제 #8
0
std::string StepMatchesCommand::getStepMatchesMatcher(mValue &jsonArgs) {
    mObject args = jsonArgs.get_obj();
    std::string matcher(args["name_to_match"].get_str());
    return matcher;
}