Circus 0.0.1-alpha
C++ Serialization Framework
Loading...
Searching...
No Matches
reader.hpp
1#pragma once
2#include <filesystem>
3#include <fstream>
4#include <iostream>
5#include <sstream>
6#include <string>
7
8namespace circus::filesystem {
9
17class reader__ {
19 std::string _contents;
20
21 public:
25 reader__() : _contents{} {};
26
33 std::string operator()(std::istream &is) {
34 std::string contents((std::istreambuf_iterator<char>(is)),
35 std::istreambuf_iterator<char>());
36 _contents = std::move(contents);
37 return _contents;
38 };
39
45 [[nodiscard]] std::size_t size() const noexcept {
46 return _contents.size();
47 };
48
54 [[nodiscard]] const std::string &get_file_contents() const noexcept { return _contents; };
55};
56
57}; // namespace circus::filesystem
reader__()
Default constructor initializes an empty content buffer.
Definition reader.hpp:25
std::string operator()(std::istream &is)
Reads entire contents of the provided input stream into internal buffer.
Definition reader.hpp:33
std::size_t size() const noexcept
Get the size in bytes of the stored content.
Definition reader.hpp:45
const std::string & get_file_contents() const noexcept
Provides read-only access to the stored file contents.
Definition reader.hpp:54