]> git.lyx.org Git - lyx.git/blob - src/insets/InsetListingsParams.h
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetListingsParams.h
1 // -*- C++ -*-
2 /**
3  * \file InsetListingsParams.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Bo Peng
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETLISTINGSPARAMS_H
13 #define INSETLISTINGSPARAMS_H
14
15 #include <map>
16 #include <exception>
17 #include "Lexer.h"
18 #include "InsetCollapsable.h"
19
20 namespace lyx {
21
22 class InsetListingsParams {
23 public:
24         ///
25         InsetListingsParams();
26
27         ///
28         InsetListingsParams(std::string const &, bool in=false,
29                 InsetCollapsable::CollapseStatus s = InsetCollapsable::Open);
30
31         /// write parameters to an ostream
32         void write(std::ostream &) const;
33
34         /// read parameters from an ostream
35         void read(Lexer &);
36
37         /// valid parameter string
38         std::string params(std::string const & sep=",") const;
39
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);
44
45         /// add a few parameters
46         void addParams(std::string const & par);
47
48         /// set params_ with par, throw an exception if par is valid
49         void setParams(std::string const & par);
50
51         /// generate a parameter string that can be safely save and restored
52         /// by lyx' lexer
53         std::string encodedString() const;
54
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;
58
59         /// get parameter from encoded string
60         void fromEncodedString(std::string const & par);
61
62         ///
63         bool isInline() const { return inline_; }
64
65         ///
66         bool isFloat() const;
67
68         ///
69         InsetCollapsable::CollapseStatus status() const { return status_; }
70
71         ///
72         void setInline(bool i) { inline_ = i; }
73
74         /// get value of option \c param
75         std::string getParamValue(std::string const & param) const;
76
77         ///
78         void clear() { params_.clear(); }
79         
80         /// validate parameter, return an error message
81         docstring validate() const;
82
83 private:
84         /// inline or normal listings
85         bool inline_;
86
87         /// key-value pairs of the parameters
88         std::map<std::string, std::string> params_;
89
90         /// collapsable status
91         InsetCollapsable::CollapseStatus status_;
92 };
93
94
95 } // namespace lyx
96
97 #endif