]> git.lyx.org Git - lyx.git/blob - src/insets/InsetListingsParams.h
Add bypass validation checkboxes to listings related dialogs
[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_
41         void addParam(std::string const & key, std::string const & value);
42
43         /// add a few parameters
44         void addParams(std::string const & par);
45
46         /// set params_ with par, throw an exception if par is valid
47         void setParams(std::string const & par);
48
49         /// generate a parameter string that can be safely save and restored
50         /// by lyx' lexer
51         std::string encodedString() const;
52
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;
56
57         /// get parameter from encoded string
58         void fromEncodedString(std::string const & par);
59
60         ///
61         bool isInline() const { return inline_; }
62
63         ///
64         bool isFloat() const;
65
66         ///
67         InsetCollapsable::CollapseStatus status() const { return status_; }
68
69         ///
70         void setInline(bool i) { inline_ = i; }
71
72         /// get value of option \c param
73         std::string getParamValue(std::string const & param) const;
74
75         ///
76         void clear() { params_.clear(); }
77         
78         /// validate parameter, return an error message
79         docstring validate() const;
80
81 private:
82         /// inline or normal listings
83         bool inline_;
84
85         /// key-value pairs of the parameters
86         std::map<std::string, std::string> params_;
87
88         /// collapsable status
89         InsetCollapsable::CollapseStatus status_;
90 };
91
92
93 } // namespace lyx
94
95 #endif