本文整理汇总了C++中options_description::options方法的典型用法代码示例。如果您正苦于以下问题:C++ options_description::options方法的具体用法?C++ options_description::options怎么用?C++ options_description::options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options_description
的用法示例。
在下文中一共展示了options_description::options方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
basic_parsed_options<charT>
parse_config_file(std::basic_istream<charT>& is,
const options_description& desc,
bool allow_unregistered)
{
set<string> allowed_options;
const vector<shared_ptr<option_description> >& options = desc.options();
for (unsigned i = 0; i < options.size(); ++i)
{
const option_description& d = *options[i];
if (d.long_name().empty())
pdalboost::throw_exception(
error("long name required for config file"));
allowed_options.insert(d.long_name());
}
// Parser return char strings
parsed_options result(&desc);
copy(detail::basic_config_file_iterator<charT>(
is, allowed_options, allow_unregistered),
detail::basic_config_file_iterator<charT>(),
back_inserter(result.options));
// Convert char strings into desired type.
return basic_parsed_options<charT>(result);
}
示例2: get_section_options
options_description get_section_options(const string section_name, const string group_caption, const options_description &original_options_descriptions)
{
const std::vector< shared_ptr<option_description> >&original_options = original_options_descriptions.options();
options_description new_options(group_caption.c_str());
std::vector< shared_ptr<option_description> >::const_iterator options_it;
for(options_it = original_options.begin(); options_it != original_options.end(); ++options_it)
{
const option_description &t_option = *(*options_it);
string new_name(section_name + ".");
new_name += t_option.long_name();
// IMPORTANT: in order for this line not to crash the original_options_descriptions needs to be a static declaration
// otherwise t_option.semantic().get() will point to an invalid memory direction and
// the application will raise a segmentation fault
new_options.add_options()
(new_name.c_str(), t_option.semantic().get(), t_option.description().c_str());
}
return new_options;
}
示例3: result
basic_parsed_options<charT>
parse_xml(const options_description& desc) {
using boost::shared_ptr;
set<string> allowed_options;
const vector<shared_ptr<option_description> >& options = desc.options();
for (unsigned i = 0; i < options.size(); ++i) {
const option_description& d = *options[i];
if (d.long_name().empty())
boost::throw_exception(
error("long name required for config file"));
allowed_options.insert(d.long_name());
}
// Parser return char strings
parsed_options result(&desc);
result.options.push_back(basic_option<charT>("my_double", vector<string>(1, "10.1214")));
//result.options.push_back(basic_option<charT>("my_string", vector<string>(1, "hello world")));
return basic_parsed_options<charT>(result);
}