Difference between revisions of "Midware TMWBuffer"
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[Midware | Main page]] -> [[Midware_Components_Reference | Midware component reference]] -> [[ | + | [[Midware | Main page]] -> [[Midware_Components_Reference | Midware component reference]] -> [[Midware_TMWBuffer | TMWBuffer]] |
== Overview == | == Overview == | ||
Line 11: | Line 11: | ||
TMWBuffer provides methods and properties to read, write and sort data. Data is stored in a very simple format: a buffer dynamically allocated from memory that contains all fields and records. Fields and records boundaries are marked with delimiters. If control characaters or delimiters are found within data, they are escaped. Three delimiters are used: escape delimiter, field delimiter and record delimiter. They are placed at start of buffer in order to consitute a kind of dictionnary. | TMWBuffer provides methods and properties to read, write and sort data. Data is stored in a very simple format: a buffer dynamically allocated from memory that contains all fields and records. Fields and records boundaries are marked with delimiters. If control characaters or delimiters are found within data, they are escaped. Three delimiters are used: escape delimiter, field delimiter and record delimiter. They are placed at start of buffer in order to consitute a kind of dictionnary. | ||
+ | |||
+ | By default, MidWare use those delimiters (decimal code): | ||
+ | <syntaxhighlight lang="delphi"> | ||
+ | Field 18 | ||
+ | Record 20 | ||
+ | Escape 127 | ||
+ | </syntaxhighlight> | ||
+ | Escape delimiter is also used to mark meta data information within data buffer. Meta data is field type or general purpose meta data such as field layout. | ||
+ | |||
+ | If an escape character is followed by another escape character, then data contains a single character. Table below indicate the meaning of an escape character followed by another character: | ||
+ | <syntaxhighlight lang="delphi"> | ||
+ | C Carriage return | ||
+ | L Line feed | ||
+ | F Field delimiter | ||
+ | R Record delimiter | ||
+ | N Null character | ||
+ | T Field type follow (used for blobs: S=String) | ||
+ | </syntaxhighlight> | ||
+ | Other uppercase characters are marking start of variable length general purpose meta data. End of meta data is marked with escape character and corresponding lower case letter. | ||
== Properties == | == Properties == | ||
Line 20: | Line 39: | ||
| valign="top" | [[Midware_TMWBuffer.DataBuffer | DataBuffer]] |||| Gives access to the underlaying data buffer. | | valign="top" | [[Midware_TMWBuffer.DataBuffer | DataBuffer]] |||| Gives access to the underlaying data buffer. | ||
|- | |- | ||
− | | valign="top" | [[Midware_TMWBuffer.DataBufferCount | DataBufferCount]] |||| | + | | valign="top" | [[Midware_TMWBuffer.DataBufferCount | DataBufferCount]] |||| The size in bytes of the data present in the buffer. |
|- | |- | ||
| valign="top" | [[Midware_TMWBuffer.DataBufferSize | DataBufferSize]] |||| The size in bytes of the current buffer. | | valign="top" | [[Midware_TMWBuffer.DataBufferSize | DataBufferSize]] |||| The size in bytes of the current buffer. | ||
Line 42: | Line 61: | ||
| valign="top" | [[Midware_TMWBuffer.RecordCount | RecordCount]] |||| Readonly property RecordCount retunrs the number of records stored in TMWBuffer. See also FieldCount. | | valign="top" | [[Midware_TMWBuffer.RecordCount | RecordCount]] |||| Readonly property RecordCount retunrs the number of records stored in TMWBuffer. See also FieldCount. | ||
|} | |} | ||
+ | |||
+ | == Methods == | ||
+ | |||
+ | {| | ||
+ | | width="140" valign="top" | [[Midware_TMWBuffer.AppendMetaData | AppendMetaData]] |||| AppendMetaData will add variable length, general purpose meta data at the end of current field. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Assign | Assign]] |||| The Assign method copies data from a TMWBuffer component to another. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.AppendBinaryField | AppendBinaryField]] |||| Write binary data as field content. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.AppendFields | AppendFields]] |||| Append fields to the current record. See also WriteFields. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.AppendRecord | AppendRecord]] |||| Append a single record from another TMWBuffer. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.AppendStreamField | AppendStreamField]] |||| Append a stream field to current record. See also WriteStreamField. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Delete | Delete]] |||| Delete the current record. Deleted records are physically lost. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.ExpandBuffer | ExpandBuffer]] |||| ExpandBuffer method check how much free space is left and will try to expand data buffer as needed. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.First | First]] |||| First method makes the first record the current one. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.FreeBookmark | FreeBookmark]] |||| Free resources used for bookmark keeping. See GetBookmark. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.GetBookmark | GetBookmark]] |||| Get a bookmark on current record. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.GetStreamField | GetStreamField]] |||| Get a stream (blob) field value from the buffer. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.GotoBookmark | GotoBookmark]] |||| Return the current position to the bookmark setup by GetBookmark. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.IsValidFields | IsValidFields]] |||| IsValidFields check if a field number is valid for use with Fields indexed property. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Last | Last]] |||| Last method will make the lsat record the current one. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.LoadFromFile | LoadFromFile]] |||| Load TMWBuffer content from a files created with SaveToFile or SaveToStream. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.LoadFromStream | LoadFromStream]] |||| Load TMWBuffer content from a stream created by SaveToStream or SaveToFile. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Locate | Locate]] |||| Locate a record by sequential search. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Next | Next]] |||| Next method makes the next record the current one. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Prior | Prior]] |||| Prior method makes the previous record the current one. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.RecordToString | RecordToString]] |||| Return the current record expressed as a string. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Rewrite | Rewrite]] |||| Clear buffer content and prepare for new writing. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.SaveToFile | SaveToFile]] |||| Save TMWBuffer data to a file. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.SaveToStream | SaveToStream]] |||| Save TMWBuffer data to a stream. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Seek | Seek]] |||| Set current record to the one indicated by nPos which results from a previous call to Tell method. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Sort | Sort]] |||| Sort will sort TMWBuffer content. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.StringToRecord | StringToRecord]] |||| Reverse operation for RecordToString. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.StringToRecords | StringToRecords]] |||| Same as StringToRecord, but applied for several records. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.Tell | Tell]] |||| Return the internal position for the current record. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.WriteDataBuffer | WriteDataBuffer]] |||| Append data from a buffer to the record buffer. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.WriteFields | WriteFields]] |||| WriteFields will write fields to the next record or append fields to the current record as per NewRec argument. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.WriteRecordMarker | WriteRecordMarker]] |||| Terminate the current record. | ||
+ | |- | ||
+ | | valign="top" | [[Midware_TMWBuffer.WriteStreamField | WriteStreamField]] |||| Write a single stream (blob) field. | ||
+ | |} | ||
+ | |||
+ | == How To == | ||
+ | |||
+ | {{Midware_Components_Footer}} |
Latest revision as of 15:27, 24 May 2011
Main page -> Midware component reference -> TMWBuffer
Contents
Overview
unit | RFormat.pas |
TMWBuffer if a very important component in MidWare technology. TMWBuffer implement data storage and formatting for transmission. Data echanged between client and server is exactly TMWBuffer content, byte for byte.
TMWBuffer can be seen as a data table in memory. This table is organized as records made of variable field number, each field having a variable length.
TMWBuffer provides methods and properties to read, write and sort data. Data is stored in a very simple format: a buffer dynamically allocated from memory that contains all fields and records. Fields and records boundaries are marked with delimiters. If control characaters or delimiters are found within data, they are escaped. Three delimiters are used: escape delimiter, field delimiter and record delimiter. They are placed at start of buffer in order to consitute a kind of dictionnary.
By default, MidWare use those delimiters (decimal code): <syntaxhighlight lang="delphi">
Field 18 Record 20 Escape 127
</syntaxhighlight> Escape delimiter is also used to mark meta data information within data buffer. Meta data is field type or general purpose meta data such as field layout.
If an escape character is followed by another escape character, then data contains a single character. Table below indicate the meaning of an escape character followed by another character: <syntaxhighlight lang="delphi">
C Carriage return L Line feed F Field delimiter R Record delimiter N Null character T Field type follow (used for blobs: S=String)
</syntaxhighlight> Other uppercase characters are marking start of variable length general purpose meta data. End of meta data is marked with escape character and corresponding lower case letter.
Properties
AutoExpand | AutoExpand property tells the component if the data buffer can be expanded when it is too short for the data that needs to be written to it. | |
Bof | Bof property is TRUE when current position has reached begin of file. | |
DataBuffer | Gives access to the underlaying data buffer. | |
DataBufferCount | The size in bytes of the data present in the buffer. | |
DataBufferSize | The size in bytes of the current buffer. | |
Eof | Eof property is TRUE when current position has reached end of file. | |
FieldCount | Returns the number of fields in the current record. | |
Fields | The indexed Fields[] property gives access to the current record's fields. | |
FieldSize | Return field size in bytes. | |
FieldType | Read only indexed property returning filed type for a given field in current record. | |
HasData | HasData property is TRUE when TMWBuffer contains data. | |
HeaderSize | Size in byte of the header in the data buffer. Default to 0. | |
MetaData | Read only indexed MetaData property gives access to the current record's meta data (application defined). | |
RecordCount | Readonly property RecordCount retunrs the number of records stored in TMWBuffer. See also FieldCount. |
Methods
AppendMetaData | AppendMetaData will add variable length, general purpose meta data at the end of current field. | |
Assign | The Assign method copies data from a TMWBuffer component to another. | |
AppendBinaryField | Write binary data as field content. | |
AppendFields | Append fields to the current record. See also WriteFields. | |
AppendRecord | Append a single record from another TMWBuffer. | |
AppendStreamField | Append a stream field to current record. See also WriteStreamField. | |
Delete | Delete the current record. Deleted records are physically lost. | |
ExpandBuffer | ExpandBuffer method check how much free space is left and will try to expand data buffer as needed. | |
First | First method makes the first record the current one. | |
FreeBookmark | Free resources used for bookmark keeping. See GetBookmark. | |
GetBookmark | Get a bookmark on current record. | |
GetStreamField | Get a stream (blob) field value from the buffer. | |
GotoBookmark | Return the current position to the bookmark setup by GetBookmark. | |
IsValidFields | IsValidFields check if a field number is valid for use with Fields indexed property. | |
Last | Last method will make the lsat record the current one. | |
LoadFromFile | Load TMWBuffer content from a files created with SaveToFile or SaveToStream. | |
LoadFromStream | Load TMWBuffer content from a stream created by SaveToStream or SaveToFile. | |
Locate | Locate a record by sequential search. | |
Next | Next method makes the next record the current one. | |
Prior | Prior method makes the previous record the current one. | |
RecordToString | Return the current record expressed as a string. | |
Rewrite | Clear buffer content and prepare for new writing. | |
SaveToFile | Save TMWBuffer data to a file. | |
SaveToStream | Save TMWBuffer data to a stream. | |
Seek | Set current record to the one indicated by nPos which results from a previous call to Tell method. | |
Sort | Sort will sort TMWBuffer content. | |
StringToRecord | Reverse operation for RecordToString. | |
StringToRecords | Same as StringToRecord, but applied for several records. | |
Tell | Return the internal position for the current record. | |
WriteDataBuffer | Append data from a buffer to the record buffer. | |
WriteFields | WriteFields will write fields to the next record or append fields to the current record as per NewRec argument. | |
WriteRecordMarker | Terminate the current record. | |
WriteStreamField | Write a single stream (blob) field. |