libDwm-0.6.0
DwmFreeBSDPkgManifest.hh
Go to the documentation of this file.
1 //===========================================================================
2 // @(#) $Name:$
3 // @(#) $Id: DwmFreeBSDPkgManifest.hh 8434 2016-04-29 01:38:22Z dwm $
4 //===========================================================================
5 // Copyright (c) Daniel W. McRobb 2016
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // 1. Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // 3. The names of the authors and copyright holders may not be used to
18 // endorse or promote products derived from this software without
19 // specific prior written permission.
20 //
21 // IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
22 // DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
23 // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
24 // EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
25 // DAMAGE.
26 //
27 // THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
28 // DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
29 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
30 // REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
31 // IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
33 // OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
34 // TRADEMARK OR OTHER RIGHTS.
35 //===========================================================================
36 
37 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 
42 #ifndef _DWMFREEBSDPKGMANIFEST_HH_
43 #define _DWMFREEBSDPKGMANIFEST_HH_
44 
45 #include <iostream>
46 #include <string>
47 #include <vector>
48 
49 namespace Dwm {
50 
51  namespace FreeBSDPkg {
52 
53  //------------------------------------------------------------------------
55  //------------------------------------------------------------------------
56  class Manifest
57  {
58  public:
59  //----------------------------------------------------------------------
61  //----------------------------------------------------------------------
62  class Dependency
63  {
64  public:
65  Dependency() = default;
66  Dependency(const std::string & name, const std::string & origin,
67  const std::string & version);
68  const std::string & Name() const;
69  const std::string & Name(const std::string & name);
70  const std::string & Version() const;
71  const std::string & Version(const std::string & version);
72  const std::string & Origin() const;
73  const std::string & Origin(const std::string & origin);
74 
75  friend std::ostream & operator << (std::ostream & os,
76  const Dependency & dep);
77  private:
78  std::string _name;
79  std::string _version;
80  std::string _origin;
81  };
82 
83  //----------------------------------------------------------------------
85  //----------------------------------------------------------------------
86  class Option
87  {
88  public:
89  const std::string & Name() const;
90  const std::string & Name(const std::string & name);
91  const std::string & Value() const;
92  const std::string & Value(const std::string & value);
93 
94  friend std::ostream & operator << (std::ostream & os,
95  const Option & option);
96 
97  private:
98  std::string _name;
99  std::string _value;
100  };
101 
102  //----------------------------------------------------------------------
104  //----------------------------------------------------------------------
105  class File
106  {
107  public:
108  File() = default;
109  File(const std::string & path, const std::string sha256 = "",
110  const std::string & user = "", const std::string group = "",
111  mode_t mode = 0);
112  const std::string & Path() const;
113  const std::string & Path(const std::string & path);
114  const std::string & SHA256() const;
115  const std::string & SHA256(const std::string & sha256);
116  const std::string & User() const;
117  const std::string & User(const std::string & user);
118  const std::string & Group() const;
119  const std::string & Group(const std::string & group);
120  mode_t Mode() const;
121  mode_t Mode(mode_t mode);
122 
123  friend std::ostream & operator << (std::ostream & os,
124  const File & file);
125 
126  private:
127  std::string _path;
128  std::string _sha256;
129  std::string _user;
130  std::string _group;
131  mode_t _mode;
132  };
133 
134  const std::string & Name() const;
135  const std::string & Name(const std::string & name);
136  const std::string & Version() const;
137  const std::string & Version(const std::string & version);
138  const std::string & Origin() const;
139  const std::string & Origin(const std::string & origin);
140  const std::string & Comment() const;
141  const std::string & Comment(const std::string & comment);
142  const std::string & Description() const;
143  const std::string & Description(const std::string & description);
144  const std::string & Arch() const;
145  const std::string & Arch(const std::string & arch);
146  const std::string & WWW() const;
147  const std::string & WWW(const std::string & www);
148  const std::string & Maintainer() const;
149  const std::string & Maintainer(const std::string & maintainer);
150  const std::string & Prefix() const;
151  const std::string & Prefix(const std::string & prefix);
152  const std::string & LicenseLogic() const;
153  const std::string & LicenseLogic(const std::string & licenseLogic);
154 
155  const std::vector<std::string> & Categories() const;
156 
157  const std::vector<std::string> &
158  Categories(const std::vector<std::string> & categories);
159 
160  const std::vector<std::string> & Licenses() const;
161 
162  const std::vector<std::string> &
163  Licenses(const std::vector<std::string> & licenses);
164 
165  size_t Flatsize() const;
166  size_t Flatsize(size_t flatsize);
167  const std::vector<Dependency> & Dependencies() const;
168  std::vector<Dependency> & Dependencies();
169  const std::vector<Dependency> &
170  Dependencies(const std::vector<Dependency> & dependencies);
171  const std::string & Conflict() const;
172  const std::string & Conflict(const std::string conflict);
173  const std::vector<Option> & Options() const;
174  std::vector<Option> & Options();
175  const std::vector<File> & Files() const;
176  std::vector<File> & Files();
177  const std::vector<File> & Files(const std::vector<File> & files);
178 
179  const std::string & PostInstall() const;
180 
181  const std::string & PostInstall(const std::string & postInstall);
182 
183  const std::string & PreInstall() const;
184 
185  const std::string & PreInstall(const std::string & preInstall);
186 
187  const std::string & Install() const;
188 
189  const std::string & Install(const std::string & install);
190 
191  const std::string & PreDeinstall() const;
192 
193  const std::string & PreDeinstall(const std::string & preDeinstall);
194 
195  const std::string & PostDeinstall() const;
196 
197  const std::string & PostDeinstall(const std::string & postDeinstall);
198 
199  const std::string & Deinstall() const;
200 
201  const std::string & Deinstall(const std::string & deinstall);
202 
203  const std::string & PreUpgrade() const;
204 
205  const std::string & PreUpgrade(const std::string & preUpgrade);
206 
207  const std::string & PostUpgrade() const;
208 
209  const std::string & PostUpgrade(const std::string & postUpgrade);
210 
211  const std::string & Upgrade() const;
212 
213  const std::string & Upgrade(const std::string & upgrade);
214 
215  bool Parse(const char *filename);
216 
217  std::vector<File> MissingFiles(const std::string & dirName) const;
218 
219  friend std::ostream & operator << (std::ostream & os,
220  const Manifest & manifest);
221 
222  private:
223  std::string _name;
224  std::string _version;
225  std::string _origin;
226  std::string _comment;
227  std::string _description;
228  std::string _arch;
229  std::string _www;
230  std::string _maintainer;
231  std::string _prefix;
232  std::string _licenseLogic;
233  std::vector<std::string> _categories;
234  std::vector<std::string> _licenses;
235  size_t _flatsize;
236  std::vector<Dependency> _dependencies;
237  std::string _conflict;
238  std::vector<Option> _options;
239  std::vector<File> _files;
240  std::string _postInstall;
241  std::string _preInstall;
242  std::string _install;
243  std::string _postDeinstall;
244  std::string _preDeinstall;
245  std::string _deinstall;
246  std::string _postUpgrade;
247  std::string _preUpgrade;
248  std::string _upgrade;
249  };
250 
251 
252  } // namespace FreeBSDPkg
253 
254 } // namespace Dwm
255 
256 #endif // _DWMFREEBSDPKGMANIFEST_HH_
Definition: DwmBZ2IO.hh:67