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.
40 std::string const & getBranch() const;
42 void setBranch(std::string const &);
44 bool getSelected() const;
45 /** Select/deselect the branch.
46 * \return true if the selection status changes.
48 bool setSelected(bool);
50 std::string const & getColor() const;
52 void setColor(std::string const &);
67 typedef std::list<Branch> List;
69 typedef List::const_iterator const_iterator;
72 BranchList() : separator_("|") {}
75 bool empty() { return list.empty(); }
77 const_iterator begin() const { return list.begin(); }
78 const_iterator end() const { return list.end(); }
80 /** \returns the Branch with \c name. If not found, returns 0.
82 Branch * find(std::string const & name);
83 Branch const * find(std::string const & name) const;
85 /** Add (possibly multiple (separated by separator())) branches to list
86 * \returns true if a branch is added.
88 bool add(std::string const &);
89 /** remove a branch from list by name
90 * \returns true if a branch is removed.
92 bool remove(std::string const &);
98 std::string separator_;
102 class BranchNamesEqual : public std::unary_function<Branch, bool> {
104 BranchNamesEqual(std::string const & name)
106 bool operator()(Branch const & branch) const
108 return branch.getBranch() == name_;