Exemplo n.º 1
0
///
/// Convenience method to obtain the SHA256 hash of a given script
///
std::string
calculate_script_hash(const repository &repo,
                      const script_action &action,
                      const std::string &script_path)
{
    switch (action) {
        case script_action::install:
        {
            string path = repo.install_script_path() + "/" + script_path;
            ifstream ifs{path.c_str()};
            return read_install_statements(ifs).sha256_sum();
        }
        case script_action::upgrade:
        {
            string path = repo.upgrade_script_path() + "/" + script_path;
            ifstream ifs{path.c_str()};
            return read_upgrade_statements(ifs).sha256_sum();
        }
        case script_action::rollback:
        {
            string path = repo.upgrade_script_path() + "/" + script_path;
            ifstream ifs{path.c_str()};
            return read_rollback_statements(ifs).sha256_sum();
        }
    }
    throw std::out_of_range{to_string(action)};
}
Exemplo n.º 2
0
std::size_t repository_hasher::hash(const repository& v) {
    std::size_t seed(0);

    combine(seed, hash_std_unordered_map_std_string_std_list_std_string(v.child_id_to_parent_ids()));
    combine(seed, hash_std_unordered_map_std_string_dogen_yarn_name(v.id_to_name()));
    combine(seed, v.model());

    return seed;
}
Exemplo n.º 3
0
std::size_t repository_hasher::hash(const repository& v) {
    std::size_t seed(0);

    combine(seed, hash_std_list_dogen_dynamic_field_definition(v.all_field_definitions()));
    combine(seed, hash_std_unordered_map_std_string_dogen_dynamic_field_definition(v.field_definitions_by_name()));
    combine(seed, hash_std_unordered_map_std_string_std_list_dogen_dynamic_field_definition_(v.field_definitions_by_facet_name()));
    combine(seed, hash_std_unordered_map_std_string_std_list_dogen_dynamic_field_definition_(v.field_definitions_by_formatter_name()));
    combine(seed, hash_std_unordered_map_std_string_std_list_dogen_dynamic_field_definition_(v.field_definitions_by_model_name()));

    return seed;
}
Exemplo n.º 4
0
void mock_repository_factory::add_field_definition(
    const field_definition& fd, repository& rp) const {

    const auto n(fd.name().qualified());
    const auto pair(std::make_pair(n, fd));
    const auto result(rp.field_definitions_by_name().insert(pair));
    if (!result.second) {
        BOOST_LOG_SEV(lg, error) << duplicate_qualified_name << n;
        BOOST_THROW_EXCEPTION(workflow_error(duplicate_qualified_name + n));
    }

    const auto& oh(fd.ownership_hierarchy());
    rp.field_definitions_by_facet_name()[oh.facet_name()].push_back(fd);
    rp.field_definitions_by_formatter_name()[oh.formatter_name()]
        .push_back(fd);
}
Exemplo n.º 5
0
/*
 * This test case uses confix to wrap each xml attribute's value
 * inside double quotes.
 *
 * Notice that the generators' attribute list contains also tuples.
 * Tuples are needed to specify each confix's attributes that contain
 * more than one generator, like confix()[int_ << string] (this
 * generator needs a tuple: tuple<int, string>).
 *
 * The difference between this generator and the one in test case
 * 'bgcolor_stream_test_case' is the use of less << operators and
 * a more clean handling of double quotes.
 */
BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F)
{
    using repository::confix;
    using fusion::tuple;

    actual_output
        << format(
            "<svg width=" << confix('"', '"')[int_ << string]
            << " height=" << confix('"', '"')[int_ << string]
            << " version=" << confix('"', '"')[float_]
            << " xmlns=" << confix('"', '"')[string]
            << ">",
            tuple<int, std::string>(width, "px"), tuple<int, std::string>(height, "px"), version, xmlns);

    BOOST_CHECK_EQUAL(actual_output.str(), expected_output);
}
/*
 * This test case uses confix to wrap each xml attribute's value
 * inside double quotes.
 *
 * Notice that the generators' attribute list contains also tuples.
 * Tuples are needed to specify each confix's attributes that contain
 * more than one generator, like confix()[int_ << string] (this 
 * generator needs a tuple: tuple<int, string>).
 *
 * The difference between this generator and the one in test case
 * 'bgcolor_stream_test_case' is the use of less << operators and
 * a more clean handling of double quotes.
 */
BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F)
{
    using repository::confix;
    using fusion::tuple;

    actual_output
	<< format(
	    "<rect x=" << confix('"', '"')[int_]
	    << " y=" << confix('"', '"')[int_]
	    << " width=" << confix('"', '"')[int_ << string]
	    << " height=" << confix('"', '"')[int_ << string]
	    << " style=" << confix('"', '"')["fill: " << string]
	    << "/>",
	    x, y, tuple<int, std::string>(width, "px"), tuple<int, std::string>(height, "px"), bgcolor); 
    
    BOOST_CHECK_EQUAL(actual_output.str(), expected_output);
}
Exemplo n.º 7
0
/*
 * This test case uses an iterator to receive the generated
 * output. The iterator comes from the std::ostringstream that's
 * been used in the previous test cases, so the output is
 * actually generated into the stream.
 *
 * Using iterators instead of streams has the advantage that
 * more advanced concepts are implemented in karma for them,
 * like rules and grammars.
 */
BOOST_FIXTURE_TEST_CASE(bgcolor_stream_iterator_test_case, F)
{
    using repository::confix;
    using fusion::tuple;

    std::ostream_iterator<char> actual_output_iterator(actual_output);

    generate(
        actual_output_iterator,
        confix("<", ">")[
            "svg width=" << confix('"', '"')[int_ << string]
            << " height=" << confix('"', '"')[int_ << string]
            << " version=" << confix('"', '"')[float_]
            << " xmlns=" << confix('"', '"')[string]],
        tuple<int, std::string>(width, "px"), tuple<int, std::string>(height, "px"), version, xmlns);

    BOOST_CHECK_EQUAL(actual_output.str(), expected_output);
}
/*
 * This test case uses an iterator to receive the generated
 * output. The iterator comes from the std::ostringstream that's
 * been used in the previous test cases, so the output is
 * actually generated into the stream.
 *
 * Using iterators instead of streams has the advantage that
 * more advanced concepts are implemented in karma for them,
 * like rules and grammars.
 */
BOOST_FIXTURE_TEST_CASE(bgcolor_stream_iterator_test_case, F)
{
    using repository::confix;
    using fusion::tuple;

    std::ostream_iterator<char> actual_output_iterator(actual_output);

    generate(
	actual_output_iterator,
	confix("<", "/>")[
	    "rect x=" << confix('"', '"')[int_]
	    << " y=" << confix('"', '"')[int_]
	    << " width=" << confix('"', '"')[int_ << string]
	    << " height=" << confix('"', '"')[int_ << string]
	    << " style=" << confix('"', '"')["fill: " << string]],
	x, y, tuple<int, std::string>(width, "px"), tuple<int, std::string>(height, "px"), bgcolor);

    BOOST_CHECK_EQUAL(actual_output.str(), expected_output);
}
 vertical_advection_reference(repository &repo) : m_repo(repo), m_domain(repo.domain()), m_halo(repo.halo()) {
     compute_strides(m_domain, m_strides);
 }