libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::FileScanner Class Referencefinal

FileScanner implements platform independent sequential scanning-like access to data in files. More...

#include <FileScanner.h>

Public Types

enum  Mode { Sequential , FastRandom , LowMemRandom , Normal }

Public Member Functions

void Close ()
 Closes the file.
void CloseFailsafe ()
 Closes the file.
 FileScanner ()=default
std::string GetFilename () const
FileOffset GetPos () const
 Returns the current position of the reading cursor in relation to the begining of the file.
void GotoBegin ()
 Moves the reading cursor to the start of the file (offset 0).
bool HasError () const
bool IsEOF () const
bool IsOpen () const
void Open (const std::string &filename, Mode mode, bool useMmap)
void Read (char *buffer, size_t bytes)
uint16_t Read (size_t bytes)
void Read (std::vector< Point > &nodes, std::vector< SegmentGeoBox > &segments, GeoBox &bbox, bool readIds)
 Reads vector of Point and pre-compute segments and bounding box for it.
bool ReadBool ()
GeoBox ReadBox ()
std::byte ReadByte ()
Color ReadColor ()
std::tuple< GeoCoord, bool > ReadConditionalCoord ()
GeoCoord ReadCoord ()
FileOffset ReadFileOffset ()
FileOffset ReadFileOffset (size_t bytes)
int16_t ReadInt16 ()
int16_t ReadInt16Number ()
int32_t ReadInt32 ()
int32_t ReadInt32Number ()
int64_t ReadInt64 ()
int64_t ReadInt64Number ()
int8_t ReadInt8 ()
ObjectFileRef ReadObjectFileRef ()
std::vector< ObjectFileRef > ReadObjectFileRefs (size_t count)
std::string ReadString ()
TypeId ReadTypeId (uint8_t maxBytes)
uint16_t ReadUInt16 ()
uint16_t ReadUInt16Number ()
uint32_t ReadUInt32 ()
uint32_t ReadUInt32 (size_t bytes)
uint32_t ReadUInt32Number ()
uint64_t ReadUInt64 ()
uint64_t ReadUInt64 (size_t bytes)
uint64_t ReadUInt64Number ()
uint8_t ReadUInt8 ()
void SetPos (FileOffset pos)
 Moves the reading cursor to the given file position.
 ~FileScanner ()

Detailed Description

FileScanner implements platform independent sequential scanning-like access to data in files.

File access is buffered.

FileScanner will use mmap in read-only mode if available (and will fall back to normal buffered IO if available but failing), resulting in mapping the complete file into the memory of the process (without allocating real memory) resulting in measurable speed increase because of exchanging buffered file access with in memory array access.

Member Enumeration Documentation

◆ Mode

Enumerator
Sequential 
FastRandom 
LowMemRandom 
Normal 

Constructor & Destructor Documentation

◆ FileScanner()

osmscout::FileScanner::FileScanner ( )
default

References Close(), CloseFailsafe(), FileScanner(), and Open().

Referenced by FileScanner().

◆ ~FileScanner()

osmscout::FileScanner::~FileScanner ( )

Member Function Documentation

◆ Close()

void osmscout::FileScanner::Close ( )

Closes the file.

If the file was never opened or was already closed an exception is thrown.

If closing the file fails, an exception is thrown

Referenced by FileScanner(), osmscout::TypeConfig::GetDatabaseFileFormatVersion(), osmscout::BoundingBoxDataFile::Load(), osmscout::ObjectVariantDataFile::Load(), osmscout::TypeDistributionDataFile::Load(), and osmscout::TypeConfig::LoadFromDataFile().

◆ CloseFailsafe()

void osmscout::FileScanner::CloseFailsafe ( )

Closes the file.

Does not throw any exceptions even if an error occurs.

Use this variant of Close() in cases where the file already run into errors and you just want to clean up the resources using best effort.

Referenced by FileScanner(), osmscout::TypeConfig::GetDatabaseFileFormatVersion(), osmscout::BoundingBoxDataFile::Load(), osmscout::ObjectVariantDataFile::Load(), osmscout::TypeDistributionDataFile::Load(), osmscout::TypeConfig::LoadFromDataFile(), and ~FileScanner().

◆ GetFilename()

◆ GetPos()

FileOffset osmscout::FileScanner::GetPos ( ) const

◆ GotoBegin()

void osmscout::FileScanner::GotoBegin ( )

Moves the reading cursor to the start of the file (offset 0).

throws IOException on error

References SetPos().

◆ HasError()

◆ IsEOF()

bool osmscout::FileScanner::IsEOF ( ) const

References HasError().

◆ IsOpen()

bool osmscout::FileScanner::IsOpen ( ) const
inline

Referenced by ~FileScanner().

◆ Open()

◆ Read() [1/3]

void osmscout::FileScanner::Read ( char * buffer,
size_t bytes )

◆ Read() [2/3]

uint16_t osmscout::FileScanner::Read ( size_t bytes)

References HasError().

◆ Read() [3/3]

void osmscout::FileScanner::Read ( std::vector< Point > & nodes,
std::vector< SegmentGeoBox > & segments,
GeoBox & bbox,
bool readIds )

◆ ReadBool()

bool osmscout::FileScanner::ReadBool ( )

References HasError().

Referenced by osmscout::TypeInfo::Read().

◆ ReadBox()

GeoBox osmscout::FileScanner::ReadBox ( )

◆ ReadByte()

std::byte osmscout::FileScanner::ReadByte ( )

References HasError().

◆ ReadColor()

Color osmscout::FileScanner::ReadColor ( )

◆ ReadConditionalCoord()

std::tuple< GeoCoord, bool > osmscout::FileScanner::ReadConditionalCoord ( )

◆ ReadCoord()

◆ ReadFileOffset() [1/2]

FileOffset osmscout::FileScanner::ReadFileOffset ( )

References HasError().

Referenced by ReadObjectFileRef().

◆ ReadFileOffset() [2/2]

FileOffset osmscout::FileScanner::ReadFileOffset ( size_t bytes)

References HasError().

◆ ReadInt16()

int16_t osmscout::FileScanner::ReadInt16 ( )

References HasError().

◆ ReadInt16Number()

int16_t osmscout::FileScanner::ReadInt16Number ( )

◆ ReadInt32()

int32_t osmscout::FileScanner::ReadInt32 ( )

◆ ReadInt32Number()

int32_t osmscout::FileScanner::ReadInt32Number ( )

◆ ReadInt64()

int64_t osmscout::FileScanner::ReadInt64 ( )

References HasError().

◆ ReadInt64Number()

int64_t osmscout::FileScanner::ReadInt64Number ( )

◆ ReadInt8()

int8_t osmscout::FileScanner::ReadInt8 ( )

References HasError().

Referenced by osmscout::LayerFeatureValue::Read().

◆ ReadObjectFileRef()

ObjectFileRef osmscout::FileScanner::ReadObjectFileRef ( )

◆ ReadObjectFileRefs()

std::vector< ObjectFileRef > osmscout::FileScanner::ReadObjectFileRefs ( size_t count)

References ReadUInt64Number().

◆ ReadString()

◆ ReadTypeId()

◆ ReadUInt16()

uint16_t osmscout::FileScanner::ReadUInt16 ( )

◆ ReadUInt16Number()

uint16_t osmscout::FileScanner::ReadUInt16Number ( )

References HasError().

◆ ReadUInt32() [1/2]

◆ ReadUInt32() [2/2]

uint32_t osmscout::FileScanner::ReadUInt32 ( size_t bytes)

References HasError().

◆ ReadUInt32Number()

◆ ReadUInt64() [1/2]

uint64_t osmscout::FileScanner::ReadUInt64 ( )

References HasError().

Referenced by osmscout::RouteNode::Read().

◆ ReadUInt64() [2/2]

uint64_t osmscout::FileScanner::ReadUInt64 ( size_t bytes)

References HasError().

◆ ReadUInt64Number()

◆ ReadUInt8()

◆ SetPos()

void osmscout::FileScanner::SetPos ( FileOffset pos)

Moves the reading cursor to the given file position.

throws IOException on error

References HasError().

Referenced by GotoBegin().


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