Contains classes, types, and routines used to implement an XML serialization driver.

Copyright (c) 2000 by Sebastian Guenther, sg@freepascal.org

Extended by Mattias Gaertner:

  • Reading/Writing children, all kinds of properties,
  • Custom properties (via DefineProperties).

This file is part of the LazUtils package.

Represents element types used in stack elements for an XML object writer. Element is an unknown type. Element represents a property in a list of properties. Element represents a child component in a list of child components. Represents a stack element for an XML object writer.

TXMLObjectWriterStackEl is a class used to represent an element pushed onto the stack for an XML object writer. Members in the class instance contain the TDOMElement instances for the stack element and its Parent, the stack element type, an inner list of stack elements which it contains, and the name of the property represented in the class instance.

TXMLObjectWriterStackEl is used in the implementation of the TXMLObjectWriter class to represent the current element being processed in the XML object writer.

DOM Element which represents the component or property in the stack element.

Element is a TDOMElement member used to store the values from the property or component represented in the stack element. Element is created and populated when TXMLObjectWriter processes properties, components, collections, and lists in the class instance.

Use PropertyName to get the name of the property represented in the stack element.

Use ElemType to determine whether the stack element represents a property list, child component list, or other type.

Use Parent to access the TDOMElement which is the parent for the current stack element.

TDOMElement
Contains the TDOMElement that is the parent node for the stack element. Indicates the element type for the stack element. Name of the property represented in the stack element. Serializes an object instance using an XML storage format.

TXMLObjectWriter is a TAbstractObjectWriter descendant which implements an object serialization writer using XML as the storage format. TXMLObjectWriter implements abstract methods defined in the ancestor class, and provides access to the DOM document and the DOM Node tree used to store values generated in the class instance. It maintains an internal stack used to capture and process the hierarchical node tree needed to represent a class instance.

TAbstractObjectWriter
Gets a TDOMElement used to serialize the specified type name. Name for the type represented in the property element. Constructor for the class instance.

Create is the constructor for the class instance. It provides arguments which identify the XML document where the XML content is stored, an optional path to a node in the document where the content is stored, and a flag to indicate the content is appended to or replaces the content for the root node in the document.

TDomDocument instance where the XML content is stored. Path expression to the node where the XML content is stored. True to append the content to the root node in the document, False to replace it. Starts serialization of a Collection using the XML format for the writer. Starts serialization of a Component using the XML format for object writer. The component instance written in the method. Not used in the current LCL implementation. Not used in the current LCL implementation. Starts serialization of a list using the XML format for the writer. Finishes serialization of a list using the XML format for the writer. Starts serialization for a property using the XML format for the object writer. Name for the property used as the value for the name attribute in the element. Ends serialization for a property using the XML format for the writer. Serializes a binary value from the specified buffer. Serializes a Boolean value using the XML format for the writer. Boolean value written in the method. Serializes a floating point value using the XML format for the writer. Floating point value written in the method. Serializes a Single value using the XML format for the writer. Single value written in the method. Serializes a Currency value using the XML format for the writer. Currency value written in the method. Serializes a TDateTime value using the XML format for the writer. TDateTime value written in the method. Serializes an Identifier using the XML format for the writer. String with the identifier written in the method. Serializes an Integer value using the XML format for the object writer. Integer value written in the method. Serializes the specified method name using the XML format for the object writer. Method name written in the method. Serializes a set values from the specified type using the XML format for the object writer. LongInt with the bit values for the set type. Pointer to the type for the set. Serializes a string value using the XML format for the object writer. String value written in the method. Serializes a wide string value using the XML format for the object writer. WideString value written in the method. Not needed for the XML format used in TXMLObjectWriter.

Contains an empty implementation in TXMLObjectWriter.

Serializes an Int64 value using the XML format for the object writer.

Included when USE_NEW_READER_WRITER has been defined in the LCL.

Serializes an UnicodeString value using the XML format for the object writer.

Included when USE_NEW_READER_WRITER has been defined in the LCL.

Serializes a Variant value using the XML format for the object writer.

Included when USE_NEW_READER_WRITER has been defined in the LCL.

Raises an exception in the current LCL version.

Raises an Exception when HasReadWriteBuf has been defined in the LCL.

TDOMDocument used to create and store elements in the XML object writer.

Doc is a read-only TDOMDocument property which contains the DOM document used to create and store the DOM elements written in XML object writer. The value in Doc is assigned in the Create constructor, and uses the TDOMDocument instance passed as an argument to the constructor.

Class type used to create new instances of the XML object writer. De-serializes an object instance from its XML storage format. TAbstractObjectReader Constructor for the class instance.

Create is the constructor for the object instance. It uses values passed in the ADoc and APath arguments to access the DOM document and node(s) where the XML content for the object reader is stored.

ADoc is assigned to the Doc property in the class instance, and its DocumentElement is used to access nodes in the DOM tree.

APath contains an expression used to locate the DOM node with the content for the object reader. It provides the hierarchy of DOM nodes used to access the XML content for the class instance.

Create raises an Exception in the constructor if a node cannot be located using the path in APath, or when the node is not a valid TDOMElement instance. Use exception handling when calling the method.
TDOMNode TDOMElement TDOMDocument
TDOMDocument instance with the values read in the object reader. Path to the node in ADoc where the object instance is stored. Destructor for the class instance.

Calls the inherited destructor on entry.

Gets the class name from the node which is the root element for the object instance.

GetRootClassName raises an Exception if a component node cannot be located in the root element, or the node is not a valid TDOMElement instance.

Value from the class attribute in the element. Not used in the current LCL implementation. Reads the value type for the next element in the XML DOM tree. TValueType Reads the value for the next element in the XML DOM tree after the value type has been read. Locates the DOM node for the component in the document element.

Raises an Exception if Element has not been assigned, or a node using a "component" tag is not found in the Element.

Gets the DOM element for the component, gets the class type and component name, and sets Element to the properties node. Reads the property name from Element and prepares for the property value(s). Name for the property read from the XML content in the Element. Reads a binary value from Element and stores it in the specified stream. TMemoryStream instance where the binary value is stored. Reads a string value from Element and converts it to a floating point value. Floating point value converted in the method, or 0 as the default. Converts a string value in Element to a Single data type. Single value converted in the method, or 0 as the default. Converts a string value in Element to a Currency data type. Currency value converted in the method, or 0 as the default. Reads a TDateTime value from Element. Reads an Identifier from Element. Reads a ShortInt value from Element. Reads a SmallInt value from Element. Reads a LongInt value from Element. Reads an Int64 type from Element. Reads values for a set type from Element. Reads a String value from Element. Reads a string value from Element. Why the exception when the string has more than 255 characters? Reads a WideString value from Element.

Converts the UTF-8-encoded content in Element to the WideString type used in the return value.

Not implemented and not needed in TXMLObjectReader. Reads a UnicodeString value from Element.

Converts the UTF-8-encoded value in Element to the UnicodeString type used in the return value.

UnicodeString value read in the method. Positions the reader to the next sibling DOM node in Element. Reads and discards the value in Element. Raises an exception in the current LCL implementation. TDomDocument instance with the XML content read in the object reader. Contains the DOM element currently being processed in the XML object reader. Indicates whether the object reader is processing an element name or its value.

0 indicates that the element name is being processed. 1 indicates that the name processing has been completed, and the value(s) in the element are being processed.

Class type used to create new instances of the XML object reader. Serializes the specified component to a stream using an XML object writer. Component with values written to the stream. TStream instance where the XML content is stored.