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_; }
42 std::string const getOptions() const;
44 std::string const getSecOptions() const;
46 std::string const getContents() const;
47 /// Set the name to \p n. This must be a known name. All parameters
48 /// are cleared except those that exist also in the new command.
49 /// What matters here is the parameter name, not position.
50 void setCmdName(std::string const & n);
52 void setOptions(std::string const &);
54 void setSecOptions(std::string const &);
56 void setContents(std::string const &);
57 /// get parameter \p name
58 docstring const & operator[](std::string const & name) const;
59 /// set parameter \p name
60 docstring & operator[](std::string const & name);
62 bool preview() const { return preview_; }
64 void preview(bool p) { preview_ = p; }
65 /// Clear the values of all parameters
71 /// Number of parameters
73 /// Parameter names. paramnames[n] must be "".
74 char const * const * paramnames;
75 /// Tells whether a parameter is optional
76 bool const * optional;
78 /// Get information for command \p name.
79 /// Returns 0 if the command is not known.
80 static CommandInfo const * findInfo(std::string const & name);
81 /// Description of all command properties
82 CommandInfo const * info_;
83 /// The name of this command as it appears in .lyx and .tex files
86 typedef std::vector<docstring> ParamVector;
87 /// The parameters (both optional and required ones). The order is
88 /// the same that is required for LaTeX output. The size of params_
89 /// is always info_->n.
94 friend bool operator==(InsetCommandParams const &,
95 InsetCommandParams const &);
100 bool operator==(InsetCommandParams const &, InsetCommandParams const &);
103 bool operator!=(InsetCommandParams const &, InsetCommandParams const &);