]> git.lyx.org Git - lyx.git/blob - src/BranchList.h
Add a Buffer::fully_loaded member function, returning true only when
[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 <string>
34 #include <list>
35
36
37 class Branch {
38 public:
39         ///
40         std::string const getBranch() const;
41         ///
42         void setBranch(std::string const &);
43         ///
44         bool getSelected() const;
45         ///
46         void setSelected(bool);
47         ///
48         std::string const getColor() const;
49         ///
50         void setColor(std::string const &);
51
52
53 private:
54         ///
55         std::string branch_;
56         ///
57         bool selected_;
58         ///
59         std::string color_;
60 };
61
62
63 class BranchList {
64 public:
65         ///
66         BranchList() : separator_("|") {}
67
68         ///
69         typedef std::list<Branch> List;
70
71         ///
72         void clear();
73         ///
74         bool empty() { return list.empty(); }
75         ///
76         bool size() const { return list.size(); }
77         ///
78         List::const_iterator begin() const { return list.begin(); }
79         ///
80         List::const_iterator end() const { return list.end(); }
81         ///
82         std::string getColor(std::string const &) const;
83         ///
84         void setColor(std::string const &, std::string const &);
85         /// Select/deselect multiple branches given in '|'-separated string
86         void setSelected(std::string const &, bool);
87         /// Add multiple branches to list
88         void add(std::string const &);
89         /// remove a branch from list by name
90         void remove(std::string const &);
91         /// return whether this branch is selected
92         bool selected(std::string const &) const;
93         /// return, as a '|'-separated string, all branch names
94         std::string allBranches() const;
95         ///
96         std::string allSelected() const;
97         ///
98         std::string const separator() const;
99
100 private:
101         ///
102         List list;
103         ///
104         std::string separator_;
105 };
106
107 #endif