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
15 #include "InsetCollapsable.h"
21 class InsetListingsParams {
24 InsetListingsParams();
27 InsetListingsParams(std::string const &, bool in=false,
28 InsetCollapsable::CollapseStatus s = InsetCollapsable::Open);
30 /// write parameters to an ostream
31 void write(std::ostream &) const;
33 /// read parameters from an ostream
36 /// valid parameter string
37 std::string params(std::string const & sep=",") const;
39 /// add key=value to params_. key_=value will be used if key=value already exists
40 /// unless replace=true.
41 void addParam(std::string const & key, std::string const & value,
42 bool replace = false);
44 /// add a few parameters
45 void addParams(std::string const & par);
47 /// set params_ with par, throw an exception if par is valid
48 void setParams(std::string const & par);
50 /// generate a parameter string that can be safely save and restored
52 std::string encodedString() const;
54 /// newline (\n) separated parameters. comma can be removed.
55 /// One possible complication is that , may appear in option value.
56 std::string separatedParams(bool keepComma = false) const;
58 /// get parameter from encoded string
59 void fromEncodedString(std::string const & par);
62 bool isInline() const { return inline_; }
68 InsetCollapsable::CollapseStatus status() const { return status_; }
71 void setInline(bool i) { inline_ = i; }
73 /// get value of option \c param
74 std::string getParamValue(std::string const & param) const;
77 void clear() { params_.clear(); }
79 /// validate parameter, return an error message
80 docstring validate() const;
83 /// inline or normal listings
86 /// Do we have a param with the given \c key?
87 bool hasParam(std::string const & key) const;
88 /// return the value for the given \c key, if avaible, else empty string
89 std::string getValue(std::string const & key) const;
91 /// key-value pairs of the parameters
92 // Use a vector of pairs in order to maintain the order of insertion.
93 typedef std::vector<std::pair<std::string, std::string> > keyValuePair;
96 /// collapsable status
97 InsetCollapsable::CollapseStatus status_;