paludis  Version 2.6.0
set_file.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_SET_FILE_HH
21 #define PALUDIS_GUARD_PALUDIS_SET_FILE_HH 1
22 
23 #include <paludis/util/pimp.hh>
25 #include <paludis/util/fs_path.hh>
26 #include <paludis/util/options.hh>
27 #include <paludis/util/named_value.hh>
28 #include <paludis/name.hh>
29 #include <paludis/spec_tree.hh>
30 #include <paludis/dep_spec-fwd.hh>
31 #include <functional>
32 #include <iosfwd>
33 
34 /** \file
35  * Declarations for the SetFile classes, which are used by Environment and
36  * Repository implementations for files containing a package set.
37  *
38  * \ingroup g_environment
39  * \ingroup g_repository
40  *
41  * \section Examples
42  *
43  * - None at this time.
44  */
45 
46 namespace paludis
47 {
48  class Environment;
49 
50 #include <paludis/set_file-se.hh>
51 
52  namespace n
53  {
54  typedef Name<struct name_environment> environment;
55  typedef Name<struct name_file_name> file_name;
56  typedef Name<struct name_parser> parser;
57  typedef Name<struct name_set_operator_mode> set_operator_mode;
58  typedef Name<struct name_tag> tag;
59  typedef Name<struct name_type> type;
60  }
61 
62  /**
63  * Parameters for a SetFile.
64  *
65  * \ingroup g_environment
66  * \ingroup g_repository
67  */
69  {
75  };
76 
77  /**
78  * Thrown if there is a problem reading or writing a SetFile.
79  *
80  * \ingroup g_environment
81  * \ingroup g_repository
82  * \ingroup g_exceptions
83  * \nosubgrouping
84  */
86  public ConfigurationError
87  {
88  public:
89  ///\name Basic operations
90  ///\{
91 
92  SetFileError(const FSPath &, const std::string &) noexcept;
93 
94  ///\}
95  };
96 
97  /**
98  * Shared code for files containing a package set.
99  *
100  * Various set file formats are supported:
101  *
102  * - sft_paludis_conf, a line-based set file with prefixed entries
103  * - sft_paludis_bash, a bash script that outputs an sft_paludis_conf
104  * - sft_simple, a simple line-based file
105  *
106  * The file can be modified if it is sft_paludis_conf or sft_simple.
107  *
108  * \ingroup g_environment
109  * \ingroup g_repository
110  * \nosubgrouping
111  */
113  {
114  private:
115  Pimp<SetFile> _imp;
116 
117  public:
118  ///\name Basic operations
119  ///\{
120 
121  SetFile(const SetFileParams &);
122  ~SetFile();
123 
124  SetFile(const SetFile &) = delete;
125  SetFile & operator= (const SetFile &) = delete;
126 
127  ///\}
128 
129  /**
130  * Fetch our contents.
131  */
132  const std::shared_ptr<const SetSpecTree> contents() const;
133 
134  /**
135  * Rewrite our contents.
136  */
137  void rewrite() const;
138 
139  /**
140  * Add an item to our contents, if it is not there already.
141  *
142  * \since 0.49 returns whether any lines were added
143  */
144  bool add(const std::string &);
145 
146  /**
147  * Remove any matching lines.
148  *
149  * \since 0.48 returns whether any lines were removed
150  */
151  bool remove(const std::string &);
152  };
153 
154  /**
155  * Split a SetName into a SetName and a SetFileSetOperatorMode.
156  *
157  * \see SetName
158  * \ingroup g_repository
159  * \since 0.26
160  */
161  std::pair<SetName, SetFileSetOperatorMode> find_base_set_name_and_suffix_mode(const SetName &)
162  PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
163 }
164 
165 #endif
Definition: named_value-fwd.hh:29
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: set_file.hh:85
Definition: set_file.hh:68
Definition: set_file.hh:112
Definition: environment.hh:200
Definition: named_value-fwd.hh:26
Definition: wrapped_value-fwd.hh:29
Definition: exception.hh:200
Definition: fs_path.hh:33
std::pair< SetName, SetFileSetOperatorMode > find_base_set_name_and_suffix_mode(const SetName &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result))
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59