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.
44 std::string const & getBranch() const;
46 void setBranch(std::string const &);
48 bool getSelected() const;
49 /** Select/deselect the branch.
50 * \return true if the selection status changes.
52 bool setSelected(bool);
54 lyx::RGBColor const & getColor() const;
56 void setColor(lyx::RGBColor const &);
58 * Set color from a string "#rrggbb".
59 * Use LColor:background if the string is no valid color.
60 * This ensures compatibility with LyX 1.4.0 that had the symbolic
61 * color "none" that was displayed as LColor:background.
63 void setColor(std::string const &);
78 typedef std::list<Branch> List;
80 typedef List::const_iterator const_iterator;
83 BranchList() : separator_("|") {}
86 bool empty() const { return list.empty(); }
88 void clear() { list.clear(); }
90 const_iterator begin() const { return list.begin(); }
91 const_iterator end() const { return list.end(); }
93 /** \returns the Branch with \c name. If not found, returns 0.
95 Branch * find(std::string const & name);
96 Branch const * find(std::string const & name) const;
98 /** Add (possibly multiple (separated by separator())) branches to list
99 * \returns true if a branch is added.
101 bool add(std::string const &);
102 /** remove a branch from list by name
103 * \returns true if a branch is removed.
105 bool remove(std::string const &);
111 std::string separator_;
115 class BranchNamesEqual : public std::unary_function<Branch, bool> {
117 BranchNamesEqual(std::string const & name)
119 bool operator()(Branch const & branch) const
121 return branch.getBranch() == name_;