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::util::DataFile Class Reference

#include <data_file.hpp>

Public Member Functions

 DataFile ()
 
 DataFile (size_t size)
 
 DataFile (const char *filename, bool writable)
 
 DataFile (const std::string &filename, bool writable)
 
 operator bool () const noexcept
 
void close ()
 
 ~DataFile () noexcept
 
int fd () const
 
size_t size () const
 
void grow (size_t new_size) const
 

Private Attributes

FILE * m_file
 

Detailed Description

Class wrapper for convenient access to some low-level file functions.

Constructor & Destructor Documentation

osmium::util::DataFile::DataFile ( )
inline

Create and open a temporary file. It is removed after opening.

Exceptions
std::system_errorif something went wrong.
osmium::util::DataFile::DataFile ( size_t  size)
inlineexplicit

Create and open a temporary file with the specified size. It is removed after opening.

Exceptions
std::system_errorif something went wrong.
osmium::util::DataFile::DataFile ( const char *  filename,
bool  writable 
)
inline

Create and open a named file.

Parameters
filenamethe name of the file
writableshould the file be writable?
Exceptions
std::system_errorif something went wrong.
osmium::util::DataFile::DataFile ( const std::string &  filename,
bool  writable 
)
inline

Create and open a named file.

Parameters
filenamethe name of the file
writableshould the file be writable?
Exceptions
std::system_errorif something went wrong.
osmium::util::DataFile::~DataFile ( )
inlinenoexcept

Member Function Documentation

void osmium::util::DataFile::close ( )
inline

Close the file.

Does nothing if the file is already closed.

Exceptions
std::system_errorif file could not be closed
int osmium::util::DataFile::fd ( ) const
inline

Get file descriptor of underlying file.

Exceptions
std::runtime_errroif file is not open
std::system_errorif fileno(3) call failed
void osmium::util::DataFile::grow ( size_t  new_size) const
inline

Grow file to given size.

If the file is large enough already, nothing is done. The file is never shrunk.

Exceptions
std::system_errorif ftruncate(2) call failed
osmium::util::DataFile::operator bool ( ) const
inlinenoexcept

In boolean context the DataFile class returns true if the file is open.

size_t osmium::util::DataFile::size ( ) const
inline

Ask the operating system for the size of this file.

Exceptions
std::system_errorif fstat(2) call failed

Member Data Documentation

FILE* osmium::util::DataFile::m_file
private

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