Abdelrazak Younes wrote:
Ozgur Ugras BARAN wrote:
Attached patch sorts listings inset params, and hence solves bug 3639.
Please somebody review and apply the patch.
I could also sort the listings_param_table[] entries manually, but I
find this way easier (and more guaranteed).
I went one step further and used a map at the first place. More cleanups
are possible.
The attached patch actually compiles and works fine.
OK?
Abdel.
Index: InsetListingsParams.cpp
===================================================================
--- InsetListingsParams.cpp (revision 18522)
+++ InsetListingsParams.cpp (working copy)
@@ -55,9 +55,13 @@
/** Information about each parameter
*/
-struct listings_param_info {
- /// name of the parameter
- string name;
+struct ListingsParam {
+ ///
+ ListingsParam(): onoff(false), type(ALL) {}
+ ///
+ ListingsParam(string v, bool o, param_type t, string i, docstring h)
+ : value(v), onoff(o), type(t), info(i), hint(h)
+ {}
/// default value
string value;
// for option with value "true", "false",
@@ -112,169 +116,181 @@
"[plain]TeX\n[primitive]TeX\nVBScript\nVerilog\nVHDL\n[AMS]VHDL\nVRML\n"
"[97]VRML\nXML\nXSLT";
-docstring const empty_hint;
-docstring const style_hint = _("Use \\footnotesize, \\small, \\itshape, "
- "\\ttfamily or something like that");
+/// key is the name of the parameter
+typedef map<string, ListingsParam> ListingsParams;
+ListingsParams AllParams;
+string AllParamNames;
-docstring const frame_hint = _("none, leftline, topline, bottomline, lines, "
- "single, shadowbox or subset of trblTRBL");
+void init_all_params()
+{
+ docstring const empty_hint;
+ docstring const style_hint = _("Use \\footnotesize, \\small, \\itshape,
"
+ "\\ttfamily or something like that");
+ docstring const frame_hint = _("none, leftline, topline, bottomline,
lines, "
+ "single, shadowbox or subset of trblTRBL");
+ docstring const frameround_hint = _("Enter four letters (either t =
round "
+ "or f = square) for top right, bottom "
+ "right, bottom left and top left corner.");
+ docstring const color_hint = _("Enter something like \\color{white}");
-docstring const frameround_hint = _("Enter four letters (either t = round "
- "or f = square) for top right, bottom "
- "right, bottom left and top left corner.");
-
-docstring const color_hint = _("Enter something like \\color{white}");
-
-
-/// options copied from page 26 of listings manual
-// FIXME: add default parameters ... (which is not used now)
-listings_param_info const listings_param_table[] = {
- { "float", "false", true, SUBSETOF, "*tbph", empty_hint},
- { "floatplacement", "tbp", false, SUBSETOF, "tbp", empty_hint},
- { "aboveskip", "\\medskipamount", false, LENGTH, "", empty_hint},
- { "belowskip", "\\medskipamount", false, LENGTH, "", empty_hint},
- { "lineskip", "", false, LENGTH, "", empty_hint},
- { "boxpos", "", false, SUBSETOF, "bct", empty_hint},
- { "print", "", false, TRUEFALSE, "", empty_hint},
- { "firstline", "", false, INTEGER, "", empty_hint},
- { "lastline", "", false, INTEGER, "", empty_hint},
- { "showlines", "", false, TRUEFALSE, "", empty_hint},
- { "emptylines", "", false, ALL, "", _("Expect a number with an optional
* before it")},
- { "gobble", "", false, INTEGER, "", empty_hint},
- { "style", "", false, ALL, "", empty_hint},
- { "language", "", false, ONEOF, allowed_languages, empty_hint},
- { "alsolanguage", "", false, ONEOF, allowed_languages, empty_hint},
- { "defaultdialect", "", false, ONEOF, allowed_languages, empty_hint},
- { "printpod", "", false, TRUEFALSE, "", empty_hint},
- { "usekeywordsintag", "", false, TRUEFALSE, "", empty_hint},
- { "tagstyle", "", false, ALL, "", style_hint },
- { "markfirstintag", "", false, ALL, "", style_hint },
- { "makemacrouse", "", false, TRUEFALSE, "", empty_hint},
- { "basicstyle", "", false, ALL, "", style_hint },
- { "identifierstyle", "", false, ALL, "", style_hint },
- { "commentstyle", "", false, ALL, "", style_hint },
- { "stringstyle", "", false, ALL, "", style_hint },
- { "keywordstyle", "", false, ALL, "", style_hint },
- { "ndkeywordstyle", "", false, ALL, "", style_hint },
- { "classoffset", "", false, INTEGER, "", empty_hint},
- { "texcsstyle", "", false, ALL, "", style_hint },
- { "directivestyle", "", false, ALL, "", style_hint },
- { "emph", "", false, ALL, "", empty_hint},
- { "moreemph", "", false, ALL, "", empty_hint},
- { "deleteemph", "", false, ALL, "", empty_hint},
- { "emphstyle", "", false, ALL, "", empty_hint},
- { "delim", "", false, ALL, "", empty_hint},
- { "moredelim", "", false, ALL, "", empty_hint},
- { "deletedelim", "", false, ALL, "", empty_hint},
- { "extendedchars", "", false, TRUEFALSE, "", empty_hint},
- { "inputencoding", "", false, ALL, "", empty_hint},
- { "upquote", "", false, TRUEFALSE, "", empty_hint},
- { "tabsize", "", false, INTEGER, "", empty_hint},
- { "showtabs", "", false, ALL, "", empty_hint},
- { "tab", "", false, ALL, "", empty_hint},
- { "showspaces", "", false, TRUEFALSE, "", empty_hint},
- { "showstringspaces", "", false, TRUEFALSE, "", empty_hint},
- { "formfeed", "", false, ALL, "", empty_hint},
- { "numbers", "", false, ONEOF, "none\nleft\nright", empty_hint},
- { "stepnumber", "", false, INTEGER, "", empty_hint},
- { "numberfirstline", "", false, TRUEFALSE, "", empty_hint},
- { "numberstyle", "", false, ALL, "", style_hint },
- { "numbersep", "", false, LENGTH, "", empty_hint},
- { "numberblanklines", "", false, ALL, "", empty_hint},
- { "firstnumber", "", false, ALL, "", _("auto, last or a number") },
- { "name", "", false, ALL, "", empty_hint},
- { "thelstnumber", "", false, ALL, "", empty_hint},
- { "title", "", false, ALL, "", empty_hint},
+ /// options copied from page 26 of listings manual
+ // FIXME: add default parameters ... (which is not used now)
+ AllParams["float"] = ListingsParam("false", true, SUBSETOF, "*tbph",
empty_hint);
+ AllParams["floatplacement"] = ListingsParam("tbp", false, SUBSETOF,
"tbp", empty_hint);
+ AllParams["aboveskip"] = ListingsParam("\\medskipamount", false,
LENGTH, "", empty_hint);
+ AllParams["belowskip"] = ListingsParam("\\medskipamount", false,
LENGTH, "", empty_hint);
+ AllParams["lineskip"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["boxpos"] = ListingsParam("", false, SUBSETOF, "bct",
empty_hint);
+ AllParams["print"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["firstline"] = ListingsParam("", false, INTEGER, "",
empty_hint);
+ AllParams["lastline"] = ListingsParam("", false, INTEGER, "",
empty_hint);
+ AllParams["showlines"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["emptylines"] = ListingsParam("", false, ALL, "", _(
+ "Expect a number with an optional * before it"));
+ AllParams["gobble"] = ListingsParam("", false, INTEGER, "", empty_hint);
+ AllParams["style"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["language"] = ListingsParam("", false, ONEOF,
allowed_languages, empty_hint);
+ AllParams["alsolanguage"] = ListingsParam("", false, ONEOF,
allowed_languages, empty_hint);
+ AllParams["defaultdialect"] = ListingsParam("", false, ONEOF,
allowed_languages, empty_hint);
+ AllParams["printpod"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["usekeywordsintag"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["tagstyle"] = ListingsParam("", false, ALL, "", style_hint);
+ AllParams["markfirstintag"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["makemacrouse"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["basicstyle"] = ListingsParam("", false, ALL, "", style_hint);
+ AllParams["identifierstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["commentstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["stringstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["keywordstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["ndkeywordstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["classoffset"] = ListingsParam("", false, INTEGER, "",
empty_hint);
+ AllParams["texcsstyle"] = ListingsParam("", false, ALL, "", style_hint);
+ AllParams["directivestyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["emph"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["moreemph"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["deleteemph"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["emphstyle"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["delim"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["moredelim"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["deletedelim"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["extendedchars"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["inputencoding"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["upquote"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["tabsize"] = ListingsParam("", false, INTEGER, "",
empty_hint);
+ AllParams["showtabs"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["tab"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["showspaces"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["showstringspaces"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["formfeed"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["numbers"] = ListingsParam("", false, ONEOF,
"none\nleft\nright", empty_hint);
+ AllParams["stepnumber"] = ListingsParam("", false, INTEGER, "",
empty_hint);
+ AllParams["numberfirstline"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["numberstyle"] = ListingsParam("", false, ALL, "",
style_hint);
+ AllParams["numbersep"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["numberblanklines"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["firstnumber"] = ListingsParam("", false, ALL, "", _("auto,
last or a number"));
+ AllParams["name"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["thelstnumber"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["title"] = ListingsParam("", false, ALL, "", empty_hint);
// this option is not handled in the parameter box
- { "caption", "", false, ALL, "", _("This parameter should not be
entered here. "
- "Please use caption editbox (Include dialog) or insert->caption
(listings inset)") },
+ AllParams["caption"] = ListingsParam("", false, ALL, "", _(
+ "This parameter should not be entered here. Please use caption "
+ "editbox (Include dialog) or insert->caption (listings
inset)"));
// this option is not handled in the parameter box
- { "label", "", false, ALL, "", _("This parameter should not be entered
here. "
- "Please use label editbox (Include dialog) or insert->caption
(listings inset)") },
- { "nolol", "", false, TRUEFALSE, "", empty_hint},
- { "captionpos", "", false, SUBSETOF, "tb", empty_hint},
- { "abovecaptionskip", "", false, LENGTH, "", empty_hint},
- { "belowcaptionskip", "", false, LENGTH, "", empty_hint},
- { "linewidth", "", false, LENGTH, "", empty_hint},
- { "xleftmargin", "", false, LENGTH, "", empty_hint},
- { "xrightmargin", "", false, LENGTH, "", empty_hint},
- { "resetmargins", "", false, TRUEFALSE, "", empty_hint},
- { "breaklines", "", false, TRUEFALSE, "", empty_hint},
- { "prebreak", "", false, ALL, "", empty_hint},
- { "postbreak", "", false, ALL, "", empty_hint},
- { "breakindent", "", false, LENGTH, "", empty_hint},
- { "breakautoindent", "", false, TRUEFALSE, "", empty_hint},
- { "frame", "", false, ALL, "", frame_hint },
- { "frameround", "", false, SUBSETOF, "tf", frameround_hint },
- { "framesep", "", false, LENGTH, "", empty_hint},
- { "rulesep", "", false, LENGTH, "", empty_hint},
- { "framerule", "", false, LENGTH, "", empty_hint},
- { "framexleftmargin", "", false, LENGTH, "", empty_hint},
- { "framexrightmargin", "", false, LENGTH, "", empty_hint},
- { "framextopmargin", "", false, LENGTH, "", empty_hint},
- { "framexbottommargin", "", false, LENGTH, "", empty_hint},
- { "backgroundcolor", "", false, ALL, "", color_hint },
- { "rulecolor", "", false, ALL, "", color_hint },
- { "fillcolor", "", false, ALL, "", color_hint },
- { "rulesepcolor", "", false, ALL, "", color_hint },
- { "frameshape", "", false, ALL, "", empty_hint},
- { "index", "", false, ALL, "", empty_hint},
- { "moreindex", "", false, ALL, "", empty_hint},
- { "deleteindex", "", false, ALL, "", empty_hint},
- { "indexstyle", "", false, ALL, "", empty_hint},
- { "columns", "", false, ALL, "", empty_hint},
- { "flexiblecolumns", "", false, ALL, "", empty_hint},
- { "keepspaces", "", false, TRUEFALSE, "", empty_hint},
- { "basewidth", "", false, LENGTH, "", empty_hint},
- { "fontadjust", "", true, TRUEFALSE, "", empty_hint},
- { "texcl", "", false, TRUEFALSE, "", empty_hint},
- { "mathescape", "", false, TRUEFALSE, "", empty_hint},
- { "escapechar", "", false, ALL, "", empty_hint},
- { "escapeinside", "", false, ALL, "", empty_hint},
- { "escepeinside", "", false, ALL, "", empty_hint},
- { "escepebegin", "", false, ALL, "", empty_hint},
- { "escepeend", "", false, ALL, "", empty_hint},
- { "fancyvrb", "", false, TRUEFALSE, "", empty_hint},
- { "fvcmdparams", "", false, ALL, "", empty_hint},
- { "morefvcmdparams", "", false, ALL, "", empty_hint},
- { "keywordsprefix", "", false, ALL, "", empty_hint},
- { "keywords", "", false, ALL, "", empty_hint},
- { "morekeywords", "", false, ALL, "", empty_hint},
- { "deletekeywords", "", false, ALL, "", empty_hint},
- { "ndkeywords", "", false, ALL, "", empty_hint},
- { "morendkeywords", "", false, ALL, "", empty_hint},
- { "deletendkeywords", "", false, ALL, "", empty_hint},
- { "texcs", "", false, ALL, "", empty_hint},
- { "moretexcs", "", false, ALL, "", empty_hint},
- { "deletetexcs", "", false, ALL, "", empty_hint},
- { "directives", "", false, ALL, "", empty_hint},
- { "moredirectives", "", false, ALL, "", empty_hint},
- { "deletedirectives", "", false, ALL, "", empty_hint},
- { "sensitive", "", false, ALL, "", empty_hint},
- { "alsoletter", "", false, ALL, "", empty_hint},
- { "alsodigit", "", false, ALL, "", empty_hint},
- { "alsoother", "", false, ALL, "", empty_hint},
- { "otherkeywords", "", false, ALL, "", empty_hint},
- { "tag", "", false, ALL, "", empty_hint},
- { "string", "", false, ALL, "", empty_hint},
- { "morestring", "", false, ALL, "", empty_hint},
- { "deletestring", "", false, ALL, "", empty_hint},
- { "comment", "", false, ALL, "", empty_hint},
- { "morecomment", "", false, ALL, "", empty_hint},
- { "deletecomment", "", false, ALL, "", empty_hint},
- { "keywordcomment", "", false, ALL, "", empty_hint},
- { "morekeywordcomment", "", false, ALL, "", empty_hint},
- { "deletekeywordcomment", "", false, ALL, "", empty_hint},
- { "keywordcommentsemicolon", "", false, ALL, "", empty_hint},
- { "podcomment", "", false, ALL, "", empty_hint},
- { "", "", false, ALL, "", empty_hint}
-};
+ AllParams["label"] = ListingsParam("", false, ALL, "",_(
+ "This parameter should not be entered here. Please use label "
+ "editbox (Include dialog) or insert->caption (listings
inset)"));
+ AllParams["nolol"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["captionpos"] = ListingsParam("", false, SUBSETOF, "tb",
empty_hint);
+ AllParams["abovecaptionskip"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["belowcaptionskip"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["linewidth"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["xleftmargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["xrightmargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["resetmargins"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["breaklines"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["prebreak"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["postbreak"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["breakindent"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["breakautoindent"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["frame"] = ListingsParam("", false, ALL, "", frame_hint);
+ AllParams["frameround"] = ListingsParam("", false, SUBSETOF, "tf",
frameround_hint);
+ AllParams["framesep"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["rulesep"] = ListingsParam("", false, LENGTH, "", empty_hint);
+ AllParams["framerule"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["framexleftmargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["framexrightmargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["framextopmargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["framexbottommargin"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["backgroundcolor"] = ListingsParam("", false, ALL, "",
color_hint );
+ AllParams["rulecolor"] = ListingsParam("", false, ALL, "", color_hint );
+ AllParams["fillcolor"] = ListingsParam("", false, ALL, "", color_hint );
+ AllParams["rulesepcolor"] = ListingsParam("", false, ALL, "",
color_hint );
+ AllParams["frameshape"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["index"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["moreindex"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["deleteindex"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["indexstyle"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["columns"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["flexiblecolumns"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["keepspaces"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["basewidth"] = ListingsParam("", false, LENGTH, "",
empty_hint);
+ AllParams["fontadjust"] = ListingsParam("", true, TRUEFALSE, "",
empty_hint);
+ AllParams["texcl"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["mathescape"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["escapechar"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["escapeinside"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["escepeinside"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["escepebegin"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["escepeend"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["fancyvrb"] = ListingsParam("", false, TRUEFALSE, "",
empty_hint);
+ AllParams["fvcmdparams"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["morefvcmdparams"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["keywordsprefix"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["keywords"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["morekeywords"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["deletekeywords"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["ndkeywords"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["morendkeywords"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["deletendkeywords"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["texcs"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["moretexcs"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["deletetexcs"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["directives"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["moredirectives"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["deletedirectives"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["sensitive"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["alsoletter"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["alsodigit"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["alsoother"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["otherkeywords"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["tag"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["string"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["morestring"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["deletestring"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["comment"] = ListingsParam("", false, ALL, "", empty_hint);
+ AllParams["morecomment"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["deletecomment"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["keywordcomment"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["morekeywordcomment"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["deletekeywordcomment"] = ListingsParam("", false, ALL, "",
empty_hint);
+ AllParams["keywordcommentsemicolon"] = ListingsParam("", false, ALL,
"", empty_hint);
+ AllParams["podcomment"] = ListingsParam("", false, ALL, "", empty_hint);
+ ListingsParams::const_iterator it = AllParams.begin();
+ ListingsParams::const_iterator end = AllParams.end();
+ for (; it != end; ++it) {
+ if (!AllParamNames.empty())
+ AllParamNames += ", ";
+ AllParamNames += it->first;
+ }
+}
-class parValidator
+
+class ParValidator
{
public:
- parValidator(string const & name);
+ ParValidator(string const & name);
/// validate given parameter
/// invalidParam will be thrown if invalid
@@ -285,45 +301,41 @@
/// parameter name
string const & name;
///
- listings_param_info const * info;
+ ListingsParam const * info;
};
-parValidator::parValidator(string const & n)
+ParValidator::ParValidator(string const & n)
: name(n), info(0)
{
+ static bool first_time = true;
+ if (first_time) {
+ init_all_params();
+ first_time = false;
+ }
+
if (name.empty())
throw invalidParam(_("Invalid (empty) listings param name."));
- else if (name == "?") {
- string pars;
- size_t idx = 0;
- while (listings_param_table[idx].name != string()) {
- if (!pars.empty())
- pars += ", ";
- pars += listings_param_table[idx].name;
- ++idx;
- }
+
+ if (name == "?")
throw invalidParam(bformat(
- _("Available listings parameters are %1$s"),
from_utf8(pars)));
- }
+ _("Available listings parameters are %1$s"),
from_ascii(AllParamNames)));
+
// locate name in parameter table
- size_t idx = 0;
- while (listings_param_table[idx].name != name &&
listings_param_table[idx].name != string())
- ++idx;
- // found the name
- if (!listings_param_table[idx].name.empty()) {
- info = &listings_param_table[idx];
+ ListingsParams::const_iterator it = AllParams.find(name);
+ if (it != AllParams.end()) {
+ info = &it->second;
return;
}
+
// otherwise, produce a meaningful error message.
string matching_names;
- for (size_t i = 0; i < idx; ++i) {
- string n(listings_param_table[i].name);
- if (prefixIs(n, name)) {
- if (matching_names.empty())
- matching_names += n;
- else
- matching_names += ", " + n;
+ ListingsParams::const_iterator end = AllParams.end();
+ for (it = AllParams.begin(); it != end; ++it) {
+ if (prefixIs(it->first, name)) {
+ if (!matching_names.empty())
+ matching_names += ", ";
+ matching_names += it->first;
}
}
if (matching_names.empty())
@@ -335,7 +347,7 @@
}
-void parValidator::validate(std::string const & par) const
+void ParValidator::validate(std::string const & par) const
{
bool unclosed = false;
string par2 = par;
@@ -346,7 +358,6 @@
par2 = par.substr(1);
unclosed = true;
}
-
switch (info->type) {
case ALL:
@@ -407,7 +418,7 @@
throw invalidParam(info->hint);
else
throw invalidParam(bformat(_("Please specify
one of %1$s"),
-
from_utf8(string(info->info))));
+
from_utf8(info->info)));
}
// break value to allowed strings
vector<string> lists;
@@ -441,7 +452,7 @@
}
if (matching_names.empty())
throw invalidParam(bformat(_("Try one of %1$s"),
-
from_utf8(string(info->info))));
+ from_utf8(info->info)));
else
throw invalidParam(bformat(_("I guess you mean %1$s"),
from_utf8(matching_names)));
@@ -453,10 +464,10 @@
throw invalidParam(info->hint);
else
throw invalidParam(bformat(_("Please specify
one or more of '%1$s'"),
-
from_utf8(string(info->info))));
+
from_utf8(info->info)));
}
for (size_t i = 0; i < par2.size(); ++i)
- if (string(info->info).find(par2[i], 0) == string::npos)
+ if (info->info.find(par2[i], 0) == string::npos)
throw invalidParam(
bformat(_("Parameter %1$s should be
composed of one or more of %2$s"),
from_utf8(name),
from_utf8(info->info)));
@@ -527,18 +538,16 @@
if (key.empty())
return;
// exception may be thown.
- parValidator(key).validate(value);
+ ParValidator(key).validate(value);
// duplicate parameters!
if (params_.find(key) != params_.end())
throw invalidParam(bformat(_("Parameter %1$s has already been
defined"),
from_utf8(key)));
// check onoff flag
- size_t idx = 0;
- while (listings_param_table[idx].name != key)
- ++idx;
- BOOST_ASSERT(listings_param_table[idx].name == key);
+ ListingsParams::const_iterator it = AllParams.find(key);
+ BOOST_ASSERT(it != AllParams.end());
// onoff parameter with value false
- if (listings_param_table[idx].onoff && (value == "false" || value ==
"{false}"))
+ if (it->second.onoff && (value == "false" || value == "{false}"))
params_[key] = string();
// if the parameter is surrounded with {}, good
else if (prefixIs(value, "{") && suffixIs(value, "}"))