]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreIOBuffer.h
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_STOREIOBUFFER_H
10 #define SQUID_STOREIOBUFFER_H
12 #include "base/Range.h"
19 StoreIOBuffer():length(0), offset (0), data (nullptr) {flags
.error
= 0;}
21 StoreIOBuffer(size_t aLength
, int64_t anOffset
, char *someData
) :
22 length (aLength
), offset (anOffset
), data (someData
) {
26 /* Create a StoreIOBuffer from a MemBuf and offset */
27 /* NOTE that MemBuf still "owns" the pointers, StoreIOBuffer is just borrowing them */
28 StoreIOBuffer(MemBuf
*aMemBuf
, int64_t anOffset
) :
29 length(aMemBuf
->contentSize()),
31 data(aMemBuf
->content()) {
35 StoreIOBuffer(MemBuf
*aMemBuf
, int64_t anOffset
, size_t anLength
) :
38 data(aMemBuf
->content()) {
42 Range
<int64_t> range() const {
43 return Range
<int64_t>(offset
, offset
+ length
);
47 if (fwrite(data
, length
, 1, stderr
)) {}
48 if (fwrite("\n", 1, 1, stderr
)) {}
61 operator <<(std::ostream
&os
, const StoreIOBuffer
&b
)
63 return os
<< "ioBuf(@" << b
.offset
<< ", len=" << b
.length
<< ", " <<
64 (void*)b
.data
<< (b
.flags
.error
? ", ERR" : "") << ')';
67 #endif /* SQUID_STOREIOBUFFER_H */