TReader¶
Generic reader object which reads component data from any given source.
Declaration¶
Source position: classesh.inc line 1998
type
TReader = class(TFiler)
public
constructor Create;
destructor Destroy;
procedure FlushBuffer;
procedure BeginReferences;
procedure CheckValue;
procedure DefineProperty;
procedure DefineBinaryProperty;
function EndOfList : Boolean;
procedure EndReferences;
procedure FixupReferences;
procedure SkipValue;
function NextValue : TValueType;
procedure Read;
procedure ReadPrefix;
function ReadBoolean : Boolean;
function ReadChar : AnsiChar;
function ReadWideChar : WideChar;
function ReadUnicodeChar : UnicodeChar;
procedure ReadCollection;
function ReadComponent : TComponent;
procedure ReadComponents;
function ReadFloat : Extended;
function ReadSingle : Single;
function ReadDouble : Double;
function ReadDate : TDateTime;
function ReadCurrency : Currency;
function ReadIdent : RawByteString;
function ReadInteger : LongInt;
function ReadInt64 : Int64;
function ReadSet : Integer;
procedure ReadListBegin;
procedure ReadListEnd;
function ReadRootComponent : TComponent;
function ReadComponentDeltaRes : TComponent;
function ReadVariant : Variant;
procedure ReadSignature;
function ReadStr : RawByteString;
function ReadString : RawByteString;
function ReadWideString : WideString;
function ReadUnicodeString : UnicodeString;
function ReadValue : TValueType;
procedure CopyValue;
property Driver: TAbstractObjectReader; {r}
property Owner: TComponent; {rw}
property Parent: TComponent; {rw}
property OnError: TReaderError; {rw}
property OnPropertyNotFound: TPropertyNotFoundEvent; {rw}
property OnFindMethod: TFindMethodEvent; {rw}
property OnSetMethodProperty: TSetMethodPropertyEvent; {rw}
property OnSetName: TSetNameEvent; {rw}
property OnReferenceName: TReferenceNameEvent; {rw}
property OnAncestorNotFound: TAncestorNotFoundEvent; {rw}
property OnCreateComponent: TCreateComponentEvent; {rw}
property OnFindComponentClass: TFindComponentClassEvent; {rw}
property OnFindComponentClassEx: TFindComponentClassExEvent; {rw}
property OnReadStringProperty: TReadWriteStringPropertyEvent; {rw}
property RawMode: Boolean; {rw}
property DelphiCompatible: Boolean; {rw}
end;
Description¶
The TReader class is a reader class that implements generic component streaming capabilities, independent of the format of the data in the stream. It uses a driver class TAbstractObjectReader to do the actual reading of data. The interface of the TReader class should be identical to the interface in Delphi.
Note that the TReader design is such that it can read a single component from a stream. It will read all children of this component, but it is not designed to read multiple components in succession from one stream.
It should never be necessary to create an instance of this class directly. Instead, the TStream.ReadComponent call should be used.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| DelphiCompatible | public | |
| Driver read only | public | The driver in use for streaming the data. |
| Owner | public | Owner of the component being read. |
| Parent | public | Parent of the component being read. |
| RawMode | public |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| BeginReferences | public | Initializes the component referencing mechanism. |
| CheckValue | public | Raises an exception if the next value in the stream is not of type Value. |
| CopyValue | public | Copy a value to a writer. |
| Create | public | Creates a new reader class. |
| DefineBinaryProperty | public | Reads a user-defined binary property from the stream. |
| DefineProperty | public | Reads a user-defined property from the stream. |
| Destroy | public | Destroys a reader class. |
| EndOfList | public | Returns true if the stream contains an end-of-list marker. |
| EndReferences | public | Finalizes the component referencing mechanism. |
| FixupReferences | public | Tries to resolve all unresolved component references. |
| FlushBuffer | public | Flush the buffer. |
| NextValue | public | Returns the type of the next value. |
| Read | public | Read raw data from stream. |
| ReadBoolean | public | Reads a boolean from the stream. |
| ReadChar | public | Reads a character from the stream. |
| ReadCollection | public | Reads a collection from the stream. |
| ReadComponent | public | Starts reading a component from the stream. |
| ReadComponentDeltaRes | public | |
| ReadComponents | public | Starts reading child components from the stream. |
| ReadCurrency | public | Read a currency value from the stream. |
| ReadDate | public | Reads a date from the stream. |
| ReadDouble | public | |
| ReadFloat | public | Reads a float from the stream. |
| ReadIdent | public | Reads an identifier from the stream. |
| ReadInt64 | public | Reads a 64-bit integer from the stream. |
| ReadInteger | public | Reads an integer from the stream. |
| ReadListBegin | public | Checks for the beginning of a list. |
| ReadListEnd | public | Checks for the end of a list. |
| ReadPrefix | public | |
| ReadRootComponent | public | Starts reading a root component. |
| ReadSet | public | Read a set value from the stream. |
| ReadSignature | public | Read stream signature from the stream. |
| ReadSingle | public | Reads a single-type real from the stream. |
| ReadStr | public | |
| ReadString | public | Reads a string from the stream. |
| ReadUnicodeChar | public | Read Unicode character. |
| ReadUnicodeString | public | Read a UnicodeString value from the stream. |
| ReadValue | public | Reads the next value type from the stream. |
| ReadVariant | public | Read a variant from the stream. |
| ReadWideChar | public | Read widechar from the stream. |
| ReadWideString | public | Read a WideString value from the stream. |
| SkipValue | public |
Events¶
| Member | Visibility | Description |
|---|---|---|
| OnAncestorNotFound | public | Handler called when the ancestor component cannot be found. |
| OnCreateComponent | public | Handler called when a component needs to be created. |
| OnError | public | Handler called when an error occurs. |
| OnFindComponentClass | public | Handler called when a component class reference needs to be found. |
| OnFindComponentClassEx | public | |
| OnFindMethod | public | Handler to find or change a method address. |
| OnPropertyNotFound | public | Handler for treating missing properties. |
| OnReadStringProperty | public | Handler for translating strings when read from the stream. |
| OnReferenceName | public | Handler called when another component is referenced. |
| OnSetMethodProperty | public | Handler for setting method properties. |
| OnSetName | public | Handler called when setting a component name. |
See also¶
| Name | Description |
|---|---|
| TFiler | Class responsible for streaming of components. |
| TWriter | Object to write component data to an arbitrary format. |
| TAbstractObjectReader | Abstract driver class to read stored component data. |