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.
33 #include "ColorCode.h"
35 #include "support/docstring.h"
48 docstring const & getBranch() const;
50 void setBranch(docstring const &);
52 bool getSelected() const;
53 /** Select/deselect the branch.
54 * \return true if the selection status changes.
56 bool setSelected(bool);
58 RGBColor const & getColor() const;
60 void setColor(RGBColor const &);
62 * Set color from a string "#rrggbb".
63 * Use Color:background if the string is no valid color.
64 * This ensures compatibility with LyX 1.4.0 that had the symbolic
65 * color "none" that was displayed as Color:background.
67 void setColor(std::string const &);
81 typedef std::list<Branch> List;
83 typedef List::const_iterator const_iterator;
86 BranchList() : separator_(from_ascii("|")) {}
89 bool empty() const { return list.empty(); }
91 void clear() { list.clear(); }
93 const_iterator begin() const { return list.begin(); }
94 const_iterator end() const { return list.end(); }
96 /** \returns the Branch with \c name. If not found, returns 0.
98 Branch * find(docstring const & name);
99 Branch const * find(docstring const & name) const;
101 /** Add (possibly multiple (separated by separator())) branches to list
102 * \returns true if a branch is added.
104 bool add(docstring const &);
105 /** remove a branch from list by name
106 * \returns true if a branch is removed.
108 bool remove(docstring const &);
114 docstring separator_;
118 class BranchNamesEqual : public std::unary_function<Branch, bool> {
120 BranchNamesEqual(docstring const & name)
122 bool operator()(Branch const & branch) const
124 return branch.getBranch() == name_;