예제 #1
0
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
0
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
0
	void saveScores()
	{
		Json::StyledStreamWriter writer;
		ofstream test("scores.json", std::ifstream::binary);

		writer.write(test, scoreRoot);
	}
예제 #4
0
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
0
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
0
			//----------
			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
0
static std::string useStyledStreamWriter(
    Json::Value const& root)
{
  Json::StyledStreamWriter writer;
  std::ostringstream sout;
  writer.write(sout, root);
  return sout.str();
}
예제 #8
0
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
0
파일: main.cpp 프로젝트: 151706061/jsoncpp
static JSONCPP_STRING useStyledStreamWriter(
    Json::Value const& root)
{
  Json::StyledStreamWriter writer;
  JSONCPP_OSTRINGSTREAM sout;
  writer.write(sout, root);
  return sout.str();
}
예제 #10
0
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
0
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
0
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
0
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
0
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
0
			//----------
			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());
				}
			}
예제 #16
0
	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();
	}
예제 #17
0
파일: main.cpp 프로젝트: monitai/redex
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();
}
예제 #18
0
	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();
	}
예제 #19
0
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();
}
예제 #20
0
파일: ap.cpp 프로젝트: Milias/NeuralSnake
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();
}
예제 #21
0
    bool ConfigSerializer::serialize(const Config &cfg, std::ostream &os)
    {
        Json::StyledStreamWriter writer;
        Json::Value root;

        root["generationCount"] = cfg.generationCount;
        root["graphFile"] = cfg.graphFile;
        root["pathFile"] = cfg.pathFile;
        root["populationSize"] = cfg.gaSettings.populationSize;
        root["startNode"] = cfg.gaSettings.startNode;
        root["elitismRate"] = cfg.gaSettings.elitismRate;
        root["fitnessPower"] = cfg.gaSettings.fitnessPow;
        root["mutationChance"] = cfg.gaSettings.mutationChance;
        root["exchangeRate"] = cfg.exchangeRate;

        writer.write(os, root);

        return true;
    }
예제 #22
0
	void InformationMgr::serialize() const {
		Json::Value root;

		for (auto instru : m_InfoDict){
			Json::Value instru_info;
			Json::Value instru_basic_info, margin_info, commission_info;
			
			instru_basic_info[kInstrumentID] = instru.second.InstruField.InstrumentID;
			instru_basic_info[kExchangeID] = instru.second.InstruField.ExchangeID;
			instru_basic_info[kDeliveryYear] = instru.second.InstruField.DeliveryYear;
			instru_basic_info[kDeliveryMonth] = instru.second.InstruField.DeliveryMonth;
			instru_basic_info[kVolumeMultiple] = instru.second.InstruField.VolumeMultiple;
			instru_basic_info[kOpenDate] = instru.second.InstruField.OpenDate;
			instru_basic_info[kExpireDate] = instru.second.InstruField.ExpireDate;
			instru_basic_info[kIsTrading] = instru.second.InstruField.IsTrading;
			instru_basic_info[kPositionType] = instru.second.InstruField.PositionType;

			margin_info[kBrokerID] = instru.second.MgrRateField.BrokerID;
			margin_info[kInvestorID] = instru.second.MgrRateField.InvestorID;
			margin_info[kHedgeFlag] = instru.second.MgrRateField.HedgeFlag;
			margin_info[kLongMarginRatioByMoney] = instru.second.MgrRateField.LongMarginRatioByMoney;
			margin_info[kLongMarginRatioByVolume] = instru.second.MgrRateField.LongMarginRatioByVolume;
			margin_info[kShortMarginRatioByMoney] = instru.second.MgrRateField.ShortMarginRatioByMoney;
			margin_info[kShortMarginRatioByVolume] = instru.second.MgrRateField.ShortMarginRatioByVolume;

			commission_info[kOpenRatioByMoney] = instru.second.ComRateField.OpenRatioByMoney;
			commission_info[kOpenRatioByVolume] = instru.second.ComRateField.OpenRatioByVolume;
			commission_info[kCloseRatioByMoney] = instru.second.ComRateField.CloseRatioByMoney;
			commission_info[kCloseRatioByVolume] = instru.second.ComRateField.CloseRatioByVolume;
			commission_info[kCloseTodayRatioByMoney] = instru.second.ComRateField.CloseTodayRatioByMoney;
			commission_info[kCloseTodayRatioByVolume] = instru.second.ComRateField.CloseTodayRatioByVolume;

			instru_info[kBasicInfo] = instru_basic_info;
			instru_info[kMarginInfo] = margin_info;
			instru_info[kCommissionInfo] = commission_info;

			root[instru.first] = instru_info;
		}
		std::ofstream out_json_file(FactorSettingFilePath);
		Json::StyledStreamWriter writer;
		writer.write(out_json_file, root);
		out_json_file.close();
	}
