本文整理汇总了C++中json::StyledStreamWriter类的典型用法代码示例。如果您正苦于以下问题:C++ StyledStreamWriter类的具体用法?C++ StyledStreamWriter怎么用?C++ StyledStreamWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StyledStreamWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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();
}
示例3: saveScores
void saveScores()
{
Json::StyledStreamWriter writer;
ofstream test("scores.json", std::ifstream::binary);
writer.write(test, scoreRoot);
}
示例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();
}
}
}
示例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);
}
示例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());
}
示例7: useStyledStreamWriter
static std::string useStyledStreamWriter(
Json::Value const& root)
{
Json::StyledStreamWriter writer;
std::ostringstream sout;
writer.write(sout, root);
return sout.str();
}
示例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);
}
示例9: useStyledStreamWriter
static JSONCPP_STRING useStyledStreamWriter(
Json::Value const& root)
{
Json::StyledStreamWriter writer;
JSONCPP_OSTRINGSTREAM sout;
writer.write(sout, root);
return sout.str();
}
示例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();
}
示例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();
}
示例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");
}
示例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();
}
示例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();
}
示例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());
}
}