예제 #1
0
std::size_t text_template_hasher::hash(const text_template& v) {
    std::size_t seed(0);

    combine(seed, hash_boost_filesystem_path(v.input_path()));
    combine(seed, hash_boost_filesystem_path(v.output_path()));
    combine(seed, v.properties());
    combine(seed, hash_std_unordered_map_std_string_std_string(v.variables()));
    combine(seed, v.body());

    return seed;
}
예제 #2
0
void validator::validate(const text_template& tt) const {
    std::unordered_set<std::string> s;
    for (const auto& kvp : tt.properties().supplied_kvps())
        s.insert(kvp.first);

    BOOST_LOG_SEV(lg, debug) << " Supplied keys: " << s;

    const auto& e(tt.properties().expected_keys());
    BOOST_LOG_SEV(lg, debug) << " Expected keys: " << e;

    /*
     * Ensure that all expected keys have been supplied. We may have
     * received additional keys, but we don't care about those.
     */
    for (const auto ek : e) {
        const auto i(s.find(ek));
        if (i == s.end()) {
            BOOST_LOG_SEV(lg, error) << key_error + ek;
            BOOST_THROW_EXCEPTION(validation_error(key_error + ek));
        }
    }
}