当前位置: 首页>>代码示例>>C++>>正文


C++ section::get_name方法代码示例

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


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

示例1: validate_section

	void section_schema::validate_section(section &sect, schema_mode mode) const
	{
		/*
		 * Here should be done:
		 * - check if section has proper options (compare by names) - depends on mode
		 * - for options with given schema call validate on that option
		 * - for missing options from schema (relaxed mode) add string options with
		 *   default value
		 */

		// firstly go through option schemas
		for (auto &opt : options_) {
			bool contains = sect.contains(opt->get_name());

			if (contains) {
				// even if option is not mandatory, we execute validation of option (both modes)
				opt->validate_option(sect[opt->get_name()]);
			} else if (opt->is_mandatory()) {
				// mandatory option is not present in given section (both modes)
				throw validation_exception(
					"Mandatory option '" + opt->get_name() + "' is missing in section '" + sect.get_name() + "'");
			} else {
				// option is not mandatory and not in given section
				//   => add option with default value
				sect.add_option(opt->get_name(), opt->get_default_value());
				// validate added option, so type of the value could be changed to nonstring type
				opt->validate_option(sect[opt->get_name()]);
			}
		}

		// secondly go through options
		for (auto &opt : sect) {
			bool contains = this->contains(opt.get_name());

			// if section_schema contains option everything is fine, we handled this above
			if (contains) {
				continue;
			}

			// we have strict mode and option which is not in section_schema
			if (mode == schema_mode::strict) {
				throw validation_exception("Option '" + opt.get_name() + "' not specified in schema");
			}
		}
	}
开发者ID:MartinFrancu,项目名称:dppUkol5,代码行数:45,代码来源:section_schema.cpp


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