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"
25 class InsetCommandParams {
27 /// Construct parameters for command \p name. \p name must be known.
28 explicit InsetCommandParams(std::string const & name);
33 void scanCommand(std::string const &);
35 void write(std::ostream &) const;
36 /// Build the complete LaTeX command
37 lyx::docstring const getCommand() const;
38 /// Return the command name
39 std::string const & getCmdName() const { return name_; }
41 std::string const getOptions() const;
43 std::string const getSecOptions() const;
45 std::string const getContents() const;
46 /// Set the name to \p n. This must be a known name. All parameters
47 /// are cleared except those that exist also in the new command.
48 /// What matters here is the parameter name, not position.
49 void setCmdName(std::string const & n);
51 void setOptions(std::string const &);
53 void setSecOptions(std::string const &);
55 void setContents(std::string const &);
56 /// get parameter \p name
57 lyx::docstring const & operator[](std::string const & name) const;
58 /// set parameter \p name
59 lyx::docstring & operator[](std::string const & name);
61 bool preview() const { return preview_; }
63 void preview(bool p) { preview_ = p; }
64 /// Clear the values of all parameters
70 /// Number of parameters
72 /// Parameter names. paramnames[n] must be "".
73 char const * const * paramnames;
74 /// Tells whether a parameter is optional
75 bool const * optional;
77 /// Get information for command \p name.
78 /// Returns 0 if the command is not known.
79 static CommandInfo const * findInfo(std::string const & name);
80 /// Description of all command properties
81 CommandInfo const * info_;
82 /// The name of this command as it appears in .lyx and .tex files
85 typedef std::vector<lyx::docstring> ParamVector;
86 /// The parameters (both optional and required ones). The order is
87 /// the same that is required for LaTeX output. The size of params_
88 /// is always info_->n.
93 friend bool operator==(InsetCommandParams const &,
94 InsetCommandParams const &);
99 bool operator==(InsetCommandParams const &, InsetCommandParams const &);
102 bool operator!=(InsetCommandParams const &, InsetCommandParams const &);