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() const { return params_; }
40 /// add key=value to params_
41 void addParam(std::string const & key, std::string const & value);
43 /// add a few parameters
44 void addParams(std::string const & par);
46 /// set params_ with par, throw an exception if par is valid
47 void setParams(std::string const & par);
49 /// generate a parameter string that can be safely save and restored
51 std::string encodedString() const;
53 /// newline (\n) separated parameters. comma can be removed.
54 /// One possible complication is that , may appear in option value.
55 std::string separatedParams(bool keepComma = false) const;
57 /// get parameter from encoded string
58 void fromEncodedString(std::string const & par);
61 bool isInline() const { return inline_; }
67 InsetCollapsable::CollapseStatus status() const { return status_; }
70 void setInline(bool i) { inline_ = i; }
72 /// get value of option \c param
73 std::string getParamValue(std::string const & param) const;
76 void clear() { params_.clear(); }
79 /// inline or normal listings
82 /// listing parameters, this will always be a *valid* string
83 /// that can be passed to listing packages.
86 /// keys defined in params_
87 std::vector<std::string> keys_;
89 /// collapsable status
90 InsetCollapsable::CollapseStatus status_;
94 class invalidParam : public std::exception {
96 invalidParam(docstring const & details)
97 : details_(to_utf8(details))
100 virtual const char * what() const throw() {
101 return details_.c_str();
104 virtual ~invalidParam() throw() {}
106 std::string const details_;