3 * \file InsetCommandParams.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSETCOMMANDPARAMS_H
14 #define INSETCOMMANDPARAMS_H
16 #include "support/docstring.h"
26 class InsetCommandParams {
28 /// Construct parameters for inset \p insetType, using
29 /// \p insetType as default for \p cmdName_.
30 explicit InsetCommandParams(std::string const & insetType);
31 /// Construct parameters for inset \p insetType with
32 /// command name \p cmdName.
33 explicit InsetCommandParams(std::string const & insetType,
34 std::string const & cmdName);
36 std::string insetType() { return insetType_; }
41 void scanCommand(std::string const &);
43 void write(std::ostream &) const;
44 /// Build the complete LaTeX command
45 docstring const getCommand() const;
46 /// Return the command name
47 std::string const & getCmdName() const { return cmdName_; }
48 /// this is used by listings package.
49 std::string const getOptions() const;
51 std::string const getContents() const;
52 /// Set the name to \p n. This must be a known name. All parameters
53 /// are cleared except those that exist also in the new command.
54 /// What matters here is the parameter name, not position.
55 void setCmdName(std::string const & n);
56 /// this is used by the listings package
57 void setOptions(std::string const &);
59 void setContents(std::string const &);
60 /// get parameter \p name
61 docstring const & operator[](std::string const & name) const;
62 /// set parameter \p name
63 docstring & operator[](std::string const & name);
65 bool preview() const { return preview_; }
67 void preview(bool p) { preview_ = p; }
68 /// Clear the values of all parameters
73 std::string const getSecOptions() const;
75 void setSecOptions(std::string const &);
78 /// Number of parameters
80 /// Parameter names. paramnames[n] must be "".
81 char const * const * paramnames;
82 /// Tells whether a parameter is optional
83 bool const * optional;
85 /// Get information for inset type \p insetType.
86 /// Returns 0 if the inset is not known.
87 static CommandInfo const * findInfo(std::string const & insetType);
88 /// Get information for \p insetType and command \p cmdName.
89 /// Returns 0 if the combination is not known.
90 /// Don't call this without first making sure the command name is
91 /// acceptable to the inset.
92 static CommandInfo const * findInfo(std::string const & insetType,
93 std::string const & cmdName);
95 std::string getDefaultCmd(std::string insetType);
96 /// Description of all command properties
97 CommandInfo const * info_;
98 /// what kind of inset we're the parameters for
99 std::string insetType_;
100 /// The name of this command as it appears in .lyx and .tex files
101 std::string cmdName_;
103 typedef std::vector<docstring> ParamVector;
104 /// The parameters (both optional and required ones). The order is
105 /// the same that is required for LaTeX output. The size of params_
106 /// is always info_->n.
111 friend bool operator==(InsetCommandParams const &,
112 InsetCommandParams const &);
117 bool operator==(InsetCommandParams const &, InsetCommandParams const &);
120 bool operator!=(InsetCommandParams const &, InsetCommandParams const &);