Libosmium  2.2.0
Fast and flexible C++ library for working with OpenStreetMap data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Attributes | List of all members
osmium::io::Writer Class Reference

#include <writer.hpp>

Collaboration diagram for osmium::io::Writer:
Collaboration graph
[legend]

Public Member Functions

 Writer (const osmium::io::File &file, const osmium::io::Header &header=osmium::io::Header(), overwrite allow_overwrite=overwrite::no)
 
 Writer (const std::string &filename, const osmium::io::Header &header=osmium::io::Header(), overwrite allow_overwrite=overwrite::no)
 
 Writer (const char *filename, const osmium::io::Header &header=osmium::io::Header(), overwrite allow_overwrite=overwrite::no)
 
 Writer (const Writer &)=delete
 
Writeroperator= (const Writer &)=delete
 
 ~Writer ()
 
void operator() (osmium::memory::Buffer &&buffer)
 
void close ()
 

Private Attributes

osmium::io::File m_file
 
osmium::io::detail::data_queue_type m_output_queue
 
std::unique_ptr
< osmium::io::detail::OutputFormat > 
m_output
 
std::unique_ptr
< osmium::io::Compressor
m_compressor
 
std::future< bool > m_write_future
 

Detailed Description

This is the user-facing interface for writing OSM files. Instantiate an object of this class with a file name or osmium::io::File object and optionally the data for the header and then call operator() on it to write Buffers. Call close() to finish up.

Constructor & Destructor Documentation

osmium::io::Writer::Writer ( const osmium::io::File file,
const osmium::io::Header header = osmium::io::Header(),
overwrite  allow_overwrite = overwrite::no 
)
inlineexplicit

The constructor of the Writer object opens a file and writes the header to it.

Parameters
fileFile (contains name and format info) to open.
headerOptional header data. If this is not given sensible defaults will be used. See the default constructor of osmium::io::Header for details.
allow_overwriteAllow overwriting of existing file? Can be osmium::io::overwrite::allow or osmium::io::overwrite::no (default).
Exceptions
std::runtime_errorIf the file could not be opened.
std::system_errorIf the file could not be opened.
osmium::io::Writer::Writer ( const std::string &  filename,
const osmium::io::Header header = osmium::io::Header(),
overwrite  allow_overwrite = overwrite::no 
)
inlineexplicit
osmium::io::Writer::Writer ( const char *  filename,
const osmium::io::Header header = osmium::io::Header(),
overwrite  allow_overwrite = overwrite::no 
)
inlineexplicit
osmium::io::Writer::Writer ( const Writer )
delete
osmium::io::Writer::~Writer ( )
inline

Member Function Documentation

void osmium::io::Writer::close ( )
inline

Flush writes to output file and closes it. If you do not call this, the destructor of Writer will also do the same thing. But because this call might thrown an exception, it is better to call close() explicitly.

Exceptions
Someform of std::runtime_error when there is a problem.
void osmium::io::Writer::operator() ( osmium::memory::Buffer &&  buffer)
inline

Write contents of a buffer to the output file.

Exceptions
Someform of std::runtime_error when there is a problem.
Writer& osmium::io::Writer::operator= ( const Writer )
delete

Member Data Documentation

std::unique_ptr<osmium::io::Compressor> osmium::io::Writer::m_compressor
private
osmium::io::File osmium::io::Writer::m_file
private
std::unique_ptr<osmium::io::detail::OutputFormat> osmium::io::Writer::m_output
private
osmium::io::detail::data_queue_type osmium::io::Writer::m_output_queue
private
std::future<bool> osmium::io::Writer::m_write_future
private

The documentation for this class was generated from the following file: