X11 Work Bench Toolkit  1.0
__file_help_buf__ Struct Reference

basic 'buffered I/O' object structure for 'FileBuf' APIs More...

#include <file_help.h>

Data Fields

struct __file_help_buf__pPrev
 pointer to 'previous' item in linked list (NULL for owner object)
 
struct __file_help_buf__pNext
 pointer to 'next' item in linked list (NULL for last object)
 
long lBufferSize
 size of entire buffer
 
long lBufferCount
 number of bytes of valid data
 
long lLineCount
 number of lines in 'cData' when ppLineBuf not NULL
 
long lLineBufSize
 size of memory block pointed to by 'ppLineBuf'
 
int iFlags
 various bit flags
 
char ** ppLineBuf
 array of pointers to beginning of each line (WBAlloc'd TODO: make it part of 'cData'?)
 
char cData [sizeof(char *)]
 the data itself (aligned to size of a pointer)
 

Detailed Description

basic 'buffered I/O' object structure for 'FileBuf' APIs

This structure is intended to assist implementing buffered I/O for files that contain multiple lines separated by linefeeds. A 'file edit' window or dialog control could use one of these objects to assist with displaying and editing text based on the contents of a file. It would also be possible to construct a file_help_buf_t object from a memory buffer as well as from a text file.

typedef struct __file_help_buf__
{
struct __file_help_buf__ *pPrev; // pointer to 'previous' item in linked list (NULL for owner object)
struct __file_help_buf__ *pNext; // pointer to 'next' item in linked list (NULL for last object)
long lBufferSize; // size of entire buffer
long lBufferCount; // number of bytes of valid data
long lLineCount; // number of lines in 'cData' when ppLineBuf not NULL
long lLineBufSize; // size of memory block pointed to by 'ppLineBuf'
int iFlags; // various bit flags
char **ppLineBuf; // array of pointers to beginning of each line (WBAlloc'd TODO: make it part of 'cData'?)
char cData[sizeof(char *)]; // the data itself (aligned to size of a pointer)

TODO: 'ppLineBuf' should point to an area within cData. If 'pNext' is valid, subsequent lines could be pointed to by the 'ppLineBuf' within the structure pointed to by 'pNext'. In this way line pointers can be re-structured without re-allocating memory. Additionally, there is no reason why lines must be contiguous, so inserting and removing lines can make use of the additional allocated space pointed to by 'pNext'.
As it would become fragmented, it would also be a good idea to re-build the structure periodically using FBParseFileBuf()

Definition at line 140 of file file_help.h.


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