88 LegoS16 length = strlen(p_data);
90 Write(p_data, length);
101 Write(&p_data,
sizeof(p_data));
112 Write(&p_data,
sizeof(p_data));
123 Write(&p_data,
sizeof(p_data));
135 Write(&p_data,
sizeof(p_data));
147 Write(&p_data,
sizeof(p_data));
158 Write(&p_data,
sizeof(p_data));
196 Read(p_data, length);
197 p_data[length] =
'\0';
208 Read(&p_data,
sizeof(p_data));
219 Read(&p_data,
sizeof(p_data));
230 Read(&p_data,
sizeof(p_data));
242 Read(&p_data,
sizeof(p_data));
254 Read(&p_data,
sizeof(p_data));
265 Read(&p_data,
sizeof(p_data));
292 char* text =
new char[length + 1];
Implementation of LegoStorage for file-backed storage using stdio FILE*.
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from file at current position.
FILE * m_file
C runtime file pointer backing storage.
~LegoFile() override
Destructor.
LegoFile()
Default constructor initializes with NULL file pointer.
LegoResult GetPosition(LegoU32 &p_position) override
Gets the current file pointer position relative to beginning.
LegoResult Open(const char *p_name, LegoU32 p_mode)
Opens a file with given name and mode, closing existing file if needed.
LegoResult Write(const void *p_buffer, LegoU32 p_size) override
Writes bytes to file at current position.
LegoResult SetPosition(LegoU32 p_position) override
Sets the current file pointer position.
Implementation of LegoStorage for memory-backed buffers.
LegoU8 * m_buffer
Pointer to target memory buffer for reading/writing.
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from memory buffer at current position.
LegoResult GetPosition(LegoU32 &p_position) override
Gets the current offset into the memory buffer.
LegoU32 m_position
Current read/write offset in buffer.
LegoResult Write(const void *p_buffer, LegoU32 p_size) override
Writes bytes to memory buffer at current position.
LegoResult SetPosition(LegoU32 p_position) override
Sets the current offset into the memory buffer.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
virtual LegoResult Write(const void *p_buffer, LegoU32 p_size)=0
Write bytes from buffer into storage.
LegoStorage * WriteVector(Mx3DPointFloat p_data)
Writes a 3D vector (three floats) to storage.
LegoStorage * ReadFloat(LegoFloat &p_data)
Reads a floating-point (single-precision) value from storage.
LegoStorage * WriteU32(MxU32 p_data)
Writes a 32-bit unsigned value to storage.
LegoStorage * ReadMxString(MxString &p_data)
Reads a length-prefixed string and stores it in an MxString object.
LegoStorage * ReadU32(MxU32 &p_data)
Reads a 32-bit unsigned value from storage.
LegoStorage * ReadVector(Mx3DPointFloat &p_data)
Reads a 3D vector (three floats) from storage.
LegoStorage * WriteU8(LegoU8 p_data)
Writes an 8-bit unsigned value to storage.
virtual LegoBool IsWriteMode()
Returns TRUE if object was opened in write mode.
LegoStorage * ReadU8(LegoU8 &p_data)
Reads an 8-bit unsigned value from storage.
LegoStorage * WriteS16(LegoS16 p_data)
Writes a 16-bit signed value to storage.
LegoU8 m_mode
File open/access mode.
LegoStorage * ReadS16(LegoS16 &p_data)
Reads a 16-bit signed value from storage.
LegoStorage * ReadS32(MxS32 &p_data)
Reads a 32-bit signed value from storage.
LegoStorage * ReadU16(LegoU16 &p_data)
Reads a 16-bit unsigned value from storage.
virtual ~LegoStorage()
Virtual destructor for safe polymorphic destruction.
virtual LegoResult SetPosition(LegoU32 p_position)=0
Set current read/write position in stream.
virtual LegoResult Read(void *p_buffer, LegoU32 p_size)=0
Read bytes from storage into buffer.
LegoStorage()
Default constructor initializing mode to zero.
virtual LegoBool IsReadMode()
Returns TRUE if object was opened in read mode.
LegoStorage * WriteString(const char *p_data)
Writes a length-prefixed string to storage.
LegoStorage * ReadString(char *p_data)
Reads a length-prefixed string from storage.
LegoStorage * WriteFloat(LegoFloat p_data)
Writes a floating-point (single-precision) value to storage.
LegoStorage * WriteU16(LegoU16 p_data)
Writes a 16-bit unsigned value to storage.
OpenFlags
File open mode flags for storage operations.
@ c_read
Open for read operations. [AI].
@ c_write
Open for write operations. [AI].
@ c_text
Open in text mode, otherwise binary. [AI].
virtual LegoResult GetPosition(LegoU32 &p_position)=0
Get current read/write position in stream.
LegoStorage * WriteS32(MxS32 p_data)
Writes a 32-bit signed value to storage.
LegoStorage * WriteMxString(MxString p_data)
Writes a length-prefixed MxString to storage.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Mindscape custom string class for managing dynamic C-strings within the game engine.
char * GetData() const
Returns a pointer to the internal character buffer.
[AI] Defines basic fixed-width data types and platform-neutral constants for LEGO Island codebase.
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
unsigned char LegoU8
[AI] Unsigned 8-bit integer type used throughout LEGO Island.
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
unsigned short LegoU16
[AI] Unsigned 16-bit integer type for cross-platform compatibility.
short LegoS16
[AI] Signed 16-bit integer type for cross-platform compatibility.
float LegoFloat
[AI] Floating point type used throughout LEGO Island.
LegoU8 LegoBool
[AI] Boolean value used throughout the codebase.