[EMAIL PROTECTED] wrote:
Author: rgheck
Date: Thu Oct 25 06:13:56 2007
New Revision: 21194

URL: http://www.lyx.org/trac/changeset/21194
Log:
Move the findInfo() and defaultCommand() routines out of InsetCommand and into its 
subclasses, so that the subclasses know what parameters they want, etc. Also, introduce 
an "isCompatibleCommand()" routine, so the subclasses can tell us which 
commands they are prepared to accept.


Modified: lyx-devel/trunk/src/insets/InsetBibitem.cpp
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetBibitem.cpp?rev=21194
==============================================================================
--- lyx-devel/trunk/src/insets/InsetBibitem.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetBibitem.cpp Thu Oct 25 06:13:56 2007
@@ -44,6 +44,15 @@
 {
        if (getParam("key").empty())
                setParam("key", key_prefix + convert<docstring>(++key_counter));
+}
+
+
+CommandInfo const * InsetBibitem::findInfo(std::string const & /* cmdName */)
+{
+       static const char * const paramnames[] = {"label", "key", ""};
+       static const bool isoptional[] = {true, false};
+       static const CommandInfo info = {2, paramnames, isoptional};
+       return &info;
 }

Hum, I think I'd prefer a static map initialisation:

map<InsetCode, CommandInfo> command_info;

command_info[BIBITEM_CODE] = CommandInfo(2, {"label", "key", ""}, {true, false}; command_info[BIBTEX_CODE] = CommandInfo(3, {"options", "btprint", "bibfiles", ""}, {true, true, false};

Hum... no, even that is too complicated, why not using ICPInfo directly instead of this intermediate structure? Instead of a list, I'd choose a vector:

typedef std::vector<ICPInfo> PList;
typeded map<InsetCode, PList> command_info;

And then in the factory or in the InsetBibitem ctor:

command_info[BIBITEM_CODE] = PList({{"label", true}, {"key", false}});

Abdel.

Reply via email to