• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中config的典型用法代码示例。如果您正苦于以下问题:C++ config类的具体用法?C++ config怎么用?C++ config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: get_node

bool persist_file_context::set_var(const std::string &global,const config &val, bool immediate)
{
	config bak;
	config bactive;
	if (immediate) {
		bak = cfg_;
		bactive = get_node(bak, namespace_, true)->child_or_add("variables");
		load();
	}

	config *active = get_node(cfg_, namespace_, true);
	config &cfg = active->child_or_add("variables");
	if (val.has_attribute(global)) {
		if (val[global].empty()) {
			clear_var(global,immediate);
		} else {
			cfg[global] = val[global];
			if (immediate) bactive[global] = val[global];
		}
	} else {
		cfg.clear_children(global);
		cfg.append(val);
		if (immediate) {
			bactive.clear_children(global);
			bactive.append(val);
		}
	}
//	dirty_ = true;
	if (!in_transaction_)
		return save_context();
	else if (immediate) {
		bool ret = save_context();
		cfg_ = bak;
		active = get_node(cfg_, namespace_, true);
		active->clear_children("variables");
		active->remove_attribute("variables");
		active->add_child("variables",bactive);
		return ret;
	} else
		return true;
}
开发者ID:Martin9295,项目名称:wesnoth,代码行数:41,代码来源:persist_context.cpp


示例2: id

