2003-09-09 18:27:24 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-17 11:28:23 +00:00
|
|
|
/**
|
2003-09-09 18:27:24 +00:00
|
|
|
* \file BranchList.h
|
2003-08-17 11:28:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2010-05-03 13:36:19 +00:00
|
|
|
*
|
2003-08-17 11:28:23 +00:00
|
|
|
* \author Martin Vermeer
|
2003-09-09 18:27:24 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2010-05-03 13:36:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BRANCHLIST_H
|
|
|
|
#define BRANCHLIST_H
|
|
|
|
|
|
|
|
#include "ColorCode.h"
|
|
|
|
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
/**
|
2003-08-17 11:28:23 +00:00
|
|
|
* \class Branch
|
|
|
|
*
|
|
|
|
* A class describing a 'branch', i.e., a named alternative for
|
|
|
|
* selectively outputting some parts of a document while suppressing
|
|
|
|
* other parts.
|
|
|
|
*
|
|
|
|
* A branch has a name, can either be selected or not, and uses a
|
2010-05-03 13:36:19 +00:00
|
|
|
* user-specifiable background colour. All these can be set and
|
2003-08-17 11:28:23 +00:00
|
|
|
* queried.
|
2003-09-09 18:27:24 +00:00
|
|
|
*
|
2003-08-17 11:28:23 +00:00
|
|
|
* \class BranchList
|
|
|
|
*
|
|
|
|
* A class containing a vector of all defined branches within a
|
2010-05-03 13:36:19 +00:00
|
|
|
* document. It has methods for selecting or deselecting branches by
|
2003-08-17 11:28:23 +00:00
|
|
|
* name, for outputting a '|'-separated string of all elements or only
|
|
|
|
* the selected ones, and for adding and removing elements.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Branch {
|
|
|
|
public:
|
2006-03-23 20:04:05 +00:00
|
|
|
///
|
|
|
|
Branch();
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-09-21 19:27:20 +00:00
|
|
|
docstring const & branch() const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
void setBranch(docstring const &);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-09-21 19:27:20 +00:00
|
|
|
bool isSelected() const;
|
2003-12-14 16:33:56 +00:00
|
|
|
/** Select/deselect the branch.
|
|
|
|
* \return true if the selection status changes.
|
|
|
|
*/
|
|
|
|
bool setSelected(bool);
|
2009-07-13 14:30:08 +00:00
|
|
|
/** If true, the branch name will be appended
|
|
|
|
* to the output file name.
|
|
|
|
*/
|
2010-04-21 01:19:35 +00:00
|
|
|
bool hasFileNameSuffix() const;
|
2009-07-13 14:30:08 +00:00
|
|
|
/// Select/deselect filename suffix property.
|
2010-04-21 01:19:35 +00:00
|
|
|
void setFileNameSuffix(bool);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2021-01-18 08:56:53 +00:00
|
|
|
std::string const & color() const;
|
2006-03-23 20:04:05 +00:00
|
|
|
/**
|
|
|
|
* Set color from a string "#rrggbb".
|
2007-04-26 17:34:20 +00:00
|
|
|
* Use Color:background if the string is no valid color.
|
2006-03-23 20:04:05 +00:00
|
|
|
* This ensures compatibility with LyX 1.4.0 that had the symbolic
|
2007-04-26 17:34:20 +00:00
|
|
|
* color "none" that was displayed as Color:background.
|
2006-03-23 20:04:05 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
void setColor(std::string const &);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
docstring branch_;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
|
|
|
bool selected_;
|
|
|
|
///
|
2009-07-13 14:30:08 +00:00
|
|
|
bool filenameSuffix_;
|
|
|
|
///
|
2021-01-18 08:56:53 +00:00
|
|
|
std::string color_;
|
2003-08-17 11:28:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BranchList {
|
|
|
|
///
|
|
|
|
typedef std::list<Branch> List;
|
2003-12-14 16:33:56 +00:00
|
|
|
public:
|
|
|
|
typedef List::const_iterator const_iterator;
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
BranchList() : separator_(from_ascii("|")) {}
|
2003-12-14 16:33:56 +00:00
|
|
|
|
2010-06-14 13:39:08 +00:00
|
|
|
///
|
|
|
|
docstring separator() const { return separator_; }
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-02-28 06:08:28 +00:00
|
|
|
bool empty() const { return list_.empty(); }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-02-28 06:08:28 +00:00
|
|
|
void clear() { list_.clear(); }
|
2005-03-27 13:31:04 +00:00
|
|
|
///
|
2020-02-28 06:08:28 +00:00
|
|
|
const_iterator begin() const { return list_.begin(); }
|
|
|
|
const_iterator end() const { return list_.end(); }
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
|
|
/** \returns the Branch with \c name. If not found, returns 0.
|
|
|
|
*/
|
2006-11-03 15:16:45 +00:00
|
|
|
Branch * find(docstring const & name);
|
|
|
|
Branch const * find(docstring const & name) const;
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
|
|
/** Add (possibly multiple (separated by separator())) branches to list
|
|
|
|
* \returns true if a branch is added.
|
|
|
|
*/
|
2006-11-03 15:16:45 +00:00
|
|
|
bool add(docstring const &);
|
2003-12-14 16:33:56 +00:00
|
|
|
/** remove a branch from list by name
|
|
|
|
* \returns true if a branch is removed.
|
|
|
|
*/
|
2006-11-03 15:16:45 +00:00
|
|
|
bool remove(docstring const &);
|
2009-07-10 06:49:51 +00:00
|
|
|
/** rename an branch in list
|
|
|
|
* \returns true if renaming succeeded.
|
|
|
|
* if \p merge is true, the branch will be removed
|
|
|
|
* if a branch with the newname already exists.
|
|
|
|
*/
|
|
|
|
bool rename(docstring const &, docstring const &, bool const merge = false);
|
2009-07-13 14:30:08 +00:00
|
|
|
/// get the complete filename suffix
|
2010-04-21 01:19:35 +00:00
|
|
|
docstring getFileNameSuffix() const;
|
2003-09-09 18:27:24 +00:00
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
private:
|
|
|
|
///
|
2020-02-28 06:08:28 +00:00
|
|
|
List list_;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
docstring separator_;
|
2003-08-17 11:28:23 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-09-21 19:27:20 +00:00
|
|
|
#endif // BRANCHLIST_H
|