libDwm-0.9.45
DwmBZ2IOCapable.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2020, 2024
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
42//---------------------------------------------------------------------------
43
44#ifndef _DWMBZ2IOCAPABLE_HH_
45#define _DWMBZ2IOCAPABLE_HH_
46
47extern "C" {
48 #include <sys/types.h>
49 #include <bzlib.h>
50}
51
52#include <cstdio>
53
54namespace Dwm {
55
56 //--------------------------------------------------------------------------
59 //--------------------------------------------------------------------------
60 template <typename T>
61 concept HasBZRead = requires(T & t, BZFILE *bzf) {
62 { t.BZRead(bzf) } -> std::same_as<int>;
63 };
64
65 //--------------------------------------------------------------------------
68 //--------------------------------------------------------------------------
69 template <typename T>
70 concept HasBZWrite = requires(const T & t, BZFILE *bzf) {
71 { ((const T)t).BZWrite(bzf) } -> std::same_as<int>;
72 };
73
74 //--------------------------------------------------------------------------
77 //--------------------------------------------------------------------------
79 {
80 public:
81 virtual ~BZ2Readable() { }
82
83 //------------------------------------------------------------------------
86 //------------------------------------------------------------------------
87 virtual int BZRead(BZFILE *bzf) = 0;
88 };
89
90 //--------------------------------------------------------------------------
93 //--------------------------------------------------------------------------
95 {
96 public:
97 virtual ~BZ2Writable() { }
98
99 //------------------------------------------------------------------------
102 //------------------------------------------------------------------------
103 virtual int BZWrite(BZFILE *bzf) const = 0;
104 };
105
106 //--------------------------------------------------------------------------
108 //--------------------------------------------------------------------------
110 : public BZ2Readable, public BZ2Writable
111 {};
112
113} // namespace Dwm
114
115#endif // _DWMBZ2IOCAPABLE_HH_
116
117
118//---------------------------- emacs settings -----------------------------
119// Local Variables:
120// mode: C++
121// tab-width: 2
122// indent-tabs-mode: nil
123// c-basic-offset: 2
124// End:
125//-------------------------------------------------------------------------
Interface for classes with BZ2IO read and write capabilities.
Definition DwmBZ2IOCapable.hh:111
This class is a pure virtual class, defining an interface for classes that can read their contents fr...
Definition DwmBZ2IOCapable.hh:79
virtual int BZRead(BZFILE *bzf)=0
Read from a BZFILE pointer.
This class is a pure virtual class, defining an interface for classes that can write their contents t...
Definition DwmBZ2IOCapable.hh:95
virtual int BZWrite(BZFILE *bzf) const =0
Write to a BZFILE pointer.
T has a BZRead(BZFILE *) member that returns int (return value of BZ2_bzread() on success,...
Definition DwmBZ2IOCapable.hh:61
T has a BZWrite(BZFILE *) const member that returns int (return value of BZ2_bzwrite() on success,...
Definition DwmBZ2IOCapable.hh:70