|
FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
|
Synchronous byte-range source. More...
#include <fcb/range_reader.hpp>
Public Member Functions | |
| virtual | ~RangeReader ()=default |
| virtual std::uint64_t | total_size ()=0 |
| Total byte length of the resource. | |
| virtual std::vector< std::uint8_t > | read (std::uint64_t offset, std::uint64_t length)=0 |
Read length bytes at offset, subject to the contract above. | |
| virtual void | read_batch (std::vector< RangeRequest > &requests) |
| Fill every request, preserving order. | |
Synchronous byte-range source.
Implement this to plug in any transport (file, HTTP, memory, engine VFS). The core never assumes asynchrony; batching, not async, is the concurrency primitive. This is the whole point of the native port: a blocking interface is trivially wrapped by any host application's threading model, whereas forcing our async model on callers is exactly the tokio-over-FFI problem we are escaping.
CONTRACT – implementors must honour all of it:
length bytes unless the range crosses the end of the resource, in which case it returns exactly the bytes that exist (possibly zero). It must never return a short buffer for any other reason; a truncated network response is an error, not a short read, and must throw fcb::Error{HttpError}.data in place. Request ORDER IS PRESERVED: the i-th request's bytes land in the i-th element. An implementation may reorder its internal fetches freely.data.Definition at line 50 of file range_reader.hpp.
|
virtualdefault |
|
pure virtual |
Read length bytes at offset, subject to the contract above.
Implemented in fcb::CurlRangeReader, fcb::FileRangeReader, and fcb::BufferedRangeReader.
Referenced by read_batch(), and fcb::rtree_search_bbox().
|
virtual |
Fill every request, preserving order.
Transports that can pipeline or multiplex should override this; the default is a sequential loop.
Reimplemented in fcb::BufferedRangeReader.
Definition at line 9 of file range_reader.cpp.
References read().
|
pure virtual |
Total byte length of the resource.
This is a REQUIRED bounds/security contract, not a convenience: every computed section offset and range request is validated against it, so a corrupt header cannot make the core read or allocate out of bounds. (It is NOT needed to size the last feature – every feature carries its own 4-byte size prefix.)
Implemented in fcb::CurlRangeReader, fcb::FileRangeReader, and fcb::BufferedRangeReader.