]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCommandParams.h
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetCommandParams.h
index a5dd8c462f85b8b2d2ac0112a3ded088927599dc..5e043a4e57395ec69a77a75b4755309b32446cb7 100644 (file)
@@ -6,6 +6,7 @@
  *
  * \author Angus Leeming
  * \author Georg Baum
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -17,6 +18,7 @@
 #include "support/docstring.h"
 
 #include <iosfwd>
+#include <string>
 #include <vector>
 
 
@@ -24,6 +26,18 @@ namespace lyx {
 
 class Lexer;
 
+// No parameter may be named "preview", because that is a required
+// flag for all commands.
+struct CommandInfo {
+       /// Number of parameters
+       size_t n;
+       /// Parameter names. paramnames[n] must be "".
+       char const * const * paramnames;
+       /// Tells whether a parameter is optional
+       bool const * optional;
+};
+
+
 class InsetCommandParams {
 public:
        /// Construct parameters for inset of type \p code.
@@ -39,26 +53,19 @@ public:
        ///
        void read(Lexer &);
        /// Parse the command
-       /// FIXME remove
-       void scanCommand(std::string const &);
        ///
        void write(std::ostream &) const;
        /// Build the complete LaTeX command
        docstring const getCommand() const;
        /// Return the command name
        std::string const & getCmdName() const { return cmdName_; }
-       /// this is used by listings package.
-       std::string const getOptions() const;
-       /// FIXME remove
-       std::string const getContents() const;
        /// Set the name to \p n. This must be a known name. All parameters
        /// are cleared except those that exist also in the new command.
        /// What matters here is the parameter name, not position.
        void setCmdName(std::string const & n);
-       /// this is used by the listings package
-       void setOptions(std::string const &);
-       /// FIXME remove
-       void setContents(std::string const &);
+       /// FIXME Would be better removed, but is used in BufferView.cpp in 
+       /// ways that make removal hard.
+       docstring const getFirstNonOptParam() const;
        /// get parameter \p name
        docstring const & operator[](std::string const & name) const;
        /// set parameter \p name
@@ -71,19 +78,7 @@ public:
        void clear();
 
 private:
-       /// FIXME remove
-       std::string const getSecOptions() const;
-       /// FIXME remove
-       void setSecOptions(std::string const &);
        ///
-       struct CommandInfo {
-               /// Number of parameters
-               size_t n;
-               /// Parameter names. paramnames[n] must be "".
-               char const * const * paramnames;
-               /// Tells whether a parameter is optional
-               bool const * optional;
-       };
        /// Get information for inset type \p code.
        /// Returns 0 if the inset is not known.
        static CommandInfo const * findInfo(InsetCode code);
@@ -94,6 +89,8 @@ private:
        static CommandInfo const * findInfo(InsetCode code,
                                            std::string const & cmdName);
        ///
+       static bool isCompatibleCommand(InsetCode code, std::string const & s);
+       ///
        std::string getDefaultCmd(InsetCode);
        /// Description of all command properties
        CommandInfo const * info_;