Squid Web Cache
master
Loading...
Searching...
No Matches
SwapMetaView.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3
*
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.
7
*/
8
9
#ifndef SQUID_SRC_STORE_SWAPMETAVIEW_H
10
#define SQUID_SRC_STORE_SWAPMETAVIEW_H
11
12
#include "
base/TextException.h
"
13
#include "
store/SwapMeta.h
"
14
15
#include <iosfwd>
16
17
namespace
Store
{
18
20
class
SwapMetaView
21
{
22
public
:
24
void
checkExpectedLength
(
size_t
)
const
;
25
26
public
:
30
const
void
*
rawValue
=
nullptr
;
31
35
size_t
rawLength
= 0;
36
39
RawSwapMetaType
rawType
=
RawSwapMetaTypeBottom
;
40
43
SwapMetaType
type
=
STORE_META_VOID
;
44
45
private
:
46
/*
47
* SwapMetaView objects should always be accessed through SwapMetaIterator
48
* or SwapMetaUnpacker for read-only access to the current view of metadata.
49
*/
50
friend
class
SwapMetaIterator
;
51
52
SwapMetaView
() =
default
;
53
SwapMetaView
(
const
SwapMetaView
&) =
default
;
54
SwapMetaView
(
SwapMetaView
&&) =
default
;
55
SwapMetaView
&
operator =
(
const
SwapMetaView
&) =
default
;
56
SwapMetaView
&
operator =
(
SwapMetaView
&&) =
default
;
57
61
explicit
SwapMetaView
(
const
void
*begin,
const
void
*
const
end);
62
};
63
66
template
<
typename
Item>
67
void
68
SwapMetaExtract
(Item &item,
const
char
* &input,
const
void
*end)
69
{
70
if
(input +
sizeof
(item) > end)
71
throw
TextException
(
"truncated swap meta part"
,
Here
());
72
memcpy(&item, input,
sizeof
(item));
73
input +=
sizeof
(item);
74
}
75
77
std::ostream &
operator <<
(std::ostream &,
const
SwapMetaView &);
78
79
}
// namespace Store
80
81
#endif
/* SQUID_SRC_STORE_SWAPMETAVIEW_H */
82
Here
#define Here()
source code location of the caller
Definition
Here.h:15
SwapMeta.h
TextException.h
Store::SwapMetaIterator
iterates serialized swap meta fields loaded into a given buffer
Definition
SwapMetaIn.cc:27
Store::SwapMetaView
a swap metadata field inside the buffer given to SwapMetaUnpacker
Definition
SwapMetaView.h:21
Store::SwapMetaView::checkExpectedLength
void checkExpectedLength(size_t) const
ensures that our fixed-size field value has the given expected length
Definition
SwapMetaView.cc:83
Store::SwapMetaView::rawLength
size_t rawLength
Definition
SwapMetaView.h:35
Store::SwapMetaView::rawType
RawSwapMetaType rawType
Definition
SwapMetaView.h:39
Store::SwapMetaView::SwapMetaView
SwapMetaView(const SwapMetaView &)=default
Store::SwapMetaView::type
SwapMetaType type
Definition
SwapMetaView.h:43
Store::SwapMetaView::rawValue
const void * rawValue
Definition
SwapMetaView.h:30
Store::SwapMetaView::operator=
SwapMetaView & operator=(const SwapMetaView &)=default
Store::SwapMetaView::SwapMetaView
SwapMetaView()=default
Store::SwapMetaView::SwapMetaView
SwapMetaView(SwapMetaView &&)=default
TextException
an std::runtime_error with thrower location info
Definition
TextException.h:21
Store
Definition
SquidConfig.h:62
Store::RawSwapMetaTypeBottom
const RawSwapMetaType RawSwapMetaTypeBottom
Definition
SwapMeta.h:126
Store::SwapMetaExtract
void SwapMetaExtract(Item &item, const char *&input, const void *end)
Definition
SwapMetaView.h:68
Store::RawSwapMetaType
char RawSwapMetaType
Definition
SwapMeta.h:95
Store::operator<<
std::ostream & operator<<(std::ostream &os, const ParsingBuffer &b)
Definition
ParsingBuffer.h:119
Store::SwapMetaType
SwapMetaType
Definition
SwapMeta.h:52
Store::STORE_META_VOID
@ STORE_META_VOID
Definition
SwapMeta.h:55
squid
src
store
SwapMetaView.h
Generated by
1.9.8