本文整理汇总了C++中value::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ value::empty方法的具体用法?C++ value::empty怎么用?C++ value::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类value
的用法示例。
在下文中一共展示了value::empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_version
unsigned get_version(quickbook::state& state, bool using_docinfo,
value version)
{
unsigned result = 0;
if (!version.empty()) {
value_consumer version_values(version);
bool before_docinfo = version_values.optional_consume(
doc_info_tags::before_docinfo).check();
int major_verison = version_values.consume().get_int();
int minor_verison = version_values.consume().get_int();
version_values.finish();
if (before_docinfo || using_docinfo) {
result = ((unsigned) major_verison * 100) +
(unsigned) minor_verison;
if(result < 100 || result > 107)
{
detail::outerr(state.current_file->path)
<< "Unknown version: "
<< major_verison
<< "."
<< minor_verison
<< std::endl;
++state.error_count;
}
}
}
return result;
}
示例2: traverse
void traverse(const value& tree,
const std::function<void (const path&, const value&)>& func,
const path& base_path,
bool leafs_only
)
{
if (!leafs_only || tree.empty() || (tree.kind() != kind::array && tree.kind() != kind::object))
func(base_path, tree);
if (tree.kind() == kind::object)
{
for (const auto& field : tree.as_object())
{
traverse(field.second,
func,
base_path + field.first,
leafs_only
);
}
}
else if (tree.kind() == kind::array)
{
for (value::size_type idx = 0; idx < tree.size(); ++idx)
traverse(tree[idx],
func,
base_path + idx,
leafs_only
);
}
}
示例3: return
bool dtree::num_equal::test(const value& val) const
{
if(val.empty())
return (as_number==0);
else
{
if(val.is<std::string>())
return (val.as<std::string>()==as_string);
else
return (val.as<unsigned int>()==as_number);
}
}
示例4: pre
std::string pre(quickbook::state& state, parse_iterator pos,
value include_doc_id, bool nested_file)
{
// The doc_info in the file has been parsed. Here's what we'll do
// *before* anything else.
//
// If there isn't a doc info block, then values will be empty, so most
// of the following code won't actually do anything.
value_consumer values = state.values.release();
// Skip over invalid attributes
while (values.check(value::default_tag)) values.consume();
bool use_doc_info = false;
std::string doc_type;
value doc_title;
if (values.check(doc_info_tags::type))
{
doc_type = detail::to_s(values.consume(doc_info_tags::type).get_quickbook());
doc_title = values.consume(doc_info_tags::title);
use_doc_info = !nested_file || qbk_version_n >= 106u;
}
else
{
if (!nested_file)
{
detail::outerr(state.current_file, pos.base())
<< "No doc_info block."
<< std::endl;
++state.error_count;
// Create a fake document info block in order to continue.
doc_type = "article";
doc_title = qbk_value(state.current_file,
pos.base(), pos.base(),
doc_info_tags::type);
use_doc_info = true;
}
}
std::vector<std::string> duplicates;
std::vector<value> escaped_attributes = consume_multiple_values(values, doc_info_tags::escaped_attribute);
value qbk_version = consume_list(values, doc_attributes::qbk_version, &duplicates);
value compatibility_mode = consume_list(values, doc_attributes::compatibility_mode, &duplicates);
consume_multiple_values(values, doc_attributes::source_mode);
value id = consume_value_in_list(values, doc_info_attributes::id, &duplicates);
value dirname = consume_value_in_list(values, doc_info_attributes::dirname, &duplicates);
value last_revision = consume_value_in_list(values, doc_info_attributes::last_revision, &duplicates);
value purpose = consume_value_in_list(values, doc_info_attributes::purpose, &duplicates);
std::vector<value> categories = consume_multiple_values(values, doc_info_attributes::category);
value lang = consume_value_in_list(values, doc_info_attributes::lang, &duplicates);
value version = consume_value_in_list(values, doc_info_attributes::version, &duplicates);
std::vector<value> authors = consume_multiple_values(values, doc_info_attributes::authors);
std::vector<value> copyrights = consume_multiple_values(values, doc_info_attributes::copyright);
value license = consume_value_in_list(values, doc_info_attributes::license, &duplicates);
std::vector<value> biblioids = consume_multiple_values(values, doc_info_attributes::biblioid);
value xmlbase = consume_value_in_list(values, doc_info_attributes::xmlbase, &duplicates);
values.finish();
if(!duplicates.empty())
{
detail::outwarn(state.current_file->path)
<< (duplicates.size() > 1 ?
"Duplicate attributes" : "Duplicate attribute")
<< ":" << boost::algorithm::join(duplicates, ", ")
<< "\n"
;
}
std::string include_doc_id_, id_;
if (!include_doc_id.empty())
include_doc_id_ = detail::to_s(include_doc_id.get_quickbook());
if (!id.empty())
id_ = detail::to_s(id.get_quickbook());
// Quickbook version
unsigned new_version = get_version(state, use_doc_info, qbk_version);
if (new_version != qbk_version_n)
{
if (new_version >= 107u)
{
detail::outwarn(state.current_file->path)
<< "Quickbook " << (new_version / 100) << "." << (new_version % 100)
<< " is still under development and is "
"likely to change in the future." << std::endl;
}
}
if (new_version) {
//.........这里部分代码省略.........
示例5: compare
bool operator<(const value& x, const value& y) {
if (x.empty() && y.empty()) return false;
if (x.empty()) return true; // empty is < !empty
return compare(x, y) < 0;
}
示例6:
bool operator<(const value& x, const value& y) {
if (x.empty() && y.empty()) return false;
if (x.empty()) return true; // empty is < !empty
return x.data().less(y.data());
}