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"
47 docstring const & branch() const;
49 void setBranch(docstring const &);
51 bool isSelected() const;
52 /** Select/deselect the branch.
53 * \return true if the selection status changes.
55 bool setSelected(bool);
57 RGBColor const & color() const;
59 void setColor(RGBColor const &);
61 * Set color from a string "#rrggbb".
62 * Use Color:background if the string is no valid color.
63 * This ensures compatibility with LyX 1.4.0 that had the symbolic
64 * color "none" that was displayed as Color:background.
66 void setColor(std::string const &);
80 typedef std::list<Branch> List;
82 typedef List::const_iterator const_iterator;
85 BranchList() : separator_(from_ascii("|")) {}
88 bool empty() const { return list.empty(); }
90 void clear() { list.clear(); }
92 const_iterator begin() const { return list.begin(); }
93 const_iterator end() const { return list.end(); }
95 /** \returns the Branch with \c name. If not found, returns 0.
97 Branch * find(docstring const & name);
98 Branch const * find(docstring const & name) const;
100 /** Add (possibly multiple (separated by separator())) branches to list
101 * \returns true if a branch is added.
103 bool add(docstring const &);
104 /** remove a branch from list by name
105 * \returns true if a branch is removed.
107 bool remove(docstring const &);
108 /** rename an branch in list
109 * \returns true if renaming succeeded.
110 * if \p merge is true, the branch will be removed
111 * if a branch with the newname already exists.
113 bool rename(docstring const &, docstring const &, bool const merge = false);
119 docstring separator_;
124 #endif // BRANCHLIST_H