本文整理汇总了C++中json::StyledStreamWriter类的典型用法代码示例。如果您正苦于以下问题:C++ StyledStreamWriter类的具体用法?C++ StyledStreamWriter怎么用?C++ StyledStreamWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StyledStreamWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fin
void FixAddColor::FixParticle3d(const std::string& filepath) const
{
Json::Value val;
Json::Reader reader;
std::locale::global(std::locale(""));
std::ifstream fin(filepath.c_str());
std::locale::global(std::locale("C"));
reader.parse(fin, val);
fin.close();
bool dirty = false;
for (int i = 0, n = val["components"].size(); i < n; ++i) {
if (val["components"][i]["add_col_begin"]["a"].asInt() != 0 ||
val["components"][i]["add_col_end"]["a"].asInt() != 0) {
val["components"][i]["add_col_begin"]["a"] = 0;
val["components"][i]["add_col_end"]["a"] = 0;
dirty = true;
}
}
if (dirty) {
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filepath.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, val);
fout.close();
}
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:29,代码来源:FixAddColor.cpp
示例2: FixComplex
void ChangeComplexOrigin::FixComplex(const std::string& filepath) const
{
const Item* item = QueryItem(filepath);
if (!item) {
return;
}
Json::Value value;
Json::Reader reader;
std::locale::global(std::locale(""));
std::ifstream fin(filepath.c_str());
std::locale::global(std::locale("C"));
reader.parse(fin, value);
fin.close();
for (int i = 0, n = value["sprite"].size(); i < n; ++i)
{
Json::Value& spr_val = value["sprite"][i];
sm::vec2 pos;
if (spr_val.isMember("position")) {
pos.x = spr_val["position"]["x"].asDouble();
pos.y = spr_val["position"]["y"].asDouble();
}
pos -= item->trans;
spr_val["position"]["x"] = pos.x;
spr_val["position"]["y"] = pos.y;
}
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filepath.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:35,代码来源:ChangeComplexOrigin.cpp
示例3: saveScores
void saveScores()
{
Json::StyledStreamWriter writer;
ofstream test("scores.json", std::ifstream::binary);
writer.write(test, scoreRoot);
}
开发者ID:SirWaddles,项目名称:TestNewWS,代码行数:7,代码来源:Assets.cpp
示例4: Trigger
void FormatJsonFile::Trigger(const std::string& dir) const
{
wxArrayString files;
ee::FileHelper::FetchAllFiles(dir, files);
for (int i = 0, n = files.size(); i < n; ++i)
{
std::string filepath = ee::FileHelper::GetAbsolutePath(files[i].ToStdString());
int pos = filepath.rfind('.');
if (pos == -1) {
continue;
}
std::string ext = filepath.substr(pos);
if (ext == ".json")
{
Json::Value value;
Json::Reader reader;
std::locale::global(std::locale(""));
std::ifstream fin(filepath.c_str());
std::locale::global(std::locale("C"));
reader.parse(fin, value);
fin.close();
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filepath.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
}
}
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:33,代码来源:FormatJsonFile.cpp
示例5: verificarUsuario
bool Login::verificarUsuario(string& arch_usuarios){
std::fstream arch;
arch.open(arch_usuarios.c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::app);
Json::Value valores;
Json::Reader reader;
Json::Value aux;
reader.parse(arch, valores, false);
aux = valores[*(nuevo_usuario->nombre)];
char res;
if (! aux){
Json::StyledStreamWriter escritor;
Json::Value nuevo;
nuevo[*(nuevo_usuario->nombre)] = *(nuevo_usuario->contrasenia);
escritor.write(arch, nuevo);
res = OK;
} else if(*(nuevo_usuario->contrasenia) == aux.asString()){
res = OK;
} else {
delete nuevo_usuario->nombre;
delete nuevo_usuario->contrasenia;
res = ERROR;
}
nuevo_usuario->sockets->enviar_cli->enviar(&res, sizeof(res));
arch.close();
return (res == OK);
}
开发者ID:debmartin,项目名称:log-horizon,代码行数:28,代码来源:Login.cpp
示例6: paste
//----------
void Patch::paste() {
//get the clipboard into json
const auto clipboardText = ofxClipboard::paste();
Json::Value json;
Json::Reader().parse(clipboardText, json);
//if we got something
if (json.isObject()) {
//let's make it
auto nodeHost = FactoryRegister::X().make(json);
//and add it to the patch
this->addNodeHost(nodeHost);
//and let's offset the bounds in the clipboard for the next paste
ofRectangle bounds;
json["Bounds"] >> bounds;
bounds.x += 20;
bounds.y += 20;
json["Bounds"] << bounds;
//push the updated copy into the clipboard
stringstream jsonString;
Json::StyledStreamWriter styledWriter;
styledWriter.write(jsonString, json);
ofxClipboard::copy(jsonString.str());
}
开发者ID:theomission,项目名称:ofxRulr,代码行数:28,代码来源:Patch.cpp
示例7: useStyledStreamWriter
static std::string useStyledStreamWriter(
Json::Value const& root)
{
Json::StyledStreamWriter writer;
std::ostringstream sout;
writer.write(sout, root);
return sout.str();
}
开发者ID:Jakebo,项目名称:Test_Project,代码行数:8,代码来源:main.cpp
示例8: saveToFile
void Config::saveToFile(std::string filename)
{
Logging::Log->info("Saving config file: %s", filename.c_str());
std::ofstream file(("Data/Config/" + filename).c_str());
Json::StyledStreamWriter writer;
writer.write(file, *this);
}
开发者ID:maker91,项目名称:VoxMysticum,代码行数:8,代码来源:Config.cpp
示例9: useStyledStreamWriter
static JSONCPP_STRING useStyledStreamWriter(
Json::Value const& root)
{
Json::StyledStreamWriter writer;
JSONCPP_OSTRINGSTREAM sout;
writer.write(sout, root);
return sout.str();
}
开发者ID:151706061,项目名称:jsoncpp,代码行数:8,代码来源:main.cpp
示例10: SaveTmpInfo
void Frame::SaveTmpInfo()
{
std::string filename = FileHelper::GetAbsolutePath("\\.easy");
Json::Value value;
m_recent_menu->StoreToFile(value);
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filename.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:12,代码来源:Frame.cpp
示例11: store
void EShapeFileAdapter::store(const char* filename)
{
Json::Value value;
for (size_t i = 0, n = m_shapes.size(); i < n; ++i)
value["shapes"][i] = store(m_shapes[i]);
Json::StyledStreamWriter writer;
std::ofstream fout(filename);
writer.write(fout, value);
fout.close();
}
开发者ID:bigstupidx,项目名称:drag2d,代码行数:12,代码来源:EShapeFileAdapter.cpp
示例12: Store
void FileIO::Store(const char* filename, LibraryPanel* library,
StagePanel* stage, ee::GroupTreePanel* grouptree)
{
Json::Value value;
SettingCfg* cfg = SettingCfg::Instance();
std::string dir = ee::FileHelper::GetFileDir(filename) + "\\";
// settings
value["settings"]["terrain2d"] = cfg->m_terrain2d_anim;
// size
value["size"]["width"] = cfg->m_map_width;
value["size"]["height"] = cfg->m_map_height;
value["size"]["view width"] = cfg->m_view_width;
value["size"]["view height"] = cfg->m_view_height;
value["size"]["view offset x"] = cfg->m_view_dx;
value["size"]["view offset y"] = cfg->m_view_dy;
// camera
auto canvas = std::dynamic_pointer_cast<ee::CameraCanvas>(stage->GetCanvas());
if (canvas->GetCamera()->Type() == s2::CAM_ORTHO2D)
{
auto cam = std::dynamic_pointer_cast<s2::OrthoCamera>(canvas->GetCamera());
value["camera"]["scale"] = cam->GetScale();
value["camera"]["x"] = cam->GetPosition().x;
value["camera"]["y"] = cam->GetPosition().y;
}
// screen
value["screen"]["multi_col"] = gum::color2str(stage->GetScreenMultiColor(), s2s::RGBA);
value["screen"]["add_col"] = gum::color2str(stage->GetScreenAddColor(), s2s::RGBA);
if (!cfg->m_post_effect_file.empty()) {
value["screen"]["post effect"] = ee::FileHelper::GetRelativePath(dir, cfg->m_post_effect_file);
}
// layers
StoreLayers(value["layer"], stage->GetLayers(), dir);
// libraries
library->StoreToFile(value["library"], dir);
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filename);
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
wxMessageBox("Success");
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:52,代码来源:FileIO.cpp
示例13: StoreToFile
void StagePanel::StoreToFile(const char* filename) const
{
std::string name = filename;
name = name.substr(0, name.find_last_of('_'));
std::string dir = ee::FileHelper::GetFileDir(filename);
// items complex
auto items_complex = std::make_shared<ecomplex::Symbol>();
std::vector<ee::SprPtr> sprs;
TraverseSprites(ee::FetchAllRefVisitor<ee::Sprite>(sprs));
for (int i = 0, n = sprs.size(); i < n; ++i) {
items_complex->Add(sprs[i]);
}
std::string items_path = name + "_items_complex[gen].json";
items_complex->SetFilepath(items_path);
ecomplex::FileStorer::Store(items_path, *items_complex, ee::FileHelper::GetFileDir(items_path));
// items_complex.InitBounding();
// wrapper complex
auto items_sprite = std::make_shared<ecomplex::Sprite>(items_complex);
items_sprite->SetName("anchor");
ecomplex::Symbol wrapper_complex;
wrapper_complex.SetScissor(m_clipbox);
wrapper_complex.Add(items_sprite);
std::string top_path = name + "_wrapper_complex[gen].json";
wrapper_complex.SetFilepath(top_path);
ecomplex::FileStorer::Store(top_path, wrapper_complex, ee::FileHelper::GetFileDir(top_path));
// ui
std::string ui_path = filename;
Json::Value value;
value["type"] = get_widget_desc(ID_WRAPPER);
value["items filepath"] = ee::FileHelper::GetRelativePath(dir, items_path);
value["wrapper filepath"] = ee::FileHelper::GetRelativePath(dir, top_path);
value["user type"] = m_toolbar->GetType();
value["tag"] = m_toolbar->GetTag();
sm::vec2 cb_sz = m_clipbox.Size();
value["clipbox"]["w"] = cb_sz.x;
value["clipbox"]["h"] = cb_sz.y;
value["clipbox"]["x"] = m_clipbox.xmin;
value["clipbox"]["y"] = m_clipbox.ymax;
sm::vec2 c_sz = items_sprite->GetBounding().GetSize().Size();
value["children"]["w"] = c_sz.x;
value["children"]["h"] = c_sz.y;
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(ui_path.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:52,代码来源:StagePanel.cpp
示例14: StoreToFile
void FileIO::StoreToFile(const char* filepath, const std::shared_ptr<Symbol>& sym)
{
Json::Value value;
sym->GetShadow()->StoreToFile(value);
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(filepath);
std::locale::global(std::locale("C"));
writer.write(fout, value);
fout.close();
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:13,代码来源:FileIO.cpp
示例15: copy
//----------
void Patch::copy() {
auto selection = this->selection.lock();
if (selection) {
//get the json
Json::Value json;
selection->serialize(json);
//push to clipboard
stringstream jsonString;
Json::StyledStreamWriter styledWriter;
styledWriter.write(jsonString, json);
ofxClipboard::copy(jsonString.str());
}
}
开发者ID:theomission,项目名称:ofxRulr,代码行数:15,代码来源:Patch.cpp
示例16: createProfile
void createProfile(const string& mName)
{
ofstream o{"Profiles/" + mName + ".json"};
Json::Value root;
Json::StyledStreamWriter writer;
root["name"] = mName;
root["scores"] = Json::objectValue;
writer.write(o, root);
o.flush(); o.close();
profileDataMap.clear();
loadProfiles();
}
开发者ID:richo,项目名称:SSVOpenHexagon,代码行数:14,代码来源:Assets.cpp
示例17: output_stats
void output_stats(
const char* path,
const dex_output_stats_t& stats,
const std::vector<dex_output_stats_t> &dexes_stats,
PassManager& mgr) {
Json::Value d;
d["total_stats"] = get_stats(stats);
d["dexes_stats"] = get_detailed_stats(dexes_stats);
d["pass_stats"] = get_pass_stats(mgr);
Json::StyledStreamWriter writer;
std::ofstream out(path);
writer.write(out, d);
out.close();
}
开发者ID:monitai,项目名称:redex,代码行数:14,代码来源:main.cpp
示例18: saveCurrentProfile
void saveCurrentProfile()
{
if(currentProfilePtr == nullptr) return;
Json::StyledStreamWriter writer;
ofstream o{getCurrentProfileFilePath(), std::ifstream::binary};
Json::Value profileRoot;
profileRoot["version"] = getVersion();
profileRoot["name"] = getCurrentProfile().getName();
profileRoot["scores"] = getCurrentProfile().getScores();
for(const auto& n : getCurrentProfile().getTrackedNames()) profileRoot["trackedNames"].append(n);
writer.write(o, profileRoot); o.flush(); o.close();
}
开发者ID:richo,项目名称:SSVOpenHexagon,代码行数:15,代码来源:Assets.cpp
示例19: Run
void LRSeparateComplex::Run(const std::string& filepath)
{
Json::Value lr_val;
Json::Reader reader;
std::locale::global(std::locale(""));
std::ifstream fin(filepath.c_str());
std::locale::global(std::locale("C"));
reader.parse(fin, lr_val);
fin.close();
Json::Value new_lr_val = lr_val;
m_dir = ee::FileHelper::GetFileDir(filepath);
std::string dst_folder = m_output_dir;
ee::FileHelper::MkDir(dst_folder, false);
for (int layer_idx = 0; layer_idx < 9; ++layer_idx)
{
// shape layer
if (layer_idx == 4 || layer_idx == 5 || layer_idx == 6) {
continue;
}
const Json::Value& src_layer_val = lr_val["layer"][layer_idx];
Json::Value& dst_layer_val = new_lr_val["layer"][layer_idx];
SeparateFromSprites(src_layer_val, dst_layer_val);
int idx = 0;
Json::Value cl_val = src_layer_val["layers"][idx++];
while (!cl_val.isNull()) {
SeparateFromSprites(cl_val, dst_layer_val["layers"][idx - 1]);
cl_val = src_layer_val["layers"][idx++];
}
}
std::string outfile = dst_folder + "\\" + m_output_name;
Json::StyledStreamWriter writer;
std::locale::global(std::locale(""));
std::ofstream fout(outfile.c_str());
std::locale::global(std::locale("C"));
writer.write(fout, new_lr_val);
fout.close();
}
开发者ID:xzrunner,项目名称:easyeditor,代码行数:46,代码来源:LRSeparateComplex.cpp
示例20: SaveProgress
void ArtificialPlayer::SaveProgress(char const * File)
{
for (uint32_t i = 0; i < ga->nXH; i++) { (*Root)["NeuralData"]["W"]["xh"][i] = ga->W_xh[i]; }
for (uint32_t i = 0; i < ga->nHH; i++) { (*Root)["NeuralData"]["W"]["hh"][i] = ga->W_hh[i]; }
for (uint32_t i = 0; i < ga->nHY; i++) { (*Root)["NeuralData"]["W"]["hy"][i] = ga->W_hy[i]; }
for (uint32_t j = 0, i = 0; j < (*Root)["NeuralData"]["Number"].asUInt(); j++, i += (*Root)["NeuralData"]["Layout"][2*j+1].asUInt()) {
for (uint32_t k = 0; k < (*Root)["NeuralData"]["Layout"][2*j+1].asUInt(); k++) {
(*Root)["NeuralData"]["Memory"][i+k] = ga->GetChromosomes()[0]->NNs[j].h[k];
}
}
Json::StyledStreamWriter writer;
std::ofstream savefile(File);
writer.write(savefile, *Root);
savefile.close();
}
开发者ID:Milias,项目名称:NeuralSnake,代码行数:17,代码来源:ap.cpp
注:本文中的json::StyledStreamWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论