From d780414989ef7e101cdaf269d4b01003d0721e6a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 11 Sep 2011 11:06:34 +0200 Subject: Generalize pragma code to support arbitrary types for context values --- odb/parser.cxx | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) (limited to 'odb/parser.cxx') diff --git a/odb/parser.cxx b/odb/parser.cxx index b615a2f..b8ea160 100644 --- a/odb/parser.cxx +++ b/odb/parser.cxx @@ -1902,49 +1902,23 @@ void parser::impl:: add_pragma (node& n, pragma const& p) { if (trace) - ts << "\t\t pragma " << p.pragma_name << " (" << p.value << ")" << endl; + ts << "\t\t pragma " << p.pragma_name << endl; // Convert '_' to '-' in the pragma name so we get foo-bar instead // of foo_bar (that's the convention used). // - string kv (p.context_name); - for (size_t i (0); i < kv.size (); ++i) - if (kv[i] == '_') - kv[i] = '-'; + string k (p.context_name); + for (size_t i (0); i < k.size (); ++i) + if (k[i] == '_') + k[i] = '-'; - string kl (kv + "-loc"); - string kn (kv + "-node"); - - if (p.mode == pragma::override) + if (p.add == 0) { - n.set (kv, p.value); - n.set (kn, p.node); - n.set (kl, p.loc); + n.set (k, p.value); + n.set (k + "-location", p.loc); } else - { - // Having three parallel vectors is not the most efficient - // way to store this, but it is quite simple. - // - typedef vector values; - typedef vector nodes; - typedef vector locations; - - if (!n.count (kv)) - { - n.set (kv, values ()); - n.set (kn, nodes ()); - n.set (kl, locations ()); - } - - values& vs (n.get (kv)); - nodes& ns (n.get (kn)); - locations& ls (n.get (kl)); - - vs.push_back (p.value); - ns.push_back (p.node); - ls.push_back (p.loc); - } + p.add (n, k, p.value, p.loc); } void parser::impl:: -- cgit v1.1