UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
read_buffer.hpp
1
42#ifndef UFO_UTILITY_READ_BUFFER_HPP
43#define UFO_UTILITY_READ_BUFFER_HPP
44
45// UFO
46#include <ufo/utility/io/base_buffer.hpp>
47#include <ufo/utility/io/dir.hpp>
48
49// STL
50#include <cstddef>
51#include <ostream>
52
53namespace ufo
54{
55class ReadBuffer : virtual public BaseBuffer
56{
57 public:
58 using size_type = BaseBuffer::size_type;
59 using pos_type = BaseBuffer::pos_type;
60 using offset_type = BaseBuffer::offset_type;
61
62 ReadBuffer() = default;
63
64 ReadBuffer(std::byte const* data, size_type count);
65
66 template <class T>
67 ReadBuffer& read(T& t)
68 {
69 return read(&t, sizeof(t));
70 }
71
72 ReadBuffer& read(void* dest, size_type count);
73
74 ReadBuffer& read(std::ostream& out, size_type count);
75
76 template <class T>
77 void readAt(pos_type pos, T& t) const
78 {
79 readAt(pos, &t, sizeof(t));
80 }
81
82 void readAt(pos_type pos, void* dest, size_type count) const;
83
84 void readAt(pos_type pos, std::ostream& out, size_type count) const;
85
86 template <class T>
87 void readAt(offset_type off, IODir dir, T& t) const
88 {
89 readAt(off, dir, &t, sizeof(t));
90 }
91
92 void readAt(offset_type off, IODir dir, void* dest, size_type count) const;
93
94 void readAt(offset_type off, IODir dir, std::ostream& out, size_type count) const;
95
96 bool readLine(std::string& line);
97
98 [[nodiscard]] pos_type readPos() const noexcept;
99
100 ReadBuffer& readSeek(pos_type pos) noexcept;
101
102 ReadBuffer& readSeek(offset_type off, IODir dir) noexcept;
103
104 template <class T>
105 ReadBuffer& readSeek(T const& t, pos_type count) noexcept
106 {
107 return readSeek(sizeof(t) * count);
108 }
109
110 template <class T>
111 ReadBuffer& readSeek(T const& t, offset_type count_signed, IODir dir) noexcept
112 {
113 return readSeek(sizeof(t) * count_signed, dir);
114 }
115
116 [[nodiscard]] size_type readLeft() const noexcept;
117
118 protected:
119 pos_type pos_{};
120};
121} // namespace ufo
122#endif // UFO_UTILITY_READ_BUFFER_HPP
All vision-related classes and functions.
Definition cloud.hpp:49