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 command \p name. \p name must be known.
29 explicit InsetCommandParams(std::string const & name);
34 void scanCommand(std::string const &);
36 void write(std::ostream &) const;
37 /// Build the complete LaTeX command
38 docstring const getCommand() const;
39 /// Return the command name
40 std::string const & getCmdName() const { return name_; }
41 /// this is used by listings package.
42 std::string const getOptions() const;
45 std::string const getSecOptions() const;
48 std::string const getContents() const;
49 /// Set the name to \p n. This must be a known name. All parameters
50 /// are cleared except those that exist also in the new command.
51 /// What matters here is the parameter name, not position.
52 void setCmdName(std::string const & n);
53 /// this is used by the listings package
54 void setOptions(std::string const &);
57 void setSecOptions(std::string const &);
60 void setContents(std::string const &);
61 /// get parameter \p name
62 docstring const & operator[](std::string const & name) const;
63 /// set parameter \p name
64 docstring & operator[](std::string const & name);
66 bool preview() const { return preview_; }
68 void preview(bool p) { preview_ = p; }
69 /// Clear the values of all parameters
75 /// Number of parameters
77 /// Parameter names. paramnames[n] must be "".
78 char const * const * paramnames;
79 /// Tells whether a parameter is optional
80 bool const * optional;
82 /// Get information for command \p name.
83 /// Returns 0 if the command is not known.
84 static CommandInfo const * findInfo(std::string const & name);
85 /// Description of all command properties
86 CommandInfo const * info_;
87 /// The name of this command as it appears in .lyx and .tex files
90 typedef std::vector<docstring> ParamVector;
91 /// The parameters (both optional and required ones). The order is
92 /// the same that is required for LaTeX output. The size of params_
93 /// is always info_->n.
98 friend bool operator==(InsetCommandParams const &,
99 InsetCommandParams const &);
104 bool operator==(InsetCommandParams const &, InsetCommandParams const &);
107 bool operator!=(InsetCommandParams const &, InsetCommandParams const &);