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 "InsetCode.h"
17 #include "support/docstring.h"
27 class InsetCommandParams {
29 /// Construct parameters for inset of type \p code.
30 explicit InsetCommandParams(InsetCode code);
31 /// Construct parameters for inset of type \p code with
32 /// command name \p cmdName.
33 explicit InsetCommandParams(InsetCode code,
34 std::string const & cmdName);
36 std::string insetType() const { return insetName(insetCode_); }
38 InsetCode code() const { return insetCode_; }
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 /// Set the name to \p n. This must be a known name. All parameters
49 /// are cleared except those that exist also in the new command.
50 /// What matters here is the parameter name, not position.
51 void setCmdName(std::string const & n);
52 /// FIXME Would be better removed, but is used in BufferView.cpp in
53 /// ways that make removal hard.
54 docstring const getFirstNonOptParam() const;
55 /// get parameter \p name
56 docstring const & operator[](std::string const & name) const;
57 /// set parameter \p name
58 docstring & operator[](std::string const & name);
60 bool preview() const { return preview_; }
62 void preview(bool p) { preview_ = p; }
63 /// Clear the values of all parameters
69 /// Number of parameters
71 /// Parameter names. paramnames[n] must be "".
72 char const * const * paramnames;
73 /// Tells whether a parameter is optional
74 bool const * optional;
76 /// Get information for inset type \p code.
77 /// Returns 0 if the inset is not known.
78 static CommandInfo const * findInfo(InsetCode code);
79 /// Get information for \p code and command \p cmdName.
80 /// Returns 0 if the combination is not known.
81 /// Don't call this without first making sure the command name is
82 /// acceptable to the inset.
83 static CommandInfo const * findInfo(InsetCode code,
84 std::string const & cmdName);
86 std::string getDefaultCmd(InsetCode);
87 /// Description of all command properties
88 CommandInfo const * info_;
89 /// what kind of inset we're the parameters for
91 /// The name of this command as it appears in .lyx and .tex files
94 typedef std::vector<docstring> ParamVector;
95 /// The parameters (both optional and required ones). The order is
96 /// the same that is required for LaTeX output. The size of params_
97 /// is always info_->n.
102 friend bool operator==(InsetCommandParams const &,
103 InsetCommandParams const &);
108 bool operator==(InsetCommandParams const &, InsetCommandParams const &);
111 bool operator!=(InsetCommandParams const &, InsetCommandParams const &);