]> git.lyx.org Git - lyx.git/blob - src/BranchList.h
e284aa43d0c0d2c0a59eb9d8c4d99094833991a1
[lyx.git] / src / BranchList.h
1 // -*- C++ -*- 
2 /**
3  * \file BranchList.h 
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  * \author Martin Vermeer
7  * 
8  * Full author contact details are available in file CREDITS.
9  *
10  *
11  * \class Branch
12  *
13  * A class describing a 'branch', i.e., a named alternative for
14  * selectively outputting some parts of a document while suppressing
15  * other parts.
16  *
17  * A branch has a name, can either be selected or not, and uses a
18  * user-specifyable background colour. All these can be set and
19  * queried.
20  * 
21  * \class BranchList
22  *
23  * A class containing a vector of all defined branches within a
24  * document. Has methods for selecting or deselecting branches by
25  * name, for outputting a '|'-separated string of all elements or only
26  * the selected ones, and for adding and removing elements.
27  */
28
29
30 #ifndef BRANCHES_H
31 #define BRANCHES_H
32
33 #include "support/std_string.h"
34 #include <list>
35
36 class Branch {
37 public:
38         ///
39         string const getBranch() const;
40         ///
41         void setBranch(string const &);
42         ///
43         bool getSelected() const;
44         ///
45         void setSelected(bool);
46         /// 
47         string const getColor() const;
48         ///
49         void setColor(string const &);
50
51
52 private:
53         ///
54         string branch_;
55         ///
56         bool selected_;
57         ///
58         string color_;
59 };
60
61
62 class BranchList {
63 public:
64         ///
65         BranchList() : separator_("|") {}
66         
67         ///
68         typedef std::list<Branch> List;
69
70         ///
71         void clear();
72         ///
73         bool empty() { return list.empty(); }
74         ///
75         bool size() const { return list.size(); }
76         ///
77         List::const_iterator begin() const { return list.begin(); }
78         ///
79         List::const_iterator end() const { return list.end(); }
80         ///
81         string getColor(string const &) const;
82         ///     
83         void setColor(string const &, string const &);
84         /// Select/deselect multiple branches given in '|'-separated string
85         void setSelected(string const &, bool);
86         /// Add multiple branches to list
87         void add(string const &);
88         /// remove a branch from list by name
89         void remove(string const &);
90         /// return whether this branch is selected
91         bool selected(string const &) const;
92         /// return, as a '|'-separated string, all branch names
93         string allBranches() const;
94         /// 
95         string allSelected() const;
96         ///
97         string const separator() const;
98         
99 private:
100         ///
101         List list;
102         ///
103         string separator_;
104 };
105
106 #endif