[libgfc Index] [libgfc Hierarchy] [Headers]
DataPipe maintains an extensible in-memory binary data stream More...
#include <src/gdatapipe.h>
DataPipe maintains an extensible in-memory binary data stream.
This class can be used as a dynamic array or a pipeline
stream for serializing classes' persistent data members.
The central information about the pipe is the 'cursor', which
indicates the current position where subsequent methods such as
append , and fetch will start. Such methods
will reposition the cursor accordingly upon the completion of
the operation. Other important data members of DataPipe includes
the "size" of the data in the pipe and the "ptr" to the location
wehre the data is stored in memory.
Every ADT in GFC defines at least two methods to store/retrive persistent
member data into and out of a pipe. They are the store
method and the load method. Additionaly there are two
global operators "DataPipe<<" and "DataPipe>>" for each ADT which can
be used handy when pumping several ADT objects into the same pipe.
Some sample use:
GPolygon poly1;
GRect rect1;
... do some thing on poly1 and rect1 ...
DataPipe p;
p << poly1 <<rect1;
db.create_record(p.ptr(), p.size()); //store into the database
DataPipe also accepts standard built-in types such as int, float,
char* etc. Here is another example:
DataPipe p1;
int x=100, y=200;
float dist = 1000;
char *name = "Pittsburgh";
p1 <<x << y << dist << name;
DataPipe p2 (p);
p2 >> x2 >> y2 >> dist2 >> name2;
...
TODO
Make DataPipe be able to redirect to i/o streams.
[public]
seek directions
[public virtual]
asignment operator
[public]
This method appends data to the pipe. append new data to the end of the existing data buffer and advance cursor. The buffer in the pipe get automatically expanded if length is greater than available space in pipe.
data | is the data to be add to the pipe length the size of the new data |
[public]
insert a chunk of data at the beginning of the pipe. New data is always put in the position 0 of the internal buffer. Existing data gets shifted to the tail by "length".
[public]
copy a chunk of data starting at cursor into 'dest'; the cursor in the pipe is advanced accordingly
[public]
attach this pipe to a pointer
[public]
detach the previously attached pointer
[public]
extend the capacity for the pipe to the 'new_capacity'. Old contents are preserved.
[public]
move the cursor to the specified position
[public]
return the position (beginning with 0) of the cursor
[public]
return the pointer at cursor
[public]
memset all data to zeros; keep the capacity intact; reset cursor to 0
[public]
return the pointer to the beginning of the data
[public]
type conversiion operator;
[public]
const char* conversion
[public]
return true if reached end of pipe (eop)
[public]
return the data size
[public]
return the capacity
[public]
reutrn free space in the array
[public]
print the data pipe
Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999 | Kdoc |