SwapMetaView.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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 "store/SwapMeta.h"
13
14#include <iosfwd>
15
16namespace Store {
17
20{
21public:
23 void checkExpectedLength(size_t) const;
24
25public:
29 const void *rawValue = nullptr;
30
34 size_t rawLength = 0;
35
39
43
44private:
45 /*
46 * SwapMetaView objects should always be accessed through SwapMetaIterator
47 * or SwapMetaUnpacker for read-only access to the current view of metadata.
48 */
49 friend class SwapMetaIterator;
50
51 SwapMetaView() = default;
52 SwapMetaView(const SwapMetaView &) = default;
56
60 explicit SwapMetaView(const void *begin, const void * const end);
61};
62
65template <typename Item>
66void
67SwapMetaExtract(Item &item, const char * &input, const void *end)
68{
69 if (input + sizeof(item) > end)
70 throw TextException("truncated swap meta part", Here());
71 memcpy(&item, input, sizeof(item));
72 input += sizeof(item);
73}
74
75} // namespace Store
76
78std::ostream &operator <<(std::ostream &, const Store::SwapMetaView &);
79
80#endif /* SQUID_SRC_STORE_SWAPMETAVIEW_H */
81
#define Here()
source code location of the caller
Definition: Here.h:15
std::ostream & operator<<(std::ostream &, const Store::SwapMetaView &)
writes a short human-readable summary of the given SwapMetaView object
Definition: SwapMetaView.cc:91
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:20
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:38
SwapMetaView(const SwapMetaView &)=default
SwapMetaType type
Definition: SwapMetaView.h:42
const void * rawValue
Definition: SwapMetaView.h:29
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:67
char RawSwapMetaType
Definition: SwapMeta.h:95
SwapMetaType
Definition: SwapMeta.h:52
@ STORE_META_VOID
Definition: SwapMeta.h:55

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors