3 * \file filefilterlist.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
12 #ifndef FILE_FILTER_LIST_H
13 #define FILE_FILTER_LIST_H
21 /** \c FileFilterList parses a Qt-style list of available file filters
22 * to generate the corresponding vector.
23 * For example "TeX documents (*.tex);;LyX Documents (*.lyx)"
24 * will be parsed to fill a vector of size 2, whilst "*.{p[bgp]m} *.pdf"
25 * will result in a vector of size 1 in which the description field is empty.
27 class FileFilterList {
31 std::vector<std::string> globs_;
33 /* \param description text describing the filters.
34 * \param one or more wildcard patterns, separated by
37 Filter(std::string const & description,
38 std::string const & globs);
40 std::string const & description() const { return desc_; }
42 typedef std::vector<std::string>::const_iterator glob_iterator;
43 glob_iterator begin() const { return globs_.begin(); }
44 glob_iterator end() const { return globs_.end(); }
47 /** \param qt_style_filter a list of available file filters.
48 * Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
49 * The "All files (*)" filter is always added to the list.
51 explicit FileFilterList(std::string const & qt_style_filter =
54 typedef std::vector<Filter>::size_type size_type;
56 bool empty() const { return filters_.empty(); }
57 size_type size() const { return filters_.size(); }
58 Filter & operator[](size_type i) { return filters_[i]; }
59 Filter const & operator[](size_type i) const { return filters_[i]; }
61 /** \returns the equivalent of the string passed to the c-tor
62 * although any brace expressions are expanded.
63 * (E.g. "*.{png,jpg}" -> "*.png *.jpg")
65 std::string const as_string() const;
68 void parse_filter(std::string const & filter);
69 std::vector<Filter> filters_;
72 } // namespace support
75 #endif // NOT FILE_FILTER_LIST_H