本文整理汇总了C++中rapidjson::Document::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::Accept方法的具体用法?C++ Document::Accept怎么用?C++ Document::Accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Document
的用法示例。
在下文中一共展示了Document::Accept方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_response_ok
void controller::write_response_ok(const rapidjson::Document& data)
{
rapidjson::StringBuffer reply;
rapidjson::Writer<rapidjson::StringBuffer> reply_writer(reply);
data.Accept(reply_writer);
_http_session->write_http_response(HTTP_CODE_OK, http_session::CONTENT_TYPE_JSON, reply.GetString(), reply.Size());
}
示例2: send
void Connection::send(rapidjson::Document &doc)
{
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
doc.Accept(writer);
send(buffer.GetString(), buffer.GetSize());
}
示例3: jsonToString
std::string jsonToString(const rapidjson::Document &document)
{
JsonStringWriter out;
rapidjson::PrettyWriter<JsonStringWriter> writer(out);
document.Accept(writer);
// Yes, the string is copied here. stringstream does not allow moving the result out (boo!)
return out.sstream.str();
}
示例4: rapidjsonToString
std::string minius::rapidjsonToString(const rapidjson::Document& document)
{
rapidjson::StringBuffer stringBuffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(stringBuffer);
document.Accept(writer);
std::string message = stringBuffer.GetString();
return message;
}
示例5: WriteJSON
void FileSystem::WriteJSON( const char* filePath, rapidjson::Document& json )
{
FILE* file;
if ( fopen_s(&file, filePath, "w" ) != 0 )
return;
rapidjson::FileStream fs(file);
rapidjson::PrettyWriter<rapidjson::FileStream> writer(fs);
json.Accept(writer);
fclose(file);
}
示例6: toJson
std::string toJson(rapidjson::Document& doc){
try {
rapidjson::StringBuffer buffer;
buffer.Clear();
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
doc.Accept(writer);
return std::string(buffer.GetString());
}catch(std::exception& e){
DebugMessageWithTime("toJson exception:",e.what());
return "";
}
}
示例7: FlushDataToFile
void HrConvertUtil::FlushDataToFile(const std::string& strOutputFile, rapidjson::Document& doc)
{
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
doc.Accept(writer);
std::string strJsonContent = std::string(buffer.GetString());
strJsonContent = FormatJsonData(strJsonContent);
std::string strRootPath = HrFileUtils::Instance()->GetFilePath(strOutputFile);
std::string strFileName = HrFileUtils::Instance()->GetFileName(strOutputFile);
std::string strSuffix = HrFileUtils::Instance()->GetFileSuffix(strOutputFile);
filesystem::path filePath(strRootPath);
//filePath = filePath / strFileName;
//if (!filesystem::exists(filePath))
//{
// filesystem::create_directories(filePath);
//}
//auto outputFilePath = filePath / (strFileName + "." + strSuffix);
std::string strRealOutputFilePath = strOutputFile;//outputFilePath.string();
HrFileUtils::Instance()->WriteDataToFile(strRealOutputFilePath, strJsonContent);
auto fileTexturePath = filePath / "Texture\\";
if (!filesystem::exists(fileTexturePath))
{
filesystem::create_directories(fileTexturePath);
}
//拷贝图片到Texture文件夹
for (size_t nMatIndex = 0; nMatIndex < m_modelDesc.vecMaterialDataInfo.size(); ++nMatIndex)
{
for (int nTexIndex = 0; nTexIndex < HrModelDataInfo::HrMaterialDataInfo::TS_NUMTEXTURESLOTS; ++nTexIndex)
{
if (filesystem::exists(m_modelDesc.vecMaterialDataInfo[nMatIndex].m_arrTexNames[nTexIndex]))
{
std::string strFileName = HrFileUtils::Instance()->GetFileNameWithSuffix(m_modelDesc.vecMaterialDataInfo[nMatIndex].m_arrTexNames[nTexIndex]);
filesystem::path dstFilePath = fileTexturePath / strFileName;
if (filesystem::exists(dstFilePath))
filesystem::remove(dstFilePath);
filesystem::copy_file(m_modelDesc.vecMaterialDataInfo[nMatIndex].m_arrTexNames[nTexIndex], dstFilePath);
}
}
}
}
示例8: writeConfigDocToFile
void MainWindow::writeConfigDocToFile(const rapidjson::Document &doc,
const std::string &filename) {
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
doc.Accept(writer);
std::ofstream output_file;
output_file.open(filename);
if (!output_file.is_open()) {
throw std::runtime_error(
(boost::format("Could not open file %s.") % filename).str()
);
}
else {
output_file << buffer.GetString();
output_file.close();
}
}
示例9: saveShaderCache
void saveShaderCache()
{
FILE* fp = fopen(_shaderCacheFilePath.c_str(), "wb");
if (fp == nullptr)
{
_INTR_LOG_ERROR("Failed to save shader cache...");
return;
}
char* writeBuffer = (char*)Memory::Tlsf::MainAllocator::allocate(65536u);
{
rapidjson::FileWriteStream os(fp, writeBuffer, 65536u);
rapidjson::PrettyWriter<rapidjson::FileWriteStream> writer(os);
_shaderCache.Accept(writer);
fclose(fp);
}
Memory::Tlsf::MainAllocator::free(writeBuffer);
}
示例10: parseField
Field SchemaHelper::parseField(const rapidjson::Document &data, int index)
{
Field field = std::make_shared<SchemaField>();
field->index = index;
field->name = getJSONString(data, "name");
field->type = getJSONString(data, "type");
field->geometry_type = getJSONString(data, "geometry_type");
field->nullable = getJSONBool(data, "nullable");
field->related_to = getJSONLong(data, "related_to", -1);
field->max_length = getJSONInt(data, "max_length", -1);
field->default_value = getJSONString(data, "default");
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
data.Accept(writer);
field->json = buffer.GetString();
if(field->name == "amigo_id")
{
field->unique = true;
}
return field;
}