Isle
Loading...
Searching...
No Matches
LegoStorage Class Referenceabstract

Abstract base class providing an interface for file-like storage with binary and text read/write operations. More...

#include <legostorage.h>

Inheritance diagram for LegoStorage:

Public Types

enum  OpenFlags { c_read = 1 , c_write = 2 , c_text = 4 }
 File open mode flags for storage operations. More...
 

Public Member Functions

 LegoStorage ()
 Default constructor initializing mode to zero. More...
 
virtual ~LegoStorage ()
 Virtual destructor for safe polymorphic destruction. More...
 
virtual LegoResult Read (void *p_buffer, LegoU32 p_size)=0
 Read bytes from storage into buffer. More...
 
virtual LegoResult Write (const void *p_buffer, LegoU32 p_size)=0
 Write bytes from buffer into storage. More...
 
virtual LegoResult GetPosition (LegoU32 &p_position)=0
 Get current read/write position in stream. More...
 
virtual LegoResult SetPosition (LegoU32 p_position)=0
 Set current read/write position in stream. More...
 
virtual LegoBool IsWriteMode ()
 Returns TRUE if object was opened in write mode. More...
 
virtual LegoBool IsReadMode ()
 Returns TRUE if object was opened in read mode. More...
 
LegoStorageWriteString (const char *p_data)
 Writes a length-prefixed string to storage. More...
 
LegoStorageWriteU8 (LegoU8 p_data)
 Writes an 8-bit unsigned value to storage. More...
 
LegoStorageWriteS16 (LegoS16 p_data)
 Writes a 16-bit signed value to storage. More...
 
LegoStorageWriteU16 (LegoU16 p_data)
 Writes a 16-bit unsigned value to storage. More...
 
LegoStorageWriteS32 (MxS32 p_data)
 Writes a 32-bit signed value to storage. More...
 
LegoStorageWriteU32 (MxU32 p_data)
 Writes a 32-bit unsigned value to storage. More...
 
LegoStorageWriteFloat (LegoFloat p_data)
 Writes a floating-point (single-precision) value to storage. More...
 
LegoStorageWriteVector (Mx3DPointFloat p_data)
 Writes a 3D vector (three floats) to storage. More...
 
LegoStorageWriteMxString (MxString p_data)
 Writes a length-prefixed MxString to storage. More...
 
LegoStorageReadString (char *p_data)
 Reads a length-prefixed string from storage. More...
 
LegoStorageReadU8 (LegoU8 &p_data)
 Reads an 8-bit unsigned value from storage. More...
 
LegoStorageReadS16 (LegoS16 &p_data)
 Reads a 16-bit signed value from storage. More...
 
LegoStorageReadU16 (LegoU16 &p_data)
 Reads a 16-bit unsigned value from storage. More...
 
LegoStorageReadS32 (MxS32 &p_data)
 Reads a 32-bit signed value from storage. More...
 
LegoStorageReadU32 (MxU32 &p_data)
 Reads a 32-bit unsigned value from storage. More...
 
LegoStorageReadFloat (LegoFloat &p_data)
 Reads a floating-point (single-precision) value from storage. More...
 
LegoStorageReadVector (Mx3DPointFloat &p_data)
 Reads a 3D vector (three floats) from storage. More...
 
LegoStorageReadMxString (MxString &p_data)
 Reads a length-prefixed string and stores it in an MxString object. More...
 

Protected Attributes

LegoU8 m_mode
 File open/access mode. More...
 

Detailed Description

Abstract base class providing an interface for file-like storage with binary and text read/write operations.

[AI]

Used as a polymorphic abstraction over file-backed and memory-backed streams for reading and writing primary built-in data types (strings, numbers, vectors) in LEGO Island. [AI]

Definition at line 16 of file legostorage.h.

Member Enumeration Documentation

◆ OpenFlags

File open mode flags for storage operations.

[AI]

c_read = Open for reading, c_write = Open for writing, c_text = Open as text file (else binary). [AI]

Enumerator
c_read 

Open for read operations. [AI].

c_write 

Open for write operations. [AI].

c_text 

Open in text mode, otherwise binary. [AI].

Definition at line 22 of file legostorage.h.

Constructor & Destructor Documentation

◆ LegoStorage()

LegoStorage::LegoStorage ( )
inline

Default constructor initializing mode to zero.

[AI]

Definition at line 31 of file legostorage.h.

◆ ~LegoStorage()

virtual LegoStorage::~LegoStorage ( )
inlinevirtual

Virtual destructor for safe polymorphic destruction.

[AI]

Definition at line 36 of file legostorage.h.

Member Function Documentation

◆ GetPosition()

virtual LegoResult LegoStorage::GetPosition ( LegoU32 p_position)
pure virtual

Get current read/write position in stream.

[AI]

Parameters
p_positionReference to receive current position [AI]
Returns
See implementation for SUCCESS/FAILURE [AI]

Implemented in LegoMemory, and LegoFile.

◆ IsReadMode()

virtual LegoBool LegoStorage::IsReadMode ( )
inlinevirtual

Returns TRUE if object was opened in read mode.

[AI]

Returns
TRUE if mode is read, FALSE otherwise [AI]

Definition at line 78 of file legostorage.h.

◆ IsWriteMode()

virtual LegoBool LegoStorage::IsWriteMode ( )
inlinevirtual

Returns TRUE if object was opened in write mode.

[AI]

Returns
TRUE if mode is write, FALSE otherwise [AI]

Definition at line 72 of file legostorage.h.

◆ Read()

virtual LegoResult LegoStorage::Read ( void *  p_buffer,
LegoU32  p_size 
)
pure virtual

Read bytes from storage into buffer.

[AI]

Parameters
p_bufferDestination buffer [AI]
p_sizeNumber of bytes to read [AI]
Returns
See implementation for SUCCESS/FAILURE [AI]

Implemented in LegoMemory, and LegoFile.

◆ ReadFloat()

LegoStorage * LegoStorage::ReadFloat ( LegoFloat p_data)
inline

Reads a floating-point (single-precision) value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

Definition at line 263 of file legostorage.h.

◆ ReadMxString()

LegoStorage * LegoStorage::ReadMxString ( MxString p_data)
inline

Reads a length-prefixed string and stores it in an MxString object.

[AI]

Parameters
p_dataOutput MxString to hold the read text [AI]
Returns
this for chaining [AI]

Definition at line 287 of file legostorage.h.

◆ ReadS16()

LegoStorage * LegoStorage::ReadS16 ( LegoS16 p_data)
inline

Reads a 16-bit signed value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

Definition at line 217 of file legostorage.h.

◆ ReadS32()

LegoStorage * LegoStorage::ReadS32 ( MxS32 p_data)
inline

Reads a 32-bit signed value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

[AI] Note: Parameter type may be incompatible with LegoS32.

Definition at line 240 of file legostorage.h.

◆ ReadString()

LegoStorage * LegoStorage::ReadString ( char *  p_data)
inline

Reads a length-prefixed string from storage.

[AI]

Reads string length, then chars (not null terminated), then writes '\0' at end. [AI]

Parameters
p_dataOutput character buffer (must be large enough for string + null terminator). [AI]
Returns
this for chaining [AI]

Definition at line 192 of file legostorage.h.

◆ ReadU16()

LegoStorage * LegoStorage::ReadU16 ( LegoU16 p_data)
inline

Reads a 16-bit unsigned value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

Definition at line 228 of file legostorage.h.

◆ ReadU32()

LegoStorage * LegoStorage::ReadU32 ( MxU32 p_data)
inline

Reads a 32-bit unsigned value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

[AI] Note: Parameter type may be incompatible with LegoU32.

Definition at line 252 of file legostorage.h.

◆ ReadU8()

LegoStorage * LegoStorage::ReadU8 ( LegoU8 p_data)
inline

Reads an 8-bit unsigned value from storage.

[AI]

Parameters
p_dataOutput variable to receive value [AI]
Returns
this for chaining [AI]

Definition at line 206 of file legostorage.h.

◆ ReadVector()

LegoStorage * LegoStorage::ReadVector ( Mx3DPointFloat p_data)
inline

Reads a 3D vector (three floats) from storage.

[AI]

Parameters
p_dataOutput variable to receive vector [AI]
Returns
this for chaining [AI]

Definition at line 274 of file legostorage.h.

◆ SetPosition()

virtual LegoResult LegoStorage::SetPosition ( LegoU32  p_position)
pure virtual

Set current read/write position in stream.

[AI]

Parameters
p_positionNew position to set [AI]
Returns
See implementation for SUCCESS/FAILURE [AI]

Implemented in LegoMemory, and LegoFile.

◆ Write()

virtual LegoResult LegoStorage::Write ( const void *  p_buffer,
LegoU32  p_size 
)
pure virtual

Write bytes from buffer into storage.

[AI]

Parameters
p_bufferSource buffer [AI]
p_sizeNumber of bytes to write [AI]
Returns
See implementation for SUCCESS/FAILURE [AI]

Implemented in LegoMemory, and LegoFile.

◆ WriteFloat()

LegoStorage * LegoStorage::WriteFloat ( LegoFloat  p_data)
inline

Writes a floating-point (single-precision) value to storage.

[AI]

Parameters
p_dataFloating-point value to write [AI]
Returns
this for chaining [AI]

Definition at line 156 of file legostorage.h.

◆ WriteMxString()

LegoStorage * LegoStorage::WriteMxString ( MxString  p_data)
inline

Writes a length-prefixed MxString to storage.

[AI]

Parameters
p_dataString to write [AI]
Returns
this for chaining [AI]

Definition at line 180 of file legostorage.h.

◆ WriteS16()

LegoStorage * LegoStorage::WriteS16 ( LegoS16  p_data)
inline

Writes a 16-bit signed value to storage.

[AI]

Parameters
p_dataValue to write [AI]
Returns
this for chaining [AI]

Definition at line 110 of file legostorage.h.

◆ WriteS32()

LegoStorage * LegoStorage::WriteS32 ( MxS32  p_data)
inline

Writes a 32-bit signed value to storage.

[AI]

Parameters
p_dataValue to write [AI]
Returns
this for chaining [AI]

[AI] Note: Parameter type may be incompatible with LegoS32.

Definition at line 133 of file legostorage.h.

◆ WriteString()

LegoStorage * LegoStorage::WriteString ( const char *  p_data)
inline

Writes a length-prefixed string to storage.

[AI]

String is prefixed by a 16-bit length, then content without null terminator. [AI]

Parameters
p_dataNull-terminated string to write [AI]
Returns
this for chaining [AI]

Definition at line 86 of file legostorage.h.

◆ WriteU16()

LegoStorage * LegoStorage::WriteU16 ( LegoU16  p_data)
inline

Writes a 16-bit unsigned value to storage.

[AI]

Parameters
p_dataValue to write [AI]
Returns
this for chaining [AI]

Definition at line 121 of file legostorage.h.

◆ WriteU32()

LegoStorage * LegoStorage::WriteU32 ( MxU32  p_data)
inline

Writes a 32-bit unsigned value to storage.

[AI]

Parameters
p_dataValue to write [AI]
Returns
this for chaining [AI]

[AI] Note: Parameter type may be incompatible with LegoU32.

Definition at line 145 of file legostorage.h.

◆ WriteU8()

LegoStorage * LegoStorage::WriteU8 ( LegoU8  p_data)
inline

Writes an 8-bit unsigned value to storage.

[AI]

Parameters
p_dataValue to write [AI]
Returns
this for chaining [AI]

Definition at line 99 of file legostorage.h.

◆ WriteVector()

LegoStorage * LegoStorage::WriteVector ( Mx3DPointFloat  p_data)
inline

Writes a 3D vector (three floats) to storage.

[AI]

Parameters
p_dataVector to write [AI]
Returns
this for chaining [AI]

Definition at line 167 of file legostorage.h.

Member Data Documentation

◆ m_mode

LegoU8 LegoStorage::m_mode
protected

File open/access mode.

See OpenFlags enum. [AI]

Definition at line 308 of file legostorage.h.


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