Osmium
0.1
|
#include <osmfile.hpp>
Classes | |
class | ArgumentError |
class | FileEncoding |
class | FileType |
struct | FileTypeError |
struct | FileTypeHistoryExpected |
struct | FileTypeOSMExpected |
class | IOError |
class | SystemError |
Public Member Functions | |
OSMFile (const std::string &filename="") | |
void | set_type_and_encoding (const std::string &suffix) |
OSMFile (const OSMFile &orig) | |
OSMFile & | operator= (const OSMFile &orig) |
~OSMFile () | |
void | close () |
void | default_settings_for_stdinout () |
void | default_settings_for_file () |
void | default_settings_for_url () |
int | get_fd () const |
FileType * | get_type () const |
OSMFile & | set_type (FileType *type) |
OSMFile & | set_type (std::string &type) |
bool | has_multiple_object_versions () const |
FileEncoding * | get_encoding () const |
OSMFile & | set_encoding (FileEncoding *encoding) |
OSMFile & | set_encoding (std::string &encoding) |
OSMFile & | set_filename (std::string &filename) |
std::string | get_filename () const |
std::string | get_filename_without_suffix () const |
std::string | get_filename_with_default_suffix () const |
void | open_for_input () |
void | open_for_output () |
template<class T > | |
void | read (T &handler) |
Osmium::Output::Base * | create_output_file () |
Private Member Functions | |
int | execute (std::string command, int input) |
int | open_input_file () const |
int | open_output_file () const |
int | open_input_file_or_url () |
Private Attributes | |
FileType * | m_type |
Type of file. | |
FileEncoding * | m_encoding |
Encoding of file. | |
std::string | m_filename |
File name. | |
int | m_fd |
File descriptor. -1 before the file is opened. | |
pid_t | m_childpid |
This class describes an OSM file in one of several different formats. It can be used as factory class for generating input and output OSM files.
If the filename is empty, this means stdin or stdout is used. If you set the filename to "-" it will be treated the same.
Osmium::OSMFile::OSMFile | ( | const std::string & | filename = "" | ) | [inline] |
Create OSMFile using type and encoding from filename. If you want to overwrite these settings you can change them later.
filename | Filename including suffix. The type and encoding of the file will be taken from the suffix. An empty filename or "-" means stdin or stdout. |
Osmium::OSMFile::OSMFile | ( | const OSMFile & | orig | ) | [inline] |
Copy constructor. Only attributes not related to the open file will be copied.
Osmium::OSMFile::~OSMFile | ( | ) | [inline] |
void Osmium::OSMFile::close | ( | ) | [inline] |
Create output file from OSMFile.
void Osmium::OSMFile::default_settings_for_file | ( | ) | [inline] |
Set default settings for type and encoding when the filename is a normal file. If you want to have a different default setting override this in a subclass.
void Osmium::OSMFile::default_settings_for_stdinout | ( | ) | [inline] |
Set default settings for type and encoding when the filename is empty or "-". If you want to have a different default setting override this in a subclass.
void Osmium::OSMFile::default_settings_for_url | ( | ) | [inline] |
Set default settings for type and encoding when the filename is a URL. If you want to have a different default setting override this in a subclass.
int Osmium::OSMFile::execute | ( | std::string | command, |
int | input | ||
) | [inline, private] |
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. |
input | 0 for reading from child, 1 for writing to child. |
SystemError | if a system call fails. |
FileEncoding* Osmium::OSMFile::get_encoding | ( | ) | const [inline] |
int Osmium::OSMFile::get_fd | ( | ) | const [inline] |
std::string Osmium::OSMFile::get_filename | ( | ) | const [inline] |
std::string Osmium::OSMFile::get_filename_with_default_suffix | ( | ) | const [inline] |
std::string Osmium::OSMFile::get_filename_without_suffix | ( | ) | const [inline] |
FileType* Osmium::OSMFile::get_type | ( | ) | const [inline] |
bool Osmium::OSMFile::has_multiple_object_versions | ( | ) | const [inline] |
void Osmium::OSMFile::open_for_input | ( | ) | [inline] |
void Osmium::OSMFile::open_for_output | ( | ) | [inline] |
int Osmium::OSMFile::open_input_file | ( | ) | const [inline, private] |
int Osmium::OSMFile::open_input_file_or_url | ( | ) | [inline, private] |
Open OSMFile for reading. Handles URLs or normal files. URLs are opened by executing the "curl" program (which must be installed) and reading from its output.
SystemError | if a system call fails. |
IOError | if the file can't be opened. |
int Osmium::OSMFile::open_output_file | ( | ) | const [inline, private] |
Assignement operator. Only attributes not related to the open file will be copied.
void Osmium::OSMFile::read | ( | T & | handler | ) |
Read OSM file and call methods on handler object.
OSMFile& Osmium::OSMFile::set_encoding | ( | FileEncoding * | encoding | ) | [inline] |
OSMFile& Osmium::OSMFile::set_encoding | ( | std::string & | encoding | ) | [inline] |
OSMFile& Osmium::OSMFile::set_filename | ( | std::string & | filename | ) | [inline] |
OSMFile& Osmium::OSMFile::set_type | ( | FileType * | type | ) | [inline] |
OSMFile& Osmium::OSMFile::set_type | ( | std::string & | type | ) | [inline] |
void Osmium::OSMFile::set_type_and_encoding | ( | const std::string & | suffix | ) | [inline] |
pid_t Osmium::OSMFile::m_childpid [private] |
Contains the child process id if a child was created to uncompress data or for getting a URL.
FileEncoding* Osmium::OSMFile::m_encoding [private] |
Encoding of file.
int Osmium::OSMFile::m_fd [private] |
File descriptor. -1 before the file is opened.
std::string Osmium::OSMFile::m_filename [private] |
File name.
FileType* Osmium::OSMFile::m_type [private] |
Type of file.