From d03b90f8d9f9906cafae4d62ee102837977e33b9 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 6 Jul 2010 08:46:14 +0000 Subject: Make dump fieldnames show if the fields has value attributes. --- server/src/macrotool/dump.cc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/server/src/macrotool/dump.cc b/server/src/macrotool/dump.cc index 6a5b018..b567768 100644 --- a/server/src/macrotool/dump.cc +++ b/server/src/macrotool/dump.cc @@ -52,7 +52,7 @@ struct _macro { std::string name; std::string title; std::set templates; - std::vector fields; + std::map fields; std::string file; std::string version; }; @@ -72,19 +72,20 @@ static const char usage_str[] = " fields Outputs all fields sorted by macro, with indication of those in the fieldnames table.\n" ; -static std::vector getFields(Widget &widget) +static std::map getFields(Widget &widget) { - std::vector fields; + std::map fields; std::vector< Widget >::iterator w = widget.widgets.begin(); while(w != widget.widgets.end()) { - std::vector fs = getFields(*w); - fields.insert(fields.end(), fs.begin(), fs.end()); + std::map fs = getFields(*w); + fields.insert(fs.begin(), fs.end()); w++; } if(widget.attributes.find("name") != widget.attributes.end()) - fields.push_back(widget.attributes["name"]); + fields[widget.attributes["name"]] = + widget.attributes.find("value") != widget.attributes.end(); return fields; } @@ -142,7 +143,8 @@ static std::map macroList() static void dump_fields() { - Database db("pgsql", Conf::database_addr, "", Conf::database_user, Conf::database_passwd, ""); + Database db("pgsql", Conf::database_addr, "", Conf::database_user, + Conf::database_passwd, ""); std::vector fieldnames = db.getFieldnames(); std::map macros = macroList(); @@ -150,20 +152,21 @@ static void dump_fields() while(ms != macros.end()) { printf("Macro: %s\n", ms->second.name.c_str()); - std::vector::iterator ts = ms->second.fields.begin(); + std::map::iterator ts = ms->second.fields.begin(); while(ts != ms->second.fields.end()) { bool reg = false; + bool value = ts->second; std::vector::iterator fs = fieldnames.begin(); while(fs != fieldnames.end()) { - if(*ts == fs->name) { + if(ts->first == fs->name) { reg = true; break; } fs++; } - - printf("\t%s %s\n", reg?"(*)":" ", ts->c_str()); + printf("\t%s %s [%s]\n", + reg?"(*)":" ", ts->first.c_str(), value?"+":"-"); ts++; } @@ -171,7 +174,10 @@ static void dump_fields() ms++; } - printf("----\n(*) Indicates that the field is registered in the fieldnames table.\n"); + printf("----\n"); + printf("(*) Indicates that the field exists in the fieldnames table.\n"); + printf("[-] Indicates that the field does not have a value field.\n"); + printf("[+] Indicates that the field does have a value field.\n"); } static void dump_macros() -- cgit v1.2.3