tcontrol_definition::tcontrol_definition(const config& cfg)
	: id(cfg["id"])
	, description(cfg["description"].t_str())
	, resolutions()
{
/*WIKI
 * @page = GUIWidgetDefinitionWML
 * @order = 1
 *
 * {{Autogenerated}}
 *
 * = Widget definition =
 *
 * This page describes the definition of all widgets in the toolkit. Every
 * widget has some parts in common, first of all; every definition has the
 * following fields.
 * @begin{parent}{name="generic/"}
 * @begin{tag}{name=widget_definition}{min=0}{max=1}
 * @begin{table}{config}
 *     id & string & &               Unique id for this gui (theme). $
 *     description & t_string & &    Unique translatable name for this gui. $
 *
 *     resolution & section & &      The definitions of the widget in various
 *                                   resolutions. $
 * @end{table}
 * @end{tag}{name=widget_definition}
 * @end{parent}{name="generic/"}
 */

	VALIDATE(!id.empty(), missing_mandatory_wml_key("control", "id"));
	VALIDATE(!description.empty()
			, missing_mandatory_wml_key("control", "description"));

	/*
	 * Do this validation here instead of in load_resolutions so the
	 * translatable string is not in the header and we don't need to pull in
	 * extra header dependencies.
	 */
	config::const_child_itors itors = cfg.child_range("resolution");
	VALIDATE(itors.first != itors.second, _("No resolution defined."));
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:41,代码来源:widget_definition.cpp


示例3: set_living

/*
 * Set the initial 'alive' cells.
 * 
 * INPUT: &cnfg Config file to store initial 'alive' cells
 */
void reader::set_living(config &cnfg)
{
	int start, end;

	// Check if the keyword exists
	start = data.find("Initial");
	if (start == string::npos || start >= data.size()) return; 

	// Find the start and end index of the "Initial" statement
	start = data.find("{", start+7);
	end = data.find("}", start+1);
	// Make sure a complete statement exists
	if (start == string::npos || start >= data.size() || end == string::npos || end >= data.size()) return;	

	int x, y;
	bool done = false;
	istringstream stream(data.substr(start, end-start+1));
	
	while (stream.good()) {
		// Find the next 'Y' char
		if (stream.peek() == 'Y') {
			done = false;

			// Process the column of alive cells (current row in .aut file)
			while (!done) {
				// Grab the y coordinate
				if (isdigit(stream.peek()) || stream.peek() == '-') {
					stream >> y;

					// Grab the x coordinates
					while (1) {
						if (isdigit(stream.peek()) || stream.peek() == '-') {
							stream >> x;	
							cnfg.add(x, y);
						}
						else if (stream.peek() == ';') break;
						else stream.get();
					} // End x coordinates

					done = true;
				}
开发者ID:argrieve,项目名称:game_of_life,代码行数:46,代码来源:reader.cpp


示例4: enter_connect_mode

static void enter_connect_mode(game_display& disp, const config& game_config,
                               mp::chat& chat, config& gamelist, const mp_game_settings& params,
                               const int num_turns, mp::controller default_controller, bool local_players_only = false)
{
    mp::ui::result res;
    game_state state;
    const network::manager net_manager(1,1);
    network_game_manager m;

    gamelist.clear();
    statistics::fresh_stats();

    {
        mp::connect ui(disp, game_config, chat, gamelist, params, num_turns, default_controller, local_players_only);
        run_lobby_loop(disp, ui);

        res = ui.get_result();

        // start_game() updates the parameters to reflect game start,
        // so it must be called before get_level()
        if (res == mp::ui::PLAY) {
            ui.start_game();
            state = ui.get_state();
        }
    }

    switch (res) {
    case mp::ui::PLAY:
        play_game(disp, state, game_config, IO_SERVER);
        recorder.clear();

        break;
    case mp::ui::CREATE:
        enter_create_mode(disp, game_config, chat, gamelist, default_controller, local_players_only);
        break;
    case mp::ui::QUIT:
    default:
        network::send_data(config("refresh_lobby"), 0);
        break;
    }
}
开发者ID:aelthwin,项目名称:Battle-for-Wesnoth--Zombie-Edition,代码行数:41,代码来源:multiplayer.cpp


示例5: best_slider_length_

builder_slider::builder_slider(const config& cfg)
    : implementation::builder_styled_widget(cfg)
    , best_slider_length_(cfg["best_slider_length"])
    , minimum_value_(cfg["minimum_value"])
    , maximum_value_(cfg["maximum_value"])
    , step_size_(cfg["step_size"])
    , value_(cfg["value"])
    , minimum_value_label_(cfg["minimum_value_label"].t_str())
    , maximum_value_label_(cfg["maximum_value_label"].t_str())
    , value_labels_()
{
    const config& labels = cfg.child("value_labels");
    if(!labels) {
        return;
    }

    for(const auto & label : labels.child_range("value"))
    {
        value_labels_.push_back(label["label"]);
    }
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:21,代码来源:slider.cpp


示例6:

timage_definition::tresolution::tresolution(const config& cfg)
	: tresolution_definition_(cfg)
{
/*WIKI
 * @page = GUIWidgetDefinitionWML
 * @order = 1_image
 *
 * == Image ==
 *
 * @macro = image_description
 *
 * The definition of an image. The label field of the widget is used as the
 * name of file to show. The widget normally has no event interaction so only
 * one state is defined.
 *
 * The following states exist:
 * * state_enabled, the image is enabled.
 */
	// Note the order should be the same as the enum tstate in image.hpp.
	state.push_back(tstate_definition(cfg.child("state_enabled")));
}
开发者ID:aelthwin,项目名称:Battle-for-Wesnoth--Zombie-Edition,代码行数:21,代码来源:image.cpp


示例7: convert_old_saves_1_11_0

//changes done during 1.11.0-dev
static void convert_old_saves_1_11_0(config& cfg)
{
	if(!cfg.has_child("snapshot")){
		return;
	}

	const config& snapshot = cfg.child("snapshot");
	const config& replay_start = cfg.child("replay_start");
	const config& replay = cfg.child("replay");

	if(!cfg.has_child("carryover_sides") && !cfg.has_child("carryover_sides_start")){
		config carryover;
		//copy rng and menu items from toplevel to new carryover_sides
		carryover["random_seed"] = cfg["random_seed"];
		carryover["random_calls"] = cfg["random_calls"];
		BOOST_FOREACH(const config& menu_item, cfg.child_range("menu_item")){
			carryover.add_child("menu_item", menu_item);
		}
		carryover["difficulty"] = cfg["difficulty"];
		carryover["random_mode"] = cfg["random_mode"];
		//the scenario to be played is always stored as next_scenario in carryover_sides_start
		carryover["next_scenario"] = cfg["scenario"];

		config carryover_start = carryover;

		//copy sides from either snapshot or replay_start to new carryover_sides
		if(!snapshot.empty()){
			BOOST_FOREACH(const config& side, snapshot.child_range("side")){
				carryover.add_child("side", side);
			}
			//for compatibility with old savegames that use player instead of side
			BOOST_FOREACH(const config& side, snapshot.child_range("player")){
				carryover.add_child("side", side);
			}
			//save the sides from replay_start in carryover_sides_start
			BOOST_FOREACH(const config& side, replay_start.child_range("side")){
				carryover_start.add_child("side", side);
			}
			//for compatibility with old savegames that use player instead of side
			BOOST_FOREACH(const config& side, replay_start.child_range("player")){
				carryover_start.add_child("side", side);
			}
		} else if (!replay_start.empty()){
开发者ID:pax2you4now,项目名称:wesnoth,代码行数:44,代码来源:savegame.cpp


示例8: gamedata_

game_state::game_state(const config & level, play_controller & pc, game_board& board) :
	gamedata_(level),
	board_(board),
	tod_manager_(level),
	pathfind_manager_(new pathfind::manager(level)),
	reports_(new reports()),
	lua_kernel_(new game_lua_kernel(NULL, *this, pc, *reports_)),
	events_manager_(new game_events::manager()),
	player_number_(level["playing_team"].to_int() + 1),
	end_level_data_(),
	init_side_done_(level["init_side_done"].to_bool(false)),
	first_human_team_(-1)
{
	events_manager_->read_scenario(level);
	if(const config& endlevel_cfg = level.child("end_level_data")) {
		end_level_data el_data;
		el_data.read(endlevel_cfg);
		el_data.transient.carryover_report = false;
		end_level_data_ = el_data;
	}
}
开发者ID:sunny975,项目名称:wesnoth,代码行数:21,代码来源:game_state.cpp


示例9: angular

      matrix<math::real, 3>  angular(const rigid::skeleton& skel, const config& at) {
	const natural n = skel.size();
	assert( at.rows() == n );
      
	mat res = mat::Zero(3, 6*n);
	
	const vec3 c = com(skel) ( at );
	
	skel.each( [&](math::natural i) {
	    res.block<3, 3>(0, 6*i) = at(i).rotation().matrix() * skel.topology[i].inertia.asDiagonal();
	  
	    const vec3 ri = at(i).translation()  - c;
	  
	    res.block<3, 3>(0, 6*i + 3) = skel.topology[i].mass * math::hat( ri )
	      * at(i).rotation().matrix();
	  });
      
      
	return std::move(res);

      }
开发者ID:Jorjor70,项目名称:meuh,代码行数:21,代码来源:momentum.cpp


示例10: get_text

std::vector<std::string> get_text(const std::string &campaign, bool split_multiline_headers)
{
	std::vector< std::string > res;

	config::child_itors about_entries = about_list.child_range("about");

	if (!campaign.empty()) {
		for (const config &about : about_entries) {
			// just finished a particular campaign
			if (campaign == about["id"]) {
				add_lines(res, about, split_multiline_headers);
			}
		}
	}

	for (const config &about : about_entries) {
		add_lines(res, about, split_multiline_headers);
	}

	return res;
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:21,代码来源:about.cpp


示例11: object

theme::status_item::status_item(const config& cfg) :
	object(cfg),
	prefix_(cfg["prefix"] + cfg["prefix_literal"]),
	postfix_(cfg["postfix_literal"] + cfg["postfix"]),
	label_(),
	font_(atoi(cfg["font_size"].c_str())),
	font_rgb_set_(false),
	font_rgb_(DefaultFontRGB)
{
	if(font_ == 0)
		font_ = DefaultFontSize;

	const config* const label_child = cfg.child("label");
	if(label_child != NULL) {
		label_ = label(*label_child);
	}

	if(cfg["font_rgb"].size()){
	  std::vector<std::string> rgb_vec = utils::split(cfg["font_rgb"]);
	  if(3 <= rgb_vec.size()){
	    std::vector<std::string>::iterator c=rgb_vec.begin();
	    int r,g,b;
	    r = (atoi(c->c_str()));
	    c++;
	    if(c != rgb_vec.end()){
	      g = (atoi(c->c_str()));
	    }else{
	      g=0;
	    }
	    c++;
	    if(c != rgb_vec.end()){
	      b=(atoi(c->c_str()));
	    }else{
	      b=0;
	    }
	    font_rgb_ = (((r<<16) & 0x00FF0000) + ((g<<8) & 0x0000FF00) + ((b) & 0x000000FF));
	    font_rgb_set_=true;
	  }
	}
}
开发者ID:dodikk,项目名称:iWesnoth,代码行数:40,代码来源:theme.cpp


示例12: id

tcontrol_definition::tcontrol_definition(const config& cfg) :
	id(cfg["id"]),
	description(cfg["description"]),
	resolutions()
{

/*WIKI
 * @page = GUIWidgetDefinitionWML
 * @order = 1
 *
 * THIS PAGE IS AUTOMATICALLY GENERATED, DO NOT MODIFY DIRECTLY !!!
 *
 * = Widget definition =
 *
 * This page describes the definition of all widgets in the toolkit. Every
 * widget has some parts in common, first of all every definition has the
 * following fields.
 *
 * @start_table = config
 *     id (string)                   Unique id for this gui (theme).
 *     description (t_string)        Unique translatable name for this gui.
 *
 *     resolution (section)          The definitions of the widget in various
 *                                   resolutions.
 * @end_table
 *
 */

	VALIDATE(!id.empty(), missing_mandatory_wml_key("gui", "id"));
	VALIDATE(!description.empty()
			, missing_mandatory_wml_key("gui", "description"));

	/*
	 * Do this validation here instead of in load_resolutions so the
	 * translatable string is not in the header and we don't need to pull in
	 * extra header dependencies.
	 */
	config::const_child_itors itors = cfg.child_range("resolution");
	VALIDATE(itors.first != itors.second, _("No resolution defined."));
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:40,代码来源:widget_definition.cpp


示例13: level_to_gamestate

void level_to_gamestate(const config& level, saved_game& state)
{
    game_classification::CAMPAIGN_TYPE type = state.classification().campaign_type;
    bool show_connect = state.mp_settings().show_connect;
    state = saved_game(level);
    state.classification().campaign_type = type;
    state.mp_settings().show_connect = show_connect;
    // Any replay data is only temporary and should be removed from
    // the level data in case we want to save the game later.
    if (const config& replay_data = level.child("replay"))
    {
        LOG_NW << "setting replay\n";
        recorder = replay(replay_data);
        if (!recorder.empty()) {
            recorder.set_skip(false);
            recorder.set_to_end();
        }
    }


    //save id setting  was moved to play_controller.
}
开发者ID:Kanac,项目名称:wesnoth,代码行数:22,代码来源:mp_game_utils.cpp


示例14: tresolution_definition_

tstacked_widget_definition::tresolution::tresolution(const config& cfg)
	: tresolution_definition_(cfg)
	, grid(NULL)
{
/*WIKI
 * @page = GUIWidgetDefinitionWML
 * @order = 1_stacked_widget
 *
 * == Multi page ==
 *
 * The documentation is not written yet.
 */

	// Add a dummy state since every widget needs a state.
	static config dummy ("draw");
	state.push_back(tstate_definition(dummy));

	const config &child = cfg.child("grid");
	VALIDATE(child, _("No grid defined."));

	grid = new tbuilder_grid(child);
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:22,代码来源:stacked_widget.cpp


示例15: init_textdomains

void init_textdomains(const config& cfg)
{
	foreach (const config &t, cfg.child_range("textdomain"))
	{
		const std::string &name = t["name"];
		const std::string &path = t["path"];

		if(path.empty()) {
			t_string::add_textdomain(name, get_intl_dir());
		} else {
			std::string location = get_binary_dir_location("", path);

			if (location.empty()) {
				//if location is empty, this causes a crash on Windows, so we
				//disallow adding empty domains
				ERR_G << "no location found for '" << path << "', skipping textdomain\n";
			} else {
				t_string::add_textdomain(name, location);
			}
		}
	}
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:22,代码来源:language.cpp


示例16: receive_data

// main thread
bool wesnothd_connection::receive_data(config& result)
{
	MPTEST_LOG;

	{
		std::lock_guard<std::mutex> lock(recv_queue_mutex_);
		if(!recv_queue_.empty()) {
			result.swap(recv_queue_.front());
			recv_queue_.pop_front();
			return true;
		}
	}

	{
		std::lock_guard<std::mutex> lock(last_error_mutex_);
		if(last_error_) {
			throw error(last_error_);
		}
	}

	return false;
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:23,代码来源:wesnothd_connection.cpp


示例17: output_test

void output_test() {
	if(!validate_configuration(cfg) ) ERROR( "Invalid configuration" );

	if(!read_input_file(initial_ens, cfg) ) {
		ERROR("you should have a tested input file");
	}

	DEBUG_OUTPUT(2, "Make a copy of ensemble for energy conservation test" );
	current_ens = initial_ens.clone();

	prepare_integrator();

	double integration_time = watch_time ( cfg.valid("interval") ? stability_test : generic_integrate );

	if(read_output_file(reference_ens,cfg)){

		// Compare with reneference ensemble for integrator verification
		double pos_diff = 0, vel_diff = 0, time_diff = 0;
		bool comparison =  compare_ensembles( current_ens, reference_ens , pos_diff, vel_diff, time_diff );

		INFO_OUTPUT(1,"\tPosition difference: " << pos_diff  << endl
			 << "\tVelocity difference: " << vel_diff  << endl
			 << "\tTime     difference: " << time_diff << endl );

		if( !comparison || pos_diff > pos_threshold || vel_diff > vel_threshold || time_diff > time_threshold ){
			INFO_OUTPUT(0, "Test failed" << endl);
			exit(1);
		}else {
			INFO_OUTPUT(0, "Test success" << endl);
		}


	}else{
		ERROR("You should provide a test output file");
	}

	INFO_OUTPUT( 1, "Integration time: " << integration_time << " ms " << std::endl);
}
开发者ID:yingz,项目名称:swarm,代码行数:38,代码来源:swarm.cpp


示例18: foreach

void tgui_definition::load_definitions(
	const std::string &definition_type, const config &cfg, const char *key)
{
	foreach (const config &d, cfg.child_range(key ? key : definition_type + "_definition"))
	{
		T* def = new T(d);

		// We assume all definitions are unique if not we would leak memory.
		assert(control_definition[definition_type].find(def->id)
			== control_definition[definition_type].end());

		control_definition[definition_type].insert(std::make_pair(def->id, def));
	}

	utils::string_map symbols;
	symbols["definition"] = definition_type;
	symbols["id"] = "default";
	t_string msg(vgettext(
		"Widget definition '$definition' doesn't contain the definition for '$id'.",
		symbols));
	VALIDATE(control_definition[definition_type].find("default")
		!= control_definition[definition_type].end(), msg);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:23,代码来源:settings.cpp


示例19: utype_anim_create_cfg

void utype_anim_create_cfg(const std::string& anim_renamed_key, const std::string& tpl_id, config& dst, const utils::string_map& symbols)
{
	typedef std::multimap<std::string, const config>::const_iterator Itor;
	std::pair<Itor, Itor> its = instance->utype_anim_tpls().equal_range(tpl_id);
	while (its.first != its.second) {
		// tpl          animation instance
		// [anim] ----> [anim_renamed_key]
		config& sub_cfg = dst.add_child(anim_renamed_key);
		if (symbols.count("offset_x")) {
			sub_cfg["offset_x"] = symbols.find("offset_x")->second;
		}
		if (symbols.count("offset_y")) {
			sub_cfg["offset_y"] = symbols.find("offset_y")->second;
		}
		const config& anim_cfg = its.first->second;
		// replace
		BOOST_FOREACH (const config::attribute &i, anim_cfg.attribute_range()) {
			sub_cfg[i.first] = utils::interpolate_variables_into_string(i.second, &symbols);
		}
		utype_anim_replace_cfg_inernal(anim_cfg, sub_cfg, symbols);
		++ its.first;
	}
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:23,代码来源:area_anim.cpp


示例20: t_string

void unit2::generate_window(config& cfg) const
{
	cfg["name"] = cell_.id;
	cfg["description"] = t_string(cell_.window.description, cell_.window.textdomain);
	if (cell_.window.orientation != gui2::twidget::auto_orientation) {
		cfg["orientation"] = gui2::orientations.find(cell_.window.orientation)->second.id;
	}

	config& res_cfg = cfg.add_child("resolution");
	res_cfg["id"] = "1024x768";
	res_cfg["width"] = "1024";
	res_cfg["height"] = "768";

	config& screen_cfg = res_cfg.add_child("screen");
	screen_cfg["id"] = "screen";
	screen_cfg["rect"] = "0,0,1024,768";

	config& border_cfg = res_cfg.add_child("main_map_border");
	generate_main_map_border(border_cfg);

	controller_.generate_linked_groups(res_cfg);
	controller_.generate_context_menus(res_cfg);
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:23,代码来源:unit2.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ config_writer类代码示例发布时间:2022-05-31
下一篇:
C++ condor_sockaddr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap