EHS
ehs::BaseFile Class Referenceabstract

A cross-platform wrapper class that handles native file input/output. More...

#include <BaseFile.h>

Inheritance diagram for ehs::BaseFile:
ehs::File ehs::File

Public Member Functions

virtual ~BaseFile ()=default
 Frees all native handles. More...
 
 BaseFile ()
 Default members initialization. More...
 
 BaseFile (const Str_8 &filePath, const Mode mode, const Disposition disposition)
 
 BaseFile (BaseFile &&file) noexcept
 
 BaseFile (const BaseFile &file)=default
 
BaseFileoperator= (BaseFile &&file) noexcept
 
BaseFileoperator= (const BaseFile &file)=default
 
virtual operator const Byte * () const =0
 
virtual operator Byte * ()=0
 
virtual void Release ()=0
 
virtual bool IsMapped () const =0
 
virtual UInt_64 MapSize () const =0
 
virtual void Map (const UInt_64 offset, const UInt_64 size)=0
 
virtual void Unmap ()=0
 
virtual void FlushMap ()=0
 
virtual UInt_64 Write (const Byte *const data, const UInt_64 size)=0
 
void WriteStr_32 (const Char_32 *const str, const UInt_64 size)
 
void WriteStr_32 (const Str_32 &str)
 
void WriteStr_16 (const Char_16 *const str, const UInt_64 size)
 
void WriteStr_16 (const Str_16 &str)
 
void WriteStr_8 (const Char_8 *const str, const UInt_64 size)
 
void WriteStr_8 (const Str_8 &str)
 
void WriteVector (const Vector< Byte, UInt_64 > &vec)
 
void WriteArray (const Array< Byte, UInt_64 > &arr)
 
void WriteSerializer_64 (const Serializer< UInt_64 > &ser)
 
void WriteSerializer_32 (const Serializer< UInt_32 > &ser)
 
virtual UInt_64 Read (Byte *const buffer, const UInt_64 size)=0
 
void ReadStr_32 (Char_32 *const buffer, UInt_64 &size)
 
Str_32 ReadStr_32 (const UInt_64 size)
 
void ReadStr_16 (Char_16 *const buffer, UInt_64 &size)
 
Str_16 ReadStr_16 (const UInt_64 size)
 
void ReadStr_8 (Char_8 *const buffer, UInt_64 &size)
 
Str_8 ReadStr_8 (const UInt_64 size)
 
Vector< Byte, UInt_64 > ReadVector (const UInt_64 size)
 
Array< Byte, UInt_64 > ReadArray (const UInt_64 size)
 
Serializer< UInt_64 > ReadSerializer_64 (const Endianness end, const UInt_64 size)
 
Serializer< UInt_32ReadSerializer_32 (const Endianness end, const UInt_32 size)
 
virtual void Seek (UInt_64 index)=0
 
virtual void SeekBeginning ()=0
 
virtual void SeekEnd ()=0
 
virtual void Truncate (const UInt_64 size)=0
 
virtual UInt_64 Size () const =0
 
Str_8 GetPath () const
 
Str_8 GetFullName () const
 
Str_8 GetName () const
 
Str_8 GetExtension () const
 
virtual bool IsValid () const =0
 

Static Public Member Functions

static void Rename_32 (const Str_32 &filePath, const Str_32 &newName)
 
static void Rename_16 (const Str_16 &filePath, const Str_16 &newName)
 
static void Rename_8 (const Str_8 &filePath, const Str_8 &newName)
 
static Str_32 ParseFullName_32 (const Str_32 &filePath)
 
static Str_16 ParseFullName_16 (const Str_16 &filePath)
 
static Str_8 ParseFullName_8 (const Str_8 &filePath)
 
static Str_32 ParseName_32 (const Str_32 &filePath)
 
static Str_16 ParseName_16 (const Str_16 &filePath)
 
static Str_8 ParseName_8 (const Str_8 &filePath)
 
static Str_32 ParseExt_32 (const Str_32 &filePath)
 
static Str_16 ParseExt_16 (const Str_16 &filePath)
 
static Str_8 ParseExt_8 (const Str_8 &filePath)
 

Protected Attributes

Str_8 path
 
Str_8 fullName
 
Str_8 name
 
Str_8 extension
 
Mode mode
 
Disposition disposition
 

Detailed Description

A cross-platform wrapper class that handles native file input/output.

Constructor & Destructor Documentation

◆ ~BaseFile()

virtual ehs::BaseFile::~BaseFile ( )
virtualdefault

Frees all native handles.

◆ BaseFile() [1/4]

ehs::BaseFile::BaseFile ( )

Default members initialization.

◆ BaseFile() [2/4]

ehs::BaseFile::BaseFile ( const Str_8 filePath,
const Mode  mode,
const Disposition  disposition 
)

Initializes members with the given data.

Parameters
[in]filePathThe file path to read or write to.
[in]modeThe mode when accessing the file.
[in]dispositionHow to handle the file.

◆ BaseFile() [3/4]

ehs::BaseFile::BaseFile ( BaseFile &&  file)
noexcept

◆ BaseFile() [4/4]

ehs::BaseFile::BaseFile ( const BaseFile file)
default

Copy constructor.

Parameters
[in]fileThe file object to copy from.

Member Function Documentation

◆ FlushMap()

virtual void ehs::BaseFile::FlushMap ( )
pure virtual

Implemented in ehs::File, and ehs::File.

◆ GetExtension()

Str_8 ehs::BaseFile::GetExtension ( ) const

◆ GetFullName()

Str_8 ehs::BaseFile::GetFullName ( ) const

◆ GetName()

Str_8 ehs::BaseFile::GetName ( ) const

◆ GetPath()

Str_8 ehs::BaseFile::GetPath ( ) const

◆ IsMapped()

virtual bool ehs::BaseFile::IsMapped ( ) const
pure virtual

Implemented in ehs::File, and ehs::File.

◆ IsValid()

virtual bool ehs::BaseFile::IsValid ( ) const
pure virtual

Retrieves whether or not this object is valid.

Returns
The result.

Implemented in ehs::File, and ehs::File.

◆ Map()

virtual void ehs::BaseFile::Map ( const UInt_64  offset,
const UInt_64  size 
)
pure virtual

Implemented in ehs::File, and ehs::File.

◆ MapSize()

virtual UInt_64 ehs::BaseFile::MapSize ( ) const
pure virtual

Implemented in ehs::File, and ehs::File.

◆ operator Byte *()

virtual ehs::BaseFile::operator Byte * ( )
pure virtual

Implemented in ehs::File, and ehs::File.

◆ operator const Byte *()

virtual ehs::BaseFile::operator const Byte * ( ) const
pure virtual

Implemented in ehs::File, and ehs::File.

◆ operator=() [1/2]

BaseFile & ehs::BaseFile::operator= ( BaseFile &&  file)
noexcept

◆ operator=() [2/2]

BaseFile & ehs::BaseFile::operator= ( const BaseFile file)
default

Copy operator.

Parameters
[in]fileThe file object to copy from.

◆ ParseExt_16()

Str_16 ehs::BaseFile::ParseExt_16 ( const Str_16 filePath)
static

◆ ParseExt_32()

Str_32 ehs::BaseFile::ParseExt_32 ( const Str_32 filePath)
static

◆ ParseExt_8()

Str_8 ehs::BaseFile::ParseExt_8 ( const Str_8 filePath)
static

◆ ParseFullName_16()

Str_16 ehs::BaseFile::ParseFullName_16 ( const Str_16 filePath)
static

◆ ParseFullName_32()

Str_32 ehs::BaseFile::ParseFullName_32 ( const Str_32 filePath)
static

◆ ParseFullName_8()

Str_8 ehs::BaseFile::ParseFullName_8 ( const Str_8 filePath)
static

◆ ParseName_16()

Str_16 ehs::BaseFile::ParseName_16 ( const Str_16 filePath)
static

◆ ParseName_32()

Str_32 ehs::BaseFile::ParseName_32 ( const Str_32 filePath)
static

◆ ParseName_8()

Str_8 ehs::BaseFile::ParseName_8 ( const Str_8 filePath)
static

◆ Read()

virtual UInt_64 ehs::BaseFile::Read ( Byte *const  buffer,
const UInt_64  size 
)
pure virtual

Reads data from the file as a C-style byte array.

Parameters
[out]bufferThe buffer to store the data read from the file.
[in]sizeThe size of the given buffer and how much data to read.

Implemented in ehs::File, and ehs::File.

◆ ReadArray()

Array< Byte, UInt_64 > ehs::BaseFile::ReadArray ( const UInt_64  size)

Reads data from the file as an array.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting array.

◆ ReadSerializer_32()

Serializer< UInt_32 > ehs::BaseFile::ReadSerializer_32 ( const Endianness  end,
const UInt_32  size 
)

Reads data from the file as a serializer.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]endThe Endianness of the data in the file.
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting serializer.

◆ ReadSerializer_64()

Serializer< UInt_64 > ehs::BaseFile::ReadSerializer_64 ( const Endianness  end,
const UInt_64  size 
)

Reads data from the file as a serializer.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]endThe Endianness of the data in the file.
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting serializer.

◆ ReadStr_16() [1/2]

void ehs::BaseFile::ReadStr_16 ( Char_16 *const  buffer,
UInt_64 &  size 
)

Reads data from the file as a C-style string.

Template Parameters
TThe character data type to use.
Parameters
[out]bufferThe buffer to store the data read from the file.
[in]sizeThe size of the given buffer and how much data to read.

◆ ReadStr_16() [2/2]

Str_16 ehs::BaseFile::ReadStr_16 ( const UInt_64  size)

Reads data from the file as a string.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting string.

◆ ReadStr_32() [1/2]

void ehs::BaseFile::ReadStr_32 ( Char_32 *const  buffer,
UInt_64 &  size 
)

Reads data from the file as a C-style string.

Template Parameters
TThe character data type to use.
Parameters
[out]bufferThe buffer to store the data read from the file.
[in]sizeThe size of the given buffer and how much data to read.

◆ ReadStr_32() [2/2]

Str_32 ehs::BaseFile::ReadStr_32 ( const UInt_64  size)

Reads data from the file as a string.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting string.

◆ ReadStr_8() [1/2]

void ehs::BaseFile::ReadStr_8 ( Char_8 *const  buffer,
UInt_64 &  size 
)

Reads data from the file as a C-style string.

Template Parameters
TThe character data type to use.
Parameters
[out]bufferThe buffer to store the data read from the file.
[in]sizeThe size of the given buffer and how much data to read.

◆ ReadStr_8() [2/2]

Str_8 ehs::BaseFile::ReadStr_8 ( const UInt_64  size)

Reads data from the file as a string.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting string.

◆ ReadVector()

Vector< Byte, UInt_64 > ehs::BaseFile::ReadVector ( const UInt_64  size)

Reads data from the file as a vector.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]sizeThe size of the buffer and how much data to read.
Returns
The resulting vector.

◆ Release()

virtual void ehs::BaseFile::Release ( )
pure virtual

Uninitializes the native handle.

Parameters
[in]raiseLogWhether or not to raise a log if already uninitialized. Mostly for deconstructor.

Implemented in ehs::File, and ehs::File.

◆ Rename_16()

void ehs::BaseFile::Rename_16 ( const Str_16 filePath,
const Str_16 newName 
)
static

◆ Rename_32()

void ehs::BaseFile::Rename_32 ( const Str_32 filePath,
const Str_32 newName 
)
static

◆ Rename_8()

void ehs::BaseFile::Rename_8 ( const Str_8 filePath,
const Str_8 newName 
)
static

◆ Seek()

virtual void ehs::BaseFile::Seek ( UInt_64  index)
pure virtual

Implemented in ehs::File, and ehs::File.

◆ SeekBeginning()

virtual void ehs::BaseFile::SeekBeginning ( )
pure virtual

Implemented in ehs::File, and ehs::File.

◆ SeekEnd()

virtual void ehs::BaseFile::SeekEnd ( )
pure virtual

Implemented in ehs::File, and ehs::File.

◆ Size()

virtual UInt_64 ehs::BaseFile::Size ( ) const
pure virtual

Retrieves the size of the file.

Returns
The result.

Implemented in ehs::File, and ehs::File.

◆ Truncate()

virtual void ehs::BaseFile::Truncate ( const UInt_64  size)
pure virtual

Implemented in ehs::File, and ehs::File.

◆ Unmap()

virtual void ehs::BaseFile::Unmap ( )
pure virtual

Implemented in ehs::File, and ehs::File.

◆ Write()

virtual UInt_64 ehs::BaseFile::Write ( const Byte *const  data,
const UInt_64  size 
)
pure virtual

Writes a C-style byte array to the file.

Parameters
[in]dataThe C-style byte array to write to the file.
[in]sizeThe size of the given C-style byte array.

Implemented in ehs::File, and ehs::File.

◆ WriteArray()

void ehs::BaseFile::WriteArray ( const Array< Byte, UInt_64 > &  arr)

Writes an array to the file.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]arrThe array to write to the file.

◆ WriteSerializer_32()

void ehs::BaseFile::WriteSerializer_32 ( const Serializer< UInt_32 > &  ser)

Writes a serializer to the file.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]serThe serializer to write to the file.

◆ WriteSerializer_64()

void ehs::BaseFile::WriteSerializer_64 ( const Serializer< UInt_64 > &  ser)

Writes a serializer to the file.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]serThe serializer to write to the file.

◆ WriteStr_16() [1/2]

void ehs::BaseFile::WriteStr_16 ( const Char_16 *const  str,
const UInt_64  size 
)

Writes a C-style string to the file.

Template Parameters
TThe character data type to use.
Parameters
[in]strThe C-style string to write to the file.
[in]sizeThe size of the given C-style string.

◆ WriteStr_16() [2/2]

void ehs::BaseFile::WriteStr_16 ( const Str_16 str)

Writes a string to the file.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]strThe string to write to the file.

◆ WriteStr_32() [1/2]

void ehs::BaseFile::WriteStr_32 ( const Char_32 *const  str,
const UInt_64  size 
)

Writes a C-style string to the file.

Template Parameters
TThe character data type to use.
Parameters
[in]strThe C-style string to write to the file.
[in]sizeThe size of the given C-style string.

◆ WriteStr_32() [2/2]

void ehs::BaseFile::WriteStr_32 ( const Str_32 str)

Writes a string to the file.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]strThe string to write to the file.

◆ WriteStr_8() [1/2]

void ehs::BaseFile::WriteStr_8 ( const Char_8 *const  str,
const UInt_64  size 
)

Writes a C-style string to the file.

Template Parameters
TThe character data type to use.
Parameters
[in]strThe C-style string to write to the file.
[in]sizeThe size of the given C-style string.

◆ WriteStr_8() [2/2]

void ehs::BaseFile::WriteStr_8 ( const Str_8 str)

Writes a string to the file.

Template Parameters
TThe character data type to use.
NThe data type to use for numbers.
Parameters
[in]strThe string to write to the file.

◆ WriteVector()

void ehs::BaseFile::WriteVector ( const Vector< Byte, UInt_64 > &  vec)

Writes a vector to the file.

Template Parameters
NThe data type to use for numbers.
Parameters
[in]vecThe vector to write to the file.

Member Data Documentation

◆ disposition

Disposition ehs::BaseFile::disposition
protected

◆ extension

Str_8 ehs::BaseFile::extension
protected

◆ fullName

Str_8 ehs::BaseFile::fullName
protected

◆ mode

Mode ehs::BaseFile::mode
protected

◆ name

Str_8 ehs::BaseFile::name
protected

◆ path

Str_8 ehs::BaseFile::path
protected

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