コード例 #1
0
ファイル: skeleton.cpp プロジェクト: buildar/awe_kinect
void SkeletonFrame::WriteJson(rapidjson::PrettyWriter<rapidjson::StringBuffer>& writer) {
	std::map<std::string,Position>::iterator it;
	std::stringstream ss;
	ss << this->id;
	writer.String(ss.str().c_str());
	writer.StartObject();
	

	for (it=this->deltas.begin(); it != this->deltas.end(); ++it) {
		writer.String(it->first.c_str());
		it->second.WriteJson(writer);
	}
	writer.EndObject();
}
コード例 #2
0
ファイル: skeleton.cpp プロジェクト: buildar/awe_kinect
void SkeletonTracker::WriteHeader(const char *action, time_t timestamp, rapidjson::PrettyWriter<rapidjson::StringBuffer>& writer) {
	std::stringstream ss;
	ss << timestamp;
	writer.String("HEAD");
	writer.StartObject();
	writer.String("service");
	writer.String("skeletons");
	writer.String("timestamp");
	writer.String(ss.str().c_str());
	writer.String("action");
	writer.String(action);
	writer.EndObject();
}
コード例 #3
0
ファイル: spawner_new.cpp プロジェクト: klenin/Spawner
void spawner_new_c::json_report(runner *runner_instance,
    rapidjson::PrettyWriter<rapidjson::StringBuffer, rapidjson::UTF16<> > &writer) {
    writer.StartObject();

    //for {
    report_class runner_report = runner_instance->get_report();
    options_class runner_options = runner_instance->get_options();
    //temporary
#define rapidjson_write(x) (writer.String(a2w(x)))
    rapidjson_write("Application");
    rapidjson_write(runner_report.application_name.c_str());
    rapidjson_write("Arguments");
    writer.StartArray();
    for (size_t i = 0; i < runner_options.get_arguments_count(); ++i) {
        rapidjson_write(runner_options.get_argument(i).c_str());
    }
    writer.EndArray();

    rapidjson_write("Limit");
    writer.StartObject();

    restrictions_class runner_restrictions = ((secure_runner*)runner_instance)->get_restrictions();
    struct {
        const char *field;
        unit_t unit;
        degrees_enum degree;
        restriction_kind_t restriction;
    } restriction_items[] = {
        { "Time", unit_time_second, degree_micro, restriction_processor_time_limit },
        { "WallClockTime", unit_time_second, degree_micro, restriction_user_time_limit },
        { "Memory", unit_memory_byte, degree_default, restriction_memory_limit },
        { "SecurityLevel", unit_no_unit, degree_default, restriction_security_limit },
        { "IOBytes", unit_memory_byte, degree_default, restriction_write_limit },
        { "IdlenessTime", unit_time_second, degree_micro, restriction_idle_time_limit },
        { "IdlenessProcessorLoad", unit_no_unit, degree_centi, restriction_load_ratio },
        { nullptr, unit_no_unit, degree_default, restriction_max },
    };
    for (int i = 0; restriction_items[i].field; ++i) {
        if (!runner_restrictions.check_restriction(restriction_items[i].restriction)) {
            continue;
        }
        rapidjson_write(restriction_items[i].field);
        if (restriction_items[i].degree == degree_default) {
            writer.Uint64(runner_restrictions[restriction_items[i].restriction]);
        }
        else {
            writer.Double((double)convert(
                value_t(restriction_items[i].unit, restriction_items[i].degree),
                value_t(restriction_items[i].unit),
                (long double)runner_restrictions[restriction_items[i].restriction]
            ));
        }
    }
    writer.EndObject();

    rapidjson_write("Options");
    writer.StartObject();
    rapidjson_write("SearchInPath");
    writer.Bool(runner_options.use_cmd);
    writer.EndObject();

    rapidjson_write("Result");
    writer.StartObject();
    struct {
        const char *field;
        uint64_t value;
        unit_t unit;
        degrees_enum degree;
    } result_items[] = {
        { "Time", runner_report.processor_time, unit_time_second, degree_micro },
        { "WallClockTime", runner_report.user_time, unit_time_second, degree_micro },
        { "Memory", runner_report.peak_memory_used, unit_memory_byte, degree_default },
        { "BytesWritten", runner_report.write_transfer_count, unit_memory_byte, degree_default },
        { "KernelTime", runner_report.kernel_time, unit_time_second, degree_micro },
        { "ProcessorLoad", (uint64_t)(runner_report.load_ratio * 100), unit_no_unit, degree_micro },
        { nullptr, 0, unit_no_unit, degree_default },
    };
    for (int i = 0; result_items[i].field; ++i) {
        rapidjson_write(result_items[i].field);
        if (result_items[i].degree == degree_default) {
            writer.Uint64(result_items[i].value);
        }
        else {
            writer.Double((double)convert(
                value_t(result_items[i].unit, result_items[i].degree),
                value_t(result_items[i].unit),
                (long double)result_items[i].value
            ));
        }
    }
    rapidjson_write("WorkingDirectory");
    rapidjson_write(runner_report.working_directory.c_str());
    writer.EndObject();

    rapidjson_write("StdOut");
    writer.StartArray();
    for (const auto& i : runner_options.stdoutput) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();
    rapidjson_write("StdErr");
    writer.StartArray();
    for (const auto& i : runner_options.stderror) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();
    rapidjson_write("StdIn");
    writer.StartArray();
    for (const auto& i : runner_options.stdinput) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();

    rapidjson_write("CreateProcessMethod");
    rapidjson_write(options.login.empty() ? "CreateProcess" : "WithLogon");
    rapidjson_write("UserName");
    writer.String(runner_report.login.c_str());
    rapidjson_write("TerminateReason");
    rapidjson_write(get_terminate_reason(runner_report.terminate_reason).c_str());
    rapidjson_write("ExitCode");
    writer.Uint(runner_report.exit_code);
    rapidjson_write("ExitStatus");
    rapidjson_write(ExtractExitStatus(runner_report).c_str());
    rapidjson_write("SpawnerError");
    writer.StartArray();
    std::vector<std::string> errors;
    errors.push_back(get_error_text());
    for (const auto& error : errors) {
        rapidjson_write(error.c_str());
    }
    writer.EndArray();
    writer.EndObject();
}
コード例 #4
0
void CMC_Material::write(rapidjson::PrettyWriter<rapidjson::StringBuffer> &writer)
{
    writer.StartObject ();

    writer.String ("ambient_color");
    writer.StartArray ();
    writer.Double (ambientColor.x());
    writer.Double (ambientColor.y());
    writer.Double (ambientColor.z());
    writer.EndArray ();

    writer.String ("diffuse_color");
    writer.StartArray ();
    writer.Double (diffuseColor.x());
    writer.Double (diffuseColor.y());
    writer.Double (diffuseColor.z());
    writer.EndArray ();

    writer.String ("specular_color");
    writer.StartArray ();
    writer.Double (specularColor.x());
    writer.Double (specularColor.y());
    writer.Double (specularColor.z());
    writer.EndArray ();

    writer.String ("diffuse_texture_path");
    writer.String (diffuseTexturePath.c_str ());

    writer.String("normal_map_texture_path");
    writer.String (normalTexturePath.c_str ());

    writer.EndObject ();
}
コード例 #5
0
void CMC_MeshData::write(rapidjson::PrettyWriter<rapidjson::StringBuffer> &writer)
{
    writer.StartObject ();

    //material index
    writer.String ("material_index");
    writer.Int (m_materialIndex);

    //write vertices.
    writer.String ("vertices");
    writer.StartArray ();
    for(int i =0;i<m_vertices.size ();i++)
    {
        m_vertices[i].write (writer);
    }
    writer.EndArray ();

    //write indices.
    writer.String ("indices");
    writer.StartArray ();
    for(auto i : m_indices)
    {
        writer.Int (i);
    }
    writer.EndArray ();

    writer.EndObject ();
}