LXPBlock

Description Support for cross-platform data exchange
Header file LXPBlock.h
Author Camil Demetrescu
Created Dec 15, 2001
Last updated Sep 25, 2003

 

Contents


Introduction

The component LXPBlock (XP=cross-platform) provides operations for maintaining a collection of numerical and non-numerical data. The collection is stored as a memory block that can be shared among different platforms. To allow portability of numerical data across different architectures, numbers are stored in big-endian format in the block.


Interface

Constants

LXPBLock_ID

LXPBlock_UNEXPECTED_END_OF_BLOCK

Types

LXPBlock
  
enum {
    LXPBlock_START,
    LXPBlock_CURR,
    LXPBlock_END
} LXPBlock_TSeekMode

Functions

LXPBlock*           LXPBlock_New            ();
LXPBlock*           LXPBlock_NewFromData    (void* inData, ui4 inSize);
void                LXPBlock_Delete         (LXPBlock* This);

void                LXPBlock_Write          (LXPBlock* This, const void* inData, ui4 inSize);
ui4                 LXPBlock_Read           (LXPBlock* This, void* outData, ui4 inSize);

void                LXPBlock_WriteXPBlock   (LXPBlock* This, const LXPBlock* inXPBlock);
LXPBlock*           LXPBlock_ReadXPBlock    (LXPBlock* This);

void                LXPBlock_WriteN1        (LXPBlock* This, const void* inVal);
void                LXPBlock_WriteN2        (LXPBlock* This, const void* inVal);
void                LXPBlock_WriteN4        (LXPBlock* This, const void* inVal);
void                LXPBlock_WriteN8        (LXPBlock* This, const void* inVal);

void                LXPBlock_ReadN1         (LXPBlock* This, void* outVal);
void                LXPBlock_ReadN2         (LXPBlock* This, void* outVal);
void                LXPBlock_ReadN4         (LXPBlock* This, void* outVal);
void                LXPBlock_ReadN8         (LXPBlock* This, void* outVal);

void                LXPBlock_Seek           (LXPBlock* This, i4 inOffset, LXPBlock_TSeekMode inMode);
ui4                 LXPBlock_Tell           (LXPBlock* This);
void                LXPBlock_Rewind         (LXPBlock* This);

void*               LXPBlock_GetData        (LXPBlock* This);
ui4                 LXPBlock_GetSize        (LXPBlock* This);

Function Arguments Description Returns Throws
New
-

Create empty XP block. The current block position after the operation is zero. Caller is responsible of dellocating the created object using LXPBlock_Delete.

LXPBlock*

pointer to newly created object.

-
NewFromData

void** inData

Create XP block starting from data segment *inData of size inSize. Numbers in the data segment are expected to be represented in big-endian format. The current block position after the operation is zero. The LXPBlock object becomes responsible of deallocating the segment *inData. Caller is responsible of dellocating the created object using LXPBlock_Delete. *inData is set to NULL.

LXPBlock*

pointer to newly created object.

-
ui4 inSize
Delete
LXPBlock** ThisA Release object pointed to by *ThisA. *ThisA is set to NULL. void -
Write
LXPBlock* This Write to block This the memory segment of size inSize pointed by inData. The current block position is advanced by inSize bytes after the operation. void -
const void* inData
ui4 inSize
Read
LXPBlock* This Read from block This inSize bytes, copying them to buffer outData. Caller must make sure that buffer is large enough to hold inSize bytes. The current block position is advanced by inSize bytes after the operation.

void

UNEXPECTED_END_OF_BLOCK if operation fails.
void* outData
ui4 inSize
WriteXPBlock
LXPBlock* This Write to block This the size of inBlock (as returned by LXPBlock_GetSize(inBlock)) and the data of inBlock (as returned by LXPBlock_GetData(inBlock)). The current block position is advanced by 4+LXPBlock_GetSize(inBlock) bytes after the operation. void -
const LXPBlock* inBlock
ReadXPBlock
LXPBlock* This Read from block This the data of an LXPBlock previously written with LXPBlock_WriteXPBlock. The current block position is advanced by 4+LXPBlock_GetSize(returned block) bytes after the operation. Caller is responsible of dellocating the created object using LXPBlock_Delete.

LXPBlock*

Pointer to a newly created LXPBlock object.

UNEXPECTED_END_OF_BLOCK if operation fails.
WriteN1
WriteN2
WriteN4
WriteN8
LXPBlock* This

Write to block This the number of size 1, 2, 4, or 8 bytes stored in buffer inVal. Numbers of size >1 byte are written to file in big endian format. The current block position is advanced by 1,2,4, or 8 bytes after the operation.

Use this function ... to write values of these types
WriteN1 i1, ui1
WriteN2 i2, ui2
WriteN4 i4, ui4, f4
WriteN8 f8
void -
const void* inVal
ReadN1
ReadN2
ReadN4
ReadN8
LXPBlock* This

Read from block This a number of size 1, 2, 4, or 8 bytes and copy it to buffer pointed by outVal.Caller must make sure that buffer is large enough to hold the value. The current file position is advanced by 1,2,4, or 8 bytes after the operation.

Use this function ... to read values of these types
WriteN1 i1, ui1
WriteN2 i2, ui2
WriteN4 i4, ui4, f4
WriteN8 f8
void UNEXPECTED_END_OF_BLOCK if operation fails.
void* outVal
Seek
LXPBlock* This

Move current position in block This by inOffsetbytes starting from the position specified by inMode:

inMode Position relative to
START beginning of the block
CURR current position in the block
END end of the block

If the resulting position is negative, then the current position is set to the beginning of the block. If the resulting position falls beyond the end of the block, the current position is set to the end of the block.

void -
i4 inOffset
TSeekMode inMode
Tell
LXPBlock* This -

ui4

Current position in block This.

-
Rewind
LXPBlock* This Reset current position to the beginning of the XP block. Equivalent to Seek(This,0,LXPBlock_START)

ui4

Current position in block This.

-
GetData
LXPBlock* This Get access to the data segment of block This. To obtain the size in bytes of the data segment use function GetSize. Numbers on the data segment are represented in big-endian format. Caller should not deallocate the pointer returned by GetBlock.

void*

Pointer to the object's data segment.

-
GetSize
LXPBlock* This Get the size of the object's data segment.

ui4

Size in bytes of the object's data segment.

-


Revision history