Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
OStream.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2023, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <boost/iostreams/filtering_stream.hpp>
23
24#include <string>
25
26namespace util::prometheus {
27
31class OStream {
32public:
38 OStream(bool compressionEnabled);
39
40 OStream(OStream const&) = delete;
41 OStream(OStream&&) = delete;
42 ~OStream() = default;
43
51 template <typename T>
53 operator<<(T const& value)
54 {
55 stream_ << value;
56 return *this;
57 }
58
66 std::string
67 data() &&;
68
69private:
70 bool compressionEnabled_;
71 std::string buffer_;
72 boost::iostreams::filtering_ostream stream_;
73};
74
75} // namespace util::prometheus
A stream that can optionally compress its data.
Definition OStream.hpp:31
OStream(bool compressionEnabled)
Construct a new OStream object.
Definition OStream.cpp:30
OStream & operator<<(T const &value)
Write to the stream.
Definition OStream.hpp:53
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70