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


C++ StyledWriter::write方法代码示例

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


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

示例1:

TEST_F(JsonCpp, StyledWriter) {
	for (int i = 0; i < kTrialCount; i++) {
		StyledWriter writer;
		std::string str = writer.write(root_);
		//if (i == 0)
		//	std::cout << str.length() << std::endl;
	}
}
开发者ID:120pulsations,项目名称:Torque2D,代码行数:8,代码来源:jsoncpptest.cpp

示例2: benchmark_jsoncpp

measurements benchmark_jsoncpp(const char *input_filename,
                               const char* output_filename)
{
    size_t start_memory_used;
    size_t end_memory_used;
    size_t time_to_read;
    size_t time_to_write;

    {
        start_memory_used =  memory_measurer::virtual_memory_currently_used_by_current_process();

        Value root;
        {
            try
            {
                auto start = high_resolution_clock::now();
                std::ifstream is(input_filename);
                is >> root;
                //Reader reader;
                //if (!reader.parse(input_filename, root))
                //{
                //    std::cerr << "jsoncpp failed." << std::endl;
                //}
                auto end = high_resolution_clock::now();
                time_to_read = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
            }
            catch (const std::exception& e)
            {
                std::cout << e.what() << std::endl;
                exit(1);
            }
        }
        end_memory_used =  memory_measurer::virtual_memory_currently_used_by_current_process();
        {
            char writeBuffer[65536];
            std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
            os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
            os.open(output_filename, std::ios_base::out | std::ios_base::binary);
            auto start = high_resolution_clock::now();
            //os << root;

            StyledWriter styledWriter;
            //std::ofstream writer(filename, std::ifstream::binary);
            os << styledWriter.write(root);

            auto end = high_resolution_clock::now();
            time_to_write = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
        }
    }
    size_t final_memory_used = memory_measurer::virtual_memory_currently_used_by_current_process();
	
	measurements results;
    results.library_name = library_name;
    results.memory_used = (end_memory_used - start_memory_used)/1000000;
    results.time_to_read = time_to_read;
    results.time_to_write = time_to_write;
    return results;
}
开发者ID:bawoking,项目名称:json_benchmarks,代码行数:58,代码来源:benchmark_jsoncpp.cpp

示例3: getRawString

//--------------------------------------------------------------
string JSONElement::getRawString(bool pretty) {
	string raw;
	if(pretty) {
		StyledWriter writer;
		raw = writer.write(*this);
	} else {
		FastWriter writer;
		raw = writer.write(*this);
	}
	return raw;
}
开发者ID:AgrimPrasad,项目名称:Unlogo,代码行数:12,代码来源:JSONElement.cpp

示例4: save

//--------------------------------------------------------------
bool JSONElement::save(string filename, bool pretty)
{
	ofstream file_key(filename.c_str());
	if (!file_key.is_open()) {
		cout << "Unable to open " << filename << endl;
		return false;
	}
	
	if(pretty) {
		StyledWriter writer;
		file_key << writer.write( *this ) << endl;
	} else {
		FastWriter writer;
		file_key << writer.write( *this ) << endl;
	}
	file_key.close();	
	return true;
}
开发者ID:AgrimPrasad,项目名称:Unlogo,代码行数:19,代码来源:JSONElement.cpp

示例5: save

//--------------------------------------------------------------
bool ofxJSONElement::save(string filename, bool pretty)
{
	filename = ofToDataPath(filename, true);
	ofstream file_key(filename.c_str());
	if (!file_key.is_open()) {
		ofLog(OF_LOG_WARNING, "Unable to open "+filename);
		return false;
	}
	
	if(pretty) {
		StyledWriter writer;
		file_key << writer.write( *this ) << endl;
	} else {
		FastWriter writer;
		file_key << writer.write( *this ) << endl;
	}
	ofLog(OF_LOG_NOTICE, "JSON saved to "+filename);
	file_key.close();	
	return true;
}
开发者ID:PetrosKataras,项目名称:ofxJSON,代码行数:21,代码来源:ofxJSONElement.cpp

示例6:

std::string 
Value::toStyledString() const
{
   StyledWriter writer;
   return writer.write( *this );
}
开发者ID:jjiezheng,项目名称:game-platform-core-native,代码行数:6,代码来源:json_value.cpp

示例7: toStyledString

JSONCPP_STRING Value::toStyledString() const {
  StyledWriter writer;
  return writer.write(*this);
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:4,代码来源:json_value.cpp

示例8: sendJSON

void JSONResponse::sendJSON(struct mg_connection *conn, const Value& value) {
	StyledWriter writer; 	//todo(njoubert): Replace with FastWriter for production
	string out = writer.write(value);
	sendHTTPResponse(conn, out.c_str(), out.length());
}
开发者ID:njoubert,项目名称:Sylvester,代码行数:5,代码来源:syl_serv_response.cpp


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