TReader
[Properties (by Name)][Methods (by Name)][Events (by Name)]
Generic reader object which reads component data from any given source.
Declaration
Source position: classesh.inc line 1499
Type
TReader = class (TFiler)
private
FDriver : TAbstractObjectReader;
FOwner : TComponent;
FParent : TComponent;
FFixups : TObject;
FLoaded : TFPList;
FLock : TRTLCRITICALSECTION;
FOnFindMethod : TFindMethodEvent;
FOnSetMethodProperty : TSetMethodPropertyEvent;
FOnSetName : TSetNameEvent;
FOnReferenceName : TReferenceNameEvent;
FOnAncestorNotFound : TAncestorNotFoundEvent;
FOnError : TReaderError;
FOnPropertyNotFound : TPropertyNotFoundEvent;
FOnFindComponentClass : TFindComponentClassEvent;
FOnCreateComponent : TCreateComponentEvent;
FPropName : string;
FCanHandleExcepts : Boolean;
FOnReadStringProperty : TReadWriteStringPropertyEvent;
procedure DoFixupReferences;
function FindComponentClass(const AClassName: string) : TComponentClass;
procedure Lock;
procedure Unlock;
protected
function Error(const Message: string) : Boolean; Virtual;
function FindMethod(ARoot: TComponent; const AMethodName: string)
: CodePointer; Virtual;
procedure ReadProperty(AInstance: TPersistent);
procedure ReadPropValue(Instance: TPersistent; PropInfo: Pointer);
procedure PropertyError;
procedure ReadData(Instance: TComponent);
PropName : string;
CanHandleExceptions : Boolean;
function CreateDriver(Stream: TStream; BufSize: Integer)
: TAbstractObjectReader; Virtual;
public
constructor Create(Stream: TStream; BufSize: Integer);
destructor Destroy; Override;
procedure FlushBuffer; Override;
procedure BeginReferences;
procedure CheckValue(Value: TValueType);
procedure DefineProperty(const Name: string; AReadData: TReaderProc;
WriteData: TWriterProc; HasData: Boolean)
; Override;
procedure DefineBinaryProperty(const Name: string;
AReadData: TStreamProc;
WriteData: TStreamProc; HasData: Boolean)
; Override;
function EndOfList : Boolean;
procedure EndReferences;
procedure FixupReferences;
function NextValue : TValueType;
procedure Read(var Buf; Count: LongInt); Virtual;
function ReadBoolean : Boolean;
function ReadChar : Char;
function ReadWideChar : WideChar;
function ReadUnicodeChar : UnicodeChar;
procedure ReadCollection(Collection: TCollection);
function ReadComponent(Component: TComponent) : TComponent;
procedure ReadComponents(AOwner: TComponent; AParent: TComponent;
Proc: TReadComponentsProc);
function ReadFloat : Extended;
function ReadSingle : Single;
function ReadDate : TDateTime;
function ReadCurrency : Currency;
function ReadIdent : string;
function ReadInteger : LongInt;
function ReadInt64 : Int64;
function ReadSet(EnumType: Pointer) : Integer;
procedure ReadListBegin;
procedure ReadListEnd;
function ReadRootComponent(ARoot: TComponent) : TComponent;
function ReadVariant : Variant;
procedure ReadSignature;
function ReadString : string;
function ReadWideString : WideString;
function ReadUnicodeString : UnicodeString;
function ReadValue : TValueType;
procedure CopyValue(Writer: TWriter);
Driver : TAbstractObjectReader;
Owner : TComponent;
Parent : TComponent;
OnError : TReaderError;
OnPropertyNotFound : TPropertyNotFoundEvent;
OnFindMethod : TFindMethodEvent;
OnSetMethodProperty : TSetMethodPropertyEvent;
OnSetName : TSetNameEvent;
OnReferenceName : TReferenceNameEvent;
OnAncestorNotFound : TAncestorNotFoundEvent;
OnCreateComponent : TCreateComponentEvent;
OnFindComponentClass : TFindComponentClassEvent;
OnReadStringProperty : TReadWriteStringPropertyEvent;
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.
Members
Member | Type | Visibility | Description |
---|---|---|---|
BeginReferences | Method | public | Initializes the component referencing mechanism. |
CanHandleExceptions | Property | protected | Indicates whether the reader is handling exceptions at this stage. |
CheckValue | Method | public | Raises an exception if the next value in the stream is not of type Value |
CopyValue | Method | public | Copy a value to a writer. |
Create | Method | public | Creates a new reader class |
CreateDriver | Method | protected | |
DefineBinaryProperty | Method | public | Reads a user-defined binary property from the stream. |
DefineProperty | Method | public | Reads a user-defined property from the stream. |
Destroy | Method | public | Destroys a reader class. |
DoFixupReferences | Method | private | |
Driver | Property | public | The driver in use for streaming the data. |
EndOfList | Method | public | Returns true if the stream contains an end-of-list marker. |
EndReferences | Method | public | Finalizes the component referencing mechanism. |
Error | Method | protected | Calls an installed error handler and passes it Message |
FCanHandleExcepts | Field | private | |
FDriver | Field | private | |
FFixups | Field | private | |
FindComponentClass | Method | private | |
FindMethod | Method | protected | Return the address of a published method. |
FixupReferences | Method | public | Tries to resolve all unresolved component references. |
FLoaded | Field | private | |
FLock | Field | private | |
FlushBuffer | Method | public | Flush the buffer |
FOnAncestorNotFound | Field | private | |
FOnCreateComponent | Field | private | |
FOnError | Field | private | |
FOnFindComponentClass | Field | private | |
FOnFindMethod | Field | private | |
FOnPropertyNotFound | Field | private | |
FOnReadStringProperty | Field | private | |
FOnReferenceName | Field | private | |
FOnSetMethodProperty | Field | private | |
FOnSetName | Field | private | |
FOwner | Field | private | |
FParent | Field | private | |
FPropName | Field | private | |
Lock | Method | private | |
NextValue | Method | public | Returns the type of the next value. |
OnAncestorNotFound | Property | public | Handler called when the ancestor component cannot be found. |
OnCreateComponent | Property | public | Handler called when a component needs to be created. |
OnError | Property | public | Handler called when an error occurs. |
OnFindComponentClass | Property | public | Handler called when a component class reference needs to be found. |
OnFindMethod | Property | public | Handler to find or change a method address. |
OnPropertyNotFound | Property | public | Handler for treating missing properties. |
OnReadStringProperty | Property | public | Handler for translating strings when read from the stream. |
OnReferenceName | Property | public | Handler called when another component is referenced. |
OnSetMethodProperty | Property | public | Handler for setting method properties. |
OnSetName | Property | public | Handler called when setting a component name. |
Owner | Property | public | Owner of the component being read |
Parent | Property | public | Parent of the component being read. |
PropertyError | Method | protected | Skips a property value and raises an exception. |
PropName | Property | protected | Name of the property being read at this moment. |
Read | Method | public | Read raw data from stream |
ReadBoolean | Method | public | Reads a boolean from the stream. |
ReadChar | Method | public | Reads a character from the stream. |
ReadCollection | Method | public | Reads a collection from the stream. |
ReadComponent | Method | public | Starts reading a component from the stream. |
ReadComponents | Method | public | Starts reading child components from the stream. |
ReadCurrency | Method | public | Read a currency value from the stream. |
ReadData | Method | protected | Reads the components data after it has been created. |
ReadDate | Method | public | Reads a date from the stream |
ReadFloat | Method | public | Reads a float from the stream. |
ReadIdent | Method | public | Reads an identifier from the stream. |
ReadInt64 | Method | public | Reads a 64-bit integer from the stream. |
ReadInteger | Method | public | Reads an integer from the stream |
ReadListBegin | Method | public | Checks for the beginning of a list. |
ReadListEnd | Method | public | Checks for the end of a list. |
ReadProperty | Method | protected | Read and process a property name |
ReadPropValue | Method | protected | Reads a property value for PropInfo. |
ReadRootComponent | Method | public | Starts reading a root component. |
ReadSet | Method | public | Read a set value from the stream |
ReadSignature | Method | public | Read stream signature from the stream |
ReadSingle | Method | public | Reads a single-type real from the stream. |
ReadString | Method | public | Reads a string from the stream. |
ReadUnicodeChar | Method | public | Read Unicode character |
ReadUnicodeString | Method | public | Read a UnicodeString value from the stream |
ReadValue | Method | public | Reads the next value type from the stream. |
ReadVariant | Method | public | Read a variant from the stream |
ReadWideChar | Method | public | Read widechar from the stream |
ReadWideString | Method | public | Read a WideString value from the stream. |
Unlock | Method | private |
Inheritance
Class | Description |
---|---|
TReader | Generic reader object which reads component data from any given source. |
See also
Name | Description |
---|---|
TAbstractObjectReader | Abstract driver class to read stored component data. |
TAbstractObjectReader | Abstract driver class to read stored component data. |
TAbstractObjectReader | Abstract driver class to read stored component data. |
TAncestorNotFoundEvent | This event occurs when an ancestor component cannot be found. |
TAncestorNotFoundEvent | This event occurs when an ancestor component cannot be found. |
TComponent | Base class for all components that need owner-owned functionality. |
TComponent | Base class for all components that need owner-owned functionality. |
TComponent | Base class for all components that need owner-owned functionality. |
TComponent | Base class for all components that need owner-owned functionality. |
TCreateComponentEvent | Event handler type, occurs when a component instance must be created when a component is read from a stream. |
TCreateComponentEvent | Event handler type, occurs when a component instance must be created when a component is read from a stream. |
TFiler | Class responsible for streaming of components. |
TFindComponentClassEvent | Event handler type, occurs when a component class pointer must be found when reading a component from a stream. |
TFindComponentClassEvent | Event handler type, occurs when a component class pointer must be found when reading a component from a stream. |
TFindMethodEvent | Occurs when the streaming process needs to locate a method |
TFindMethodEvent | Occurs when the streaming process needs to locate a method |
TFPList | Class to manage collections of pointers. |
TObject | Base class of all classes. |
TPropertyNotFoundEvent | Callback for the TReader.OnPropertyNotFound event. |
TPropertyNotFoundEvent | Callback for the TReader.OnPropertyNotFound event. |
TReaderError | Event handler type, called when an error occurs during the streaming. |
TReaderError | Event handler type, called when an error occurs during the streaming. |
TReadWriteStringPropertyEvent | Callback for the TReader.OnReadStringProperty event handler |
TReadWriteStringPropertyEvent | Callback for the TReader.OnReadStringProperty event handler |
TReferenceNameEvent | Occurs when a named object needs to be looked up. |
TReferenceNameEvent | Occurs when a named object needs to be looked up. |
TRTLCRITICALSECTION | A class for managing multiple threads |
TSetMethodPropertyEvent | Callback for the TReader.OnSetMethodProperty event. |
TSetMethodPropertyEvent | Callback for the TReader.OnSetMethodProperty event. |
TSetNameEvent | Occurs when the reader needs to set a component's name. |
TSetNameEvent | Occurs when the reader needs to set a component's name. |
TWriter | Object to write component data to an arbitrary format. |