Libosmium
2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
|
#include <reader.hpp>
Public Member Functions | |
template<typename... TArgs> | |
Reader (const osmium::io::File &file, TArgs &&... args) | |
template<typename... TArgs> | |
Reader (const std::string &filename, TArgs &&... args) | |
template<typename... TArgs> | |
Reader (const char *filename, TArgs &&... args) | |
Reader (const Reader &)=delete | |
Reader & | operator= (const Reader &)=delete |
Reader (Reader &&)=delete | |
Reader & | operator= (Reader &&)=delete |
~Reader () noexcept | |
void | close () |
osmium::io::Header | header () |
osmium::memory::Buffer | read () |
bool | eof () const |
std::size_t | file_size () const noexcept |
std::size_t | offset () const noexcept |
Private Types | |
enum class | status { okay = 0 , error = 1 , closed = 2 , eof = 3 } |
Private Member Functions | |
void | set_option (osmium::thread::Pool &pool) noexcept |
void | set_option (osmium::osm_entity_bits::type value) noexcept |
void | set_option (osmium::io::read_meta value) noexcept |
void | set_option (osmium::io::buffers_type value) noexcept |
Static Private Member Functions | |
static void | parser_thread (osmium::thread::Pool &pool, int fd, const detail::ParserFactory::create_parser_type &creator, detail::future_string_queue_type &input_queue, detail::future_buffer_queue_type &osmdata_queue, std::promise< osmium::io::Header > &&header_promise, std::atomic< std::size_t > *offset_ptr, osmium::osm_entity_bits::type read_which_entities, osmium::io::read_meta read_metadata, osmium::io::buffers_type buffers_kind, bool want_buffered_pages_removed) |
static int | execute (const std::string &command, const std::string &filename, int *childpid) |
static int | open_input_file_or_url (const std::string &filename, int *childpid) |
static std::unique_ptr< Decompressor > | make_decompressor (const osmium::io::File &file, int fd, std::atomic< std::size_t > *offset_ptr) |
Private Attributes | |
osmium::memory::Buffer | m_back_buffers {} |
osmium::io::File | m_file |
osmium::thread::Pool * | m_pool = nullptr |
std::atomic< std::size_t > | m_offset {0} |
detail::ParserFactory::create_parser_type | m_creator |
enum osmium::io::Reader::status | m_status = status::okay |
int | m_childpid = 0 |
detail::future_string_queue_type | m_input_queue |
int | m_fd = -1 |
std::size_t | m_file_size = 0 |
std::unique_ptr< osmium::io::Decompressor > | m_decompressor |
osmium::io::detail::ReadThreadManager | m_read_thread_manager |
detail::future_buffer_queue_type | m_osmdata_queue |
detail::queue_wrapper< osmium::memory::Buffer > | m_osmdata_queue_wrapper |
std::future< osmium::io::Header > | m_header_future {} |
osmium::io::Header | m_header {} |
osmium::thread::thread_handler | m_thread {} |
osmium::osm_entity_bits::type | m_read_which_entities = osmium::osm_entity_bits::all |
osmium::io::read_meta | m_read_metadata = osmium::io::read_meta::yes |
osmium::io::buffers_type | m_buffers_kind = osmium::io::buffers_type::any |
This is the user-facing interface for reading OSM files. Instantiate an object of this class with a file name or osmium::io::File object and then call read() on it in a loop until it returns an invalid Buffer.
|
strongprivate |
|
inlineexplicit |
Create new Reader object.
file | The file (contains name and format info) to open. |
args | All further arguments are optional and can appear in any order: |
osmium::io_error | If there was an error. |
std::system_error | If the file could not be opened. |
|
inlineexplicit |
|
inlineexplicit |
|
delete |
|
delete |
|
inlinenoexcept |
|
inline |
Close down the Reader. A call to this is optional, because the destructor of Reader will also call this. But if you don't call this function first, you might miss an exception, because the destructor is not allowed to throw.
Some | form of osmium::io_error when there is a problem. |
|
inline |
Has the end of file been reached? This is set after the last data has been read. It is also set by calling close().
|
inlinestaticprivate |
Fork and execute the given command in the child. A pipe is created between the child and the parent. The child writes to the pipe, the parent reads from it. This function never returns in the child.
command | Command to execute in the child. |
filename | Filename to give to command as argument. |
std::system_error | if a system call fails. |
|
inlinenoexcept |
Get the size of the input file. Returns 0 if the file size is not available (for instance when reading from stdin).
|
inline |
Get the header data from the file.
Some | form of osmium::io_error if there is an error. |
|
inlinestaticprivate |
|
inlinenoexcept |
Returns the current offset into the input file. Returns 0 if the offset is not available (for instance when reading from stdin).
The offset can be used together with the result of file_size() to estimate how much of the file has been read. Note that due to buffering inside Osmium, this value will be larger than the amount of data actually available to the application.
Do not call this function too often, certainly not for every object you are reading. Depending on the file type it might do an expensive system call.
|
inlinestaticprivate |
|
inlinestaticprivate |
|
inline |
Reads the next buffer from the input. An invalid buffer signals end-of-file. After end-of-file all read() calls will throw an osmium::io_error.
Some | form of osmium::io_error if there is an error. |
|
inlineprivatenoexcept |
|
inlineprivatenoexcept |
|
inlineprivatenoexcept |
|
inlineprivatenoexcept |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |