当前位置: 首页>>代码示例>>C++>>正文


C++ Document::Accept方法代码示例

本文整理汇总了C++中Document::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::Accept方法的具体用法?C++ Document::Accept怎么用?C++ Document::Accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document::Accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddToSSGS

// Adds the game to SteelSeries Engine 3 GameSense.
int AddToSSGS() {

	//////////////// -GameDataJson- ////////////////

	// Data.
	const char* GameDataJson = "{\"game\":\"FALLOUT4\",\"event\":\"HEALTH\",\"data\":{\"value\":0}}";
	const char* GameData2Json = "{\"game\":\"FALLOUT4\",\"event\":\"STAMINA\",\"data\":{\"value\":0}}";
	const char* GameData3Json = "{\"game\":\"FALLOUT4\",\"event\":\"RADS\",\"data\":{\"value\":0}}";
	const char* GameData4Json = "{\"game\":\"FALLOUT4\",\"event\":\"WEIGHT\",\"data\":{\"value\":0}}";

	// Parsed JSON.
	Document GameJsonParsed;
	// Processed JSON ready be posted.
	StringBuffer Buffer;

	//// -HEALTH- ////

	// Parse.
	GameJsonParsed.Parse(GameDataJson);
	// Insert default value.
	Value& STR = GameJsonParsed["data"]["value"];
	STR.SetInt(100); // 100 Health default.
					 // Format into buffer.
	Writer<StringBuffer>writer(Buffer);
	GameJsonParsed.Accept(writer);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -STAMINA- ////

	// Parse.
	GameJsonParsed.Parse(GameData2Json);
	// Insert default value.
	Value& STR2 = GameJsonParsed["data"]["value"];
	STR2.SetInt(100); // 100 Stamina default.
					  // Format into buffer.
	Writer<StringBuffer>writer2(Buffer);
	GameJsonParsed.Accept(writer2);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -RADS- ////

	// Parse.
	GameJsonParsed.Parse(GameData3Json);
	// Insert default value.
	Value& STR3 = GameJsonParsed["data"]["value"];
	STR3.SetInt(0); // 0 RADS default.
					// Format into buffer.
	Writer<StringBuffer>writer3(Buffer);
	GameJsonParsed.Accept(writer3);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//// -WEIGHT- ////

	// Parse.
	GameJsonParsed.Parse(GameData4Json);
	// Insert default value.
	Value& STR4 = GameJsonParsed["data"]["value"];
	STR4.SetInt(100); // 100 WEIGHT default.
					  // Format into buffer.
	Writer<StringBuffer>writer4(Buffer);
	GameJsonParsed.Accept(writer4);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameEvent);
	// Cleanup.
	Buffer.Clear();

	//////////////// -GameInterfaceJson- ////////////////

	// Data.
	const char* GameInterfaceJson = "{\"game\":\"FALLOUT4\",\"game_display_name\":\"Fallout 4\",\"icon_color_id\":5}";

	//// -Interface- ////

	// Parse.
	GameJsonParsed.Parse(GameInterfaceJson);
	// Insert default value.
	Writer<StringBuffer>writer5(Buffer);
	GameJsonParsed.Accept(writer5);
	// Post.
	PostJson(Buffer, SSGS_ServerAddress_GameMetadata);
	// Cleanup.
	Buffer.Clear();

	//////////////// -GameInterfaceEventsJson- ////////////////

	// Data.
	const char* GameInterfaceEventsJson = "{\"game\":\"FALLOUT4\",\"event\":\"HEALTH\",\"min_value\":0,\"max_value\":100,\"icon_id\":1}";
	const char* GameInterfaceEvents2Json = "{\"game\":\"FALLOUT4\",\"event\":\"STAMINA\",\"min_value\":0,\"max_value\":100,\"icon_id\":11}";
	const char* GameInterfaceEvents3Json = "{\"game\":\"FALLOUT4\",\"event\":\"RADS\",\"min_value\":0,\"max_value\":100,\"icon_id\":6}";
	const char* GameInterfaceEvents4Json = "{\"game\":\"FALLOUT4\",\"event\":\"WEIGHT\",\"min_value\":0,\"max_value\":100,\"icon_id\":17}";
//.........这里部分代码省略.........
开发者ID:Sumwunn,项目名称:SSGSPlugin_FO4,代码行数:101,代码来源:SSGSPlugin_FO4_Setup.cpp

示例2: main

int main(int argc, char** argv){
	arma::wall_clock timer; //Keeps track of how much time my program is taking to run.

	timer.tic();

	cout << "In this program I'm assuming that the given json model.adm file will follow a certain format, where keys will have an expected name." <<endl;
	//cout << "If no information is displaying after this line that means that you didn't input the two integer arguments for bodyID and constraintID." <<endl;
	//double constraintID = double(atof(argv[1]));

	cout << "Start of Assignment" <<endl;


	MyJsonDocument d = parseJSON("models/simplePend.acf");

	string simulation = string(d["simulation"].GetString());
	double tend = d["tend"].GetDouble();
	double stepSize = d["stepSize"].GetDouble();
	double outputSteps = d["outputSteps"].GetDouble();


	cout << "Simulation = "  + simulation <<endl;
	cout << "tend = ";
	cout << tend << endl;
	cout << "stepSize = ";
	cout << stepSize << endl;
	cout << "outputSteps = ";
	cout << outputSteps << endl;


	//static const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" };

	MyJsonDocument d4 = parseJSON("models/simplePend.adm");
	cout << "parsing is fine" << endl;
	Model m(d4, simulation, tend,outputSteps,stepSize);


/**
	vector<c_constraint*> constraints = m.getConstraints();
	for(std::vector<int>::size_type i = 0; i != constraints.size(); i++) {

			constraints[i]->print();

	}*/

	m.solveK();

	std::vector<arma::vec> q = m.getQList();
	std::vector<arma::vec> qd = m.getQdList();
	std::vector<arma::vec> qdd = m.getQddList();

	double xAccPlot[2][(int)m.getOutputSteps()];
	double trajectoryPlot[2][(int)m.getOutputSteps()];

	Document doc;
	doc.SetObject();
	rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();

	Value plot1(kArrayType);
	Value plot1X(kArrayType);
    Value plot1Y(kArrayType);
	Value plot2(kArrayType);
	Value plot2X(kArrayType);
    Value plot2Y(kArrayType);

	for(int i = 0; i <= m.getOutputSteps(); i++){
		xAccPlot[0][i] = m.getStepSize()*i;
		xAccPlot[1][i] = qdd.at(i)(0);

		plot1X.PushBack(xAccPlot[0][i],allocator);
		plot1Y.PushBack(xAccPlot[1][i],allocator);


		trajectoryPlot[0][i] = q.at(i)(0);
		trajectoryPlot[1][i] = q.at(i)(1);
		plot2X.PushBack(trajectoryPlot[0][i],allocator);
		plot2Y.PushBack(trajectoryPlot[1][i],allocator);

	}
	plot1.PushBack(plot1X,allocator);
	plot1.PushBack(plot1Y,allocator);
	plot2.PushBack(plot2X,allocator);
	plot2.PushBack(plot2Y,allocator);

	doc.AddMember("Plot1",plot1,allocator);
	doc.AddMember("Plot2",plot2,allocator);

	StringBuffer strbuf;
	Writer<StringBuffer> writer(strbuf);
	doc.Accept(writer);

    std::string plotsData = strbuf.GetString();


	ofstream dataFile ("plots/data.json");
	if (dataFile.is_open()){
	    dataFile << plotsData;
	    dataFile.close();
	}
	else cout << "Unable to open file";

//.........这里部分代码省略.........
开发者ID:felipegb94,项目名称:simEngine,代码行数:101,代码来源:assignment7.cpp

示例3: outputJSON

std::string ProfileRegion::outputJSON() {
  const char *base = 
    "{"
      "\"region_id\":0,"
      "\"region_type\":0,"
      "\"file_name\":\"\","
      "\"start_line\":0,"
      "\"end_line\":0,"
      "\"initial_mask\":0,"
      "\"lane_usage\":[],"
      "\"full_mask_percentage\": [],"
      "\"ipc\":0,"
      "\"l2_hit\":0,"
      "\"l3_hit\":0,"
      "\"bytes_read\":0"
    "}";

  Document d;
  d.Parse(base);

  d["region_id"].SetUint64(this->id);
  d["region_type"].SetInt(this->region_type);
  d["file_name"].SetString(StringRef(this->file_name));
  d["start_line"].SetInt(this->start_line);
  d["end_line"].SetInt(this->end_line);
  d["initial_mask"].SetUint64(this->initial_mask);
  d["ipc"].SetDouble(this->avg_ipc);
  d["l2_hit"].SetDouble(this->avg_l2_hit);
  d["l3_hit"].SetDouble(this->avg_l3_hit);
  d["bytes_read"].SetDouble(this->avg_bytes_read);

  // Add list of lane usage by line number.
  Value &lane_usage = d["lane_usage"];
  Document::AllocatorType &allocator = d.GetAllocator();
  for (LaneUsageMap::iterator it = this->laneUsageMap.begin(); 
      it != this->laneUsageMap.end(); ++it) {
    Value line(kObjectType);

    double percent = it->second.second/double(it->second.first) * 100;

    line.AddMember("line", it->first, allocator);
    line.AddMember("percent", percent, allocator);

    lane_usage.PushBack(line, allocator); 
  }

  // Add list of percent of full mask runs by line number.
  Value &full_mask = d["full_mask_percentage"];
  for (LaneUsageMap::iterator it = this->fullMaskMap.begin(); 
      it != this->fullMaskMap.end(); ++it) {
    Value line(kObjectType);

    double percent = it->second.second/double(it->second.first) * 100;

    line.AddMember("line", it->first, allocator);
    line.AddMember("percent", percent, allocator);

    full_mask.PushBack(line, allocator); 
  }
  
  // Stringify the DOM
  StringBuffer buffer;
  Writer<StringBuffer> writer(buffer);
  d.Accept(writer);

  std::string str(buffer.GetString());
  return str;
}
开发者ID:kku1993,项目名称:ispc,代码行数:68,代码来源:profile_ctx.cpp

示例4: NodeWifiHandler


//.........这里部分代码省略.........
    // Sunucu tarafından gönderilen Matlab komutlarına Subscribe olunuyor
    else
    {
      status = serverReqReader->take(serverReqSeq,
                                     infoSeq,
                                     LENGTH_UNLIMITED,
                                     ANY_SAMPLE_STATE,
                                     ANY_VIEW_STATE,
                                     ANY_INSTANCE_STATE);
      checkStatus(status, "severReqDataReader::take");

      // isDataReceived değişkeni bir kontrol değişkeni olup, Matlab komut
      // bilgisini içeren mesaja Subscribe olunduysa true, olunmadıysa false
      // değerini tutar
      bool isDataReceived = false;

      for (DDS::ULong j = 0; j < serverReqSeq.length(); j++)
      {

        if(infoSeq[j].valid_data)
        {
          cout << "=== [Subscriber] message received :" << endl;
          cout << "    Received Request Message  : "
               << serverReqSeq[j].request << endl;
          cout << "    Received RequestID : \""
               << serverReqSeq[j].requestID << "\"" << endl;

          // Rapidjson yapılandırıcısı yaratılıyor
          Document d;
          if(d.Parse(serverReqSeq[j].request).HasParseError())
            cout << " Parsing Error!" << endl;
          StringBuffer nodeIdBuffer;
          Writer<StringBuffer> nodeIdWriter(nodeIdBuffer);
          d["NodeID"].Accept(nodeIdWriter);
          string tempNodeId = nodeIdBuffer.GetString();

          // Subscribe olunan mesajın düğüme ait olup olmadığı kontrol ediliyor
          if (tempNodeId == "\"SensDug13\"")
          {
            StringBuffer buffer;

            // Reset komutunun gelip gelmediği kontrol ediliyor.
            Value::ConstMemberIterator itr = d.FindMember("Reset");
            if(itr != d.MemberEnd())
            {
              // Resetin değeri falsedan trueya çevriliyor
              Value& s = d["Reset"];
              s.SetBool(true);

              // Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
              Writer<StringBuffer> writer(buffer);
              d.Accept(writer);

              cout << "    Request Message is modified to  : "
                   << buffer.GetString() << endl;

              // Publish edilecek Response mesajı hazırlanıyor
              string str = buffer.GetString();
              str.append("\n");
              serverReq->request = DDS::string_dup(str.c_str());
              serverReq->requestID = serverReqSeq[j].requestID;

              if(!isDataReceived && status == DDS::RETCODE_OK)
              {
                // Response mesajı gönderiliyor
                ReturnCode_t tempStatus = serverReqWriter->write(
开发者ID:snmbzkrt,项目名称:rfkon,代码行数:67,代码来源:NodeWifiHandler.cpp


注:本文中的Document::Accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。