3 * \file InsetListingsParams.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSETLISTINGSPARAMS_H
13 #define INSETLISTINGSPARAMS_H
18 #include "InsetCollapsable.h"
22 class InsetListingsParams {
25 InsetListingsParams();
28 InsetListingsParams(std::string const &, bool in=false,
29 InsetCollapsable::CollapseStatus s = InsetCollapsable::Open);
31 /// write parameters to an ostream
32 void write(std::ostream &) const;
34 /// read parameters from an ostream
37 /// valid parameter string
38 std::string params(std::string const & sep=",") const;
40 /// add key=value to params_. key_=value will be used if key=value already exists
41 /// unless replace=true.
42 void addParam(std::string const & key, std::string const & value,
43 bool replace = false);
45 /// add a few parameters
46 void addParams(std::string const & par);
48 /// set params_ with par, throw an exception if par is valid
49 void setParams(std::string const & par);
51 /// generate a parameter string that can be safely save and restored
53 std::string encodedString() const;
55 /// newline (\n) separated parameters. comma can be removed.
56 /// One possible complication is that , may appear in option value.
57 std::string separatedParams(bool keepComma = false) const;
59 /// get parameter from encoded string
60 void fromEncodedString(std::string const & par);
63 bool isInline() const { return inline_; }
69 InsetCollapsable::CollapseStatus status() const { return status_; }
72 void setInline(bool i) { inline_ = i; }
74 /// get value of option \c param
75 std::string getParamValue(std::string const & param) const;
78 void clear() { params_.clear(); }
80 /// validate parameter, return an error message
81 docstring validate() const;
84 /// inline or normal listings
87 /// key-value pairs of the parameters
88 std::map<std::string, std::string> params_;
90 /// collapsable status
91 InsetCollapsable::CollapseStatus status_;