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 /// \param valid_key whether or not strip leading @, which is
39 /// used to bypass validator
40 std::string params(std::string const & sep=",", bool valid_key=false) const;
42 /// add key=value to params_
43 void addParam(std::string const & key, std::string const & value);
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(); }
81 /// inline or normal listings
84 /// key-value pairs of the parameters
85 std::map<std::string, std::string> params_;
87 /// collapsable status
88 InsetCollapsable::CollapseStatus status_;
92 class invalidParam : public std::exception {
94 invalidParam(docstring const & details)
95 : details_(to_utf8(details))
98 virtual const char * what() const throw() {
99 return details_.c_str();
102 virtual ~invalidParam() throw() {}
104 std::string const details_;