diff options
Diffstat (limited to 'server/src/macrotool')
-rw-r--r-- | server/src/macrotool/dump.cc | 30 |
1 files 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<std::string> templates; - std::vector<std::string> fields; + std::map<std::string, bool> 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<std::string> getFields(Widget &widget) +static std::map<std::string, bool> getFields(Widget &widget) { - std::vector<std::string> fields; + std::map<std::string, bool> fields; std::vector< Widget >::iterator w = widget.widgets.begin(); while(w != widget.widgets.end()) { - std::vector<std::string> fs = getFields(*w); - fields.insert(fields.end(), fs.begin(), fs.end()); + std::map<std::string, bool> 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<std::string, struct _macro> 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<Fieldname> fieldnames = db.getFieldnames(); std::map<std::string, struct _macro> 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<std::string>::iterator ts = ms->second.fields.begin(); + std::map<std::string, bool>::iterator ts = ms->second.fields.begin(); while(ts != ms->second.fields.end()) { bool reg = false; + bool value = ts->second; std::vector<Fieldname>::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() |