예제 #23
0
void ChangeComplexOrigin::FixLR(const std::string& path) const
{
	std::string filepath = ee::FileHelper::GetAbsolutePath(path);

	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();

	bool dirty = false;

	Json::Value& layer_val = value["layer"];
	for (int i = 0, n = layer_val.size(); i < n; ++i) {
		Json::Value& spr_val = layer_val[i]["sprite"];
		for (int j = 0, m = spr_val.size(); j < m; ++j) {
			std::string filepath = spr_val[j]["filepath"].asString();
			if (filepath == ee::SYM_GROUP_TAG) {
				Json::Value& group_val = spr_val[j][ee::SYM_GROUP_TAG];
				for (int i = 0, n = group_val.size(); i < n; ++i) {
					if (FixLRSpr(group_val[i])) {
						dirty = true;
					}
				}
			} else {
				if (FixLRSpr(spr_val[j])) {
					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, value);
		fout.close();
	}
}
예제 #24
0
void ChangeTPJsonFile::TranslateFrameXY(int dx, int dy)
{
	for (int i = 0, n = m_files.size(); i < n; ++i)
	{
		std::string filepath = ee::FileHelper::GetAbsolutePath(m_files[i].ToStdString());
		std::string ext = ee::FileHelper::GetExtension(filepath);
		if (ext != "json") {
			continue;
		}

		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();

		if (!check_json_key(value, "frames", filepath)) break;

 		int j = 0;
 		Json::Value itemValue = value["frames"][j++];
 		while (!itemValue.isNull()) {
			if (!check_json_key(itemValue, "frame", filepath)) break;
			if (!check_json_key(itemValue["frame"], "x", filepath)) break;
			if (!check_json_key(itemValue["frame"], "y", filepath)) break;

 			int x = itemValue["frame"]["x"].asInt();
 			int y = itemValue["frame"]["y"].asInt();
   			value["frames"][j-1]["frame"]["x"] = x + dx;
   			value["frames"][j-1]["frame"]["y"] = y + dy;
 			itemValue = value["frames"][j++];
 		}

		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();
	}
}
예제 #25
0
void FileSaver::StoreSingle(const std::string& filepath)
{
	Json::Value value;

	value["name"] = DataMgr::Instance()->name;
	value["fps"] = GetFpsSJ::Instance()->Get();

	std::string dir = ee::FileHelper::GetFileDir(filepath);

	LayersMgr& layers = DataMgr::Instance()->GetLayers();
	for (size_t i = 0, n = layers.Size(); i < n; ++i) {
		value["layer"][i] = StoreLayer(layers.GetLayer(i), dir, true);
	}

	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();
}
예제 #26
0
void FixLRSprLayer::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());
		if (filepath.find("_lr.json") == std::string::npos) {
			continue;
		}

		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["layer"].size(); i < n; ++i) {
			Json::Value& layer_val = val["layer"][i];
			for (int j = 0, m = layer_val["sprite"].size(); j < m; ++j) {
				if (FixSprite(layer_val["sprite"][j])) {
					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();
		}
	}
}
예제 #27
0
std::string LRSeparateComplex::CreateNewComplexFile(const Json::Value& value) const
{
	std::string name = std::string("name_") + ee::StringHelper::ToString(m_count++);

	Json::Value out_val;

	out_val["name"] = name;
	out_val["use_render_cache"] = false;
	out_val["xmin"] = 0;
	out_val["xmax"] = 0;
	out_val["ymin"] = 0;
	out_val["ymax"] = 0;

	Json::Value spr_val = value;

	std::string relative_path = ee::FileHelper::GetRelativePath(m_output_dir, 
		m_dir + "\\" + spr_val["filepath"].asString());
	spr_val["filepath"] = relative_path;

	std::string dir = ee::FileHelper::GetFileDir(relative_path);

	ee::SpriteIO spr_io;
	spr_io.Load(spr_val, dir.c_str());
	FixPosWithShape(spr_io.m_position, value["filepath"].asString());
	int idx = 0;
	out_val["sprite"][idx] = spr_val;
	spr_io.Store(out_val["sprite"][idx], dir.c_str());

	std::string outpath = m_output_dir + "\\" + name + "_complex.json";
	Json::StyledStreamWriter writer;
	std::locale::global(std::locale(""));
	std::ofstream fout(outpath.c_str());
	std::locale::global(std::locale("C"));
	writer.write(fout, out_val);
	fout.close();

	return name;
}
예제 #28
0
void Config::saveConfiguration()
{
	Json::Value root;
	Json::Reader reader;
	Json::StyledStreamWriter writer;
	ifstream config_file_i(CONFIG_FILE_NAME);

	bool parsing_successful = reader.parse(config_file_i, root, false);
	if (!parsing_successful)
	{
		// cout  << reader.getFormatedErrorMessages() << endl;
	}
	root["fullscreen"] = m_fullscreen;
	root["music"] = m_music;
	root["map_sensivity"] = m_map_sensivity;
	root["music_volume"] = m_audio_volume;
	root["sounds_effects"] = m_sounds_effects;
	// root["music_volume"] =
	ofstream config_file_o(CONFIG_FILE_NAME);
    writer.write(config_file_o, root);
	config_file_i.close();
	config_file_o.close();
}
void c_CfgEsriGS_FeatureServer::WriteToJson( std::ostream& Out ,bool Pretty ) const
{
  Json::Value root_val(Json::objectValue);

  { 
    root_val["layers"] = Json::Value(Json::arrayValue); 
    t_c_CfgEsriGS_FServer_LayerVector::const_iterator iter;
    for ( iter = m_Layers.begin( ) ; iter != m_Layers.end( ) ; iter++ )
    {
      c_CfgEsriGS_FServer_Layer * datalayer = *iter;
      std::string name;
      Json::Value layer_val(Json::objectValue);
      Poco::UnicodeConverter::toUTF8(datalayer->m_Name,name);
      layer_val["name"] = name;
      layer_val["id"] = datalayer->m_Id;
      
      root_val["layers"].append(layer_val);
    }

  }

  
  if( Pretty )    
  {
    Json::StyledStreamWriter sswrite;

    sswrite.write(Out,root_val);
  }
  else
  {
    Json::FastWriter fwrite;

    std::string outstr = fwrite.write(root_val);
    Out << outstr;
  }

}
예제 #30
0
void RectCutCMPT::OnSaveEditOP(wxCommandEvent& event)
{
	wxFileDialog dlg(this, wxT("Save"), wxEmptyString, wxEmptyString, 
		wxT("*_") + FILTER + wxT(".json"), wxFD_SAVE);
	if (dlg.ShowModal() == wxID_OK)
	{
		auto op = std::dynamic_pointer_cast<RectCutOP>(m_editop);

		Json::Value value;

		std::string filepath = op->GetImageFilepath();
		std::string dir = ee::FileHelper::GetFileDir(dlg.GetPath().ToStdString());
		value["image filepath"] = ee::FileHelper::GetRelativePath(dir, filepath);
		op->GetRectMgr().Store(value);

		const sm::vec2& center = op->GetCenter();
		value["center"]["x"] = center.x;
		value["center"]["y"] = center.y;

		for (int i = 0, n = m_part_rects.size(); i < n; ++i) {
			const sm::rect& r = m_part_rects[i];
			value["part_rect"][i]["xmin"] = r.xmin;
			value["part_rect"][i]["xmax"] = r.xmax;
			value["part_rect"][i]["ymin"] = r.ymin;
			value["part_rect"][i]["ymax"] = r.ymax;
		}

		std::string filename = ee::FileHelper::GetFilenameAddTag(dlg.GetPath().ToStdString(), FILTER, "json");
		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();
	}
}