4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
6 * \author Martin Vermeer
8 * Full author contact details are available in file CREDITS.
13 * A class describing a 'branch', i.e., a named alternative for
14 * selectively outputting some parts of a document while suppressing
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
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.
46 docstring
const & getBranch() const;
48 void setBranch(docstring
const &);
50 bool getSelected() const;
51 /** Select/deselect the branch.
52 * \return true if the selection status changes.
54 bool setSelected(bool);
56 RGBColor
const & getColor() const;
58 void setColor(RGBColor
const &);
60 * Set color from a string "#rrggbb".
61 * Use Color:background if the string is no valid color.
62 * This ensures compatibility with LyX 1.4.0 that had the symbolic
63 * color "none" that was displayed as Color:background.
65 void setColor(std::string
const &);
79 typedef std::list
<Branch
> List
;
81 typedef List::const_iterator const_iterator
;
84 BranchList() : separator_(from_ascii("|")) {}
87 bool empty() const { return list
.empty(); }
89 void clear() { list
.clear(); }
91 const_iterator
begin() const { return list
.begin(); }
92 const_iterator
end() const { return list
.end(); }
94 /** \returns the Branch with \c name. If not found, returns 0.
96 Branch
* find(docstring
const & name
);
97 Branch
const * find(docstring
const & name
) const;
99 /** Add (possibly multiple (separated by separator())) branches to list
100 * \returns true if a branch is added.
102 bool add(docstring
const &);
103 /** remove a branch from list by name
104 * \returns true if a branch is removed.
106 bool remove(docstring
const &);
112 docstring separator_
;
116 class BranchNamesEqual
: public std::unary_function
<Branch
, bool> {
118 BranchNamesEqual(docstring
const & name
)
120 bool operator()(Branch
const & branch
) const
122 return branch
.getBranch() == name_
;