SwapMetaView.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
17namespace Store {
18
21{
22public:
24 void checkExpectedLength(size_t) const;
25
26public:
30 const void *rawValue = nullptr;
31
35 size_t rawLength = 0;
36
40
44
45private:
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;
57
61 explicit SwapMetaView(const void *begin, const void * const end);
62};
63
66template <typename Item>
67void
68SwapMetaExtract(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
77std::ostream &operator <<(std::ostream &, const SwapMetaView &);
78
79} // namespace Store
80
81#endif /* SQUID_SRC_STORE_SWAPMETAVIEW_H */
82
#define Here()
source code location of the caller
Definition: Here.h:15
iterates serialized swap meta fields loaded into a given buffer
Definition: SwapMetaIn.cc:27
a swap metadata field inside the buffer given to SwapMetaUnpacker
Definition: SwapMetaView.h:21
void checkExpectedLength(size_t) const
ensures that our fixed-size field value has the given expected length
Definition: SwapMetaView.cc:83
RawSwapMetaType rawType
Definition: SwapMetaView.h:39
SwapMetaView(const SwapMetaView &)=default
SwapMetaType type
Definition: SwapMetaView.h:43
const void * rawValue
Definition: SwapMetaView.h:30
SwapMetaView & operator=(const SwapMetaView &)=default
SwapMetaView()=default
SwapMetaView(SwapMetaView &&)=default
an std::runtime_error with thrower location info
Definition: TextException.h:21
const RawSwapMetaType RawSwapMetaTypeBottom
Definition: SwapMeta.h:126
void SwapMetaExtract(Item &item, const char *&input, const void *end)
Definition: SwapMetaView.h:68
char RawSwapMetaType
Definition: SwapMeta.h:95
std::ostream & operator<<(std::ostream &os, const ParsingBuffer &b)
SwapMetaType
Definition: SwapMeta.h:52
@ STORE_META_VOID
Definition: SwapMeta.h:55

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors