📄 nativexml.pas
字号:
procedure AttributeAdd(const AName, AValue: string); {$IFDEF D4UP}overload;{$ENDIF}
// Use this method to delete the attribute at Index in the list. Index must be
// equal or greater than 0, and smaller than AttributeCount. Using an index
// outside of that range has no effect.
procedure AttributeDelete(Index: integer);
// Switch position of the attributes at Index1 and Index2.
procedure AttributeExchange(Index1, Index2: integer);
// Use this method to find the index of an attribute with name AName.
function AttributeIndexByname(const AName: string): integer;
// \Clear all attributes from the current node.
procedure AttributesClear; virtual;
// Use this method to read binary data from the node into Buffer with a length of Count.
procedure BufferRead(var Buffer{$IFDEF CLR}: TBytes{$ENDIF}; Count: Integer); virtual;
// Use this method to write binary data in Buffer with a length of Count to the
// current node. The data will appear as text using either BinHex or Base64
// method) in the final XML document.
// Notice that XmlDocument does only support up to 2Gb bytes of data per file,
// so do not use this option for huge files. The binary encoding method (converting
// binary data into text) can be selected using property BinaryEncoding.
// xbeBase64 is most efficient, but slightly slower. Always use identical methods
// for reading and writing.
procedure BufferWrite(const Buffer{$IFDEF CLR}: TBytes{$ENDIF}; Count: Integer); virtual;
// Returns the length of the data in the buffer, once it would be decoded by
// method xbeBinHex or xbeBase64. If BinaryEncoding is xbeSixBits, this function
// cannot be used. The length of the unencoded data is determined from the
// length of the encoded data. For xbeBinHex this is trivial (just half the
// length), for xbeBase64 this is more difficult (must use the padding characters)
function BufferLength: integer; virtual;
// Clear all child nodes and attributes, and the name and value of the current
// XML node. However, the node is not deleted. Call Delete instead for that.
procedure Clear; virtual;
// Find the first node which has name NodeName. Contrary to the NodeByName
// function, this function will search the whole subnode tree, using the
// DepthFirst method. It is possible to search for a full path too, e.g.
// FoundNode := MyNode.FindNode('/Root/SubNode1/SubNode2/ThisNode');
function FindNode(const NodeName: string): TXmlNode;
// Find all nodes which have name NodeName. Contrary to the NodesByName
// function, this function will search the whole subnode tree. If you use
// a TXmlNodeLIst for the AList parameter, you don't need to cast the list
// items to TXmlNode.
procedure FindNodes(const NodeName: string; const AList: TList);
// Use FromAnsiString to convert a normal ANSI string to a string for the node
// (name, value, attributes). If the TNativeXml property UtfEncoded is True,
// the ANSI characters are encoded into UTF8. Use this function if you work
// with special codebases (characters in the range $7F-$FF) and want to produce
// unicode or UTF8 XML documents.
function FromAnsiString(const s: string): string;
// Use FromWidestring to convert widestring to a string for the node (name, value,
// attributes). If the TNativeXml property UtfEncoded is True, all
// character codes higher than $FF are preserved.
function FromWidestring(const W: widestring): string;
// Use HasAttribute to determine if the node has an attribute with name AName.
function HasAttribute(const AName: string): boolean; virtual;
// This function returns the index of this node in the parent's node list.
// If Parent is not assigned, this function returns -1.
function IndexInParent: integer;
// This function returns True if the node has no subnodes and no attributes,
// and if the node Name and value are empty.
function IsClear: boolean; virtual;
// This function returns True if the node has no subnodes and no attributes,
// and if the node value is empty.
function IsEmpty: boolean; virtual;
function IsEqualTo(ANode: TXmlNode; Options: TXmlCompareOptions; MismatchNodes: TList {$IFDEF D4UP}= nil{$ENDIF}): boolean;
// Add the node ANode as a new subelement in the nodelist. The node will be
// added in position NodeCount (which will be returned).
function NodeAdd(ANode: TXmlNode): integer; virtual;
// This function returns a pointer to the first subnode that has an attribute with
// name AttribName and value AttribValue. If ShouldRecurse = True (default), the
// function works recursively, using the depthfirst method.
function NodeByAttributeValue(const NodeName, AttribName, AttribValue: string;
ShouldRecurse: boolean {$IFDEF D4UP}= True{$ENDIF}): TXmlNode;
// Return a pointer to the first subnode with this Elementype, or return nil
// if no subnode with that type is found.
function NodeByElementType(ElementType: TXmlElementType): TXmlNode;
// Return a pointer to the first subnode in the nodelist that has name AName.
// If no subnodes with AName are found, the function returns nil.
function NodeByName(const AName: string): TXmlNode; virtual;
// \Delete the subnode at Index. The node will also be freed, so do not free the
// node in the application.
procedure NodeDelete(Index: integer); virtual;
// Switch position of the nodes at Index1 and Index2.
procedure NodeExchange(Index1, Index2: integer);
// Extract the node ANode from the subnode list. The node will no longer appear
// in the subnodes list, so the application is responsible for freeing ANode later.
function NodeExtract(ANode: TXmlNode): TXmlNode; virtual;
// This function returns a pointer to the first node with AName. If this node
// is not found, then it creates a new node with AName and returns its pointer.
function NodeFindOrCreate(const AName: string): TXmlNode; virtual;
// Find the index of the first subnode with name AName.
function NodeIndexByName(const AName: string): integer; virtual;
// Find the index of the first subnode with name AName that appears after or on
// the index AFrom. This function can be used in a loop to retrieve all nodes
// with a certain name, without using a helper list. See also NodesByName.
function NodeIndexByNameFrom(const AName: string; AFrom: integer): integer; virtual;
// Call NodeIndexOf to get the index for ANode in the Nodes array. The first
// node in the array has index 0, the second item has index 1, and so on. If
// a node is not in the list, NodeIndexOf returns -1.
function NodeIndexOf(ANode: TXmlNode): integer;
// Insert the node ANode at location Index in the list.
procedure NodeInsert(Index: integer; ANode: TXmlNode); virtual;
// \Create a new node with AName, add it to the subnode list, and return a
// pointer to it.
function NodeNew(const AName: string): TXmlNode; virtual;
// \Create a new node with AName, and insert it into the subnode list at location
// Index, and return a pointer to it.
function NodeNewAtIndex(Index: integer; const AName: string): TXmlNode; virtual;
// Call NodeRemove to remove a specific node from the Nodes array when its index
// is unknown. The value returned is the index of the item in the Nodes array
// before it was removed. After an item is removed, all the items that follow
// it are moved up in index position and the NodeCount is reduced by one.
function NodeRemove(ANode: TxmlNode): integer;
// \Clear (and free) the complete list of subnodes.
procedure NodesClear; virtual;
// Use this procedure to retrieve all nodes that have name AName. Pointers to
// these nodes are added to the list in AList. AList must be initialized
// before calling this procedure. If you use a TXmlNodeList you don't need
// to cast the list items to TXmlNode.
procedure NodesByName(const AName: string; const AList: TList);
// Find the attribute with AName, and convert its value to an integer. If the
// attribute is not found, or cannot be converted, the default ADefault will
// be returned.
function ReadAttributeInteger(const AName: string; ADefault: integer {$IFDEF D4UP}= 0{$ENDIF}): integer; virtual;
function ReadAttributeString(const AName: string; const ADefault: string {$IFDEF D4UP}= ''{$ENDIF}): string; virtual;
// Read the subnode with AName and convert it to a boolean value. If the
// subnode is not found, or cannot be converted, the boolean ADefault will
// be returned.
function ReadBool(const AName: string; ADefault: boolean {$IFDEF D4UP}= False{$ENDIF}): boolean; virtual;
{$IFDEF USEGRAPHICS}
// Read the properties Color and Style for the TBrush object ABrush from the
// subnode with AName.
procedure ReadBrush(const AName: string; ABrush: TBrush); virtual;
// Read the subnode with AName and convert its value to TColor. If the
// subnode is not found, or cannot be converted, ADefault will be returned.
function ReadColor(const AName: string; ADefault: TColor {$IFDEF D4UP}= clBlack{$ENDIF}): TColor; virtual;
// Read the properties \Name, Color, Size and Style for the TFont object AFont
// from the subnode with AName.
procedure ReadFont(const AName: string; AFont: TFont); virtual;
// Read the properties Color, Mode, Style and Width for the TPen object APen
// from the subnode with AName.
procedure ReadPen(const AName: string; APen: TPen); virtual;
{$ENDIF}
// Read the subnode with AName and convert its value to TDateTime. If the
// subnode is not found, or cannot be converted, ADefault will be returned.
function ReadDateTime(const AName: string; ADefault: TDateTime {$IFDEF D4UP}= 0{$ENDIF}): TDateTime; virtual;
// Read the subnode with AName and convert its value to a double. If the
// subnode is not found, or cannot be converted, ADefault will be returned.
function ReadFloat(const AName: string; ADefault: double {$IFDEF D4UP}= 0.0{$ENDIF}): double; virtual;
{$IFDEF D4UP}
// Read the subnode with AName and convert its value to an int64. If the
// subnode is not found, or cannot be converted, ADefault will be returned.
function ReadInt64(const AName: string; ADefault: int64 {$IFDEF D4UP}= 0{$ENDIF}): int64; virtual;
{$ENDIF}
// Read the subnode with AName and convert its value to an integer. If the
// subnode is not found, or cannot be converted, ADefault will be returned.
function ReadInteger(const AName: string; ADefault: integer {$IFDEF D4UP}= 0{$ENDIF}): integer; virtual;
// Read the subnode with AName and return its string value. If the subnode is
// not found, ADefault will be returned.
function ReadString(const AName: string; const ADefault: string {$IFDEF D4UP}= ''{$ENDIF}): string; virtual;
// Read the subnode with AName and return its widestring value. If the subnode is
// not found, ADefault will be returned.
function ReadWidestring(const AName: string; const ADefault: widestring {$IFDEF D4UP}= ''{$ENDIF}): widestring; virtual;
// Sort the child nodes of this node. Provide a custom node compare function in Compare,
// or attach an event handler to the parent documents' OnNodeCompare in order to
// provide custom sorting. If no compare function is given (nil) and OnNodeCompare
// is not implemented, SortChildNodes will simply sort the nodes by name (ascending,
// case insensitive). The Info pointer parameter can be used to pass any custom
// information to the compare function. Default value for Info is nil.
procedure SortChildNodes(Compare: TXMLNodeCompareFunction {$IFDEF D4UP}= nil{$ENDIF}; Info: TPointer {$IFDEF D4UP}= nil{$ENDIF});
// Use ToAnsiString to convert any string from the node (name, value, attributes)
// to a normal ANSI string. If the TNativeXml property UtfEncoded is True,
// you may loose characters with codes higher than $FF. To prevent this, use
// widestrings in your application and use ToWidestring instead.
function ToAnsiString(const s: string): string;
// Use ToWidestring to convert any string from the node (name, value, attributes)
// to a widestring. If the TNativeXml property UtfEncoded is True, all
// character codes higher than $FF are preserved.
function ToWidestring(const s: string): widestring;
// Convert the node's value to boolean and return the result. If this conversion
// fails, or no value is found, then the function returns ADefault.
function ValueAsBoolDef(ADefault: boolean): boolean; virtual;
// Convert the node's value to a TDateTime and return the result. If this conversion
// fails, or no value is found, then the function returns ADefault.
function ValueAsDateTimeDef(ADefault: TDateTime): TDateTime; virtual;
// Convert the node's value to a double and return the result. If this conversion
// fails, or no value is found, then the function returns ADefault.
function ValueAsFloatDef(ADefault: double): double; virtual;
{$IFDEF D4UP}
// Convert the node's value to int64 and return the result. If this conversion
// fails, or no value is found, then the function returns ADefault.
function ValueAsInt64Def(ADefault: int64): int64; virtual;
{$ENDIF}
// Convert the node's value to integer and return the result. If this conversion
// fails, or no value is found, then the function returns ADefault.
function ValueAsIntegerDef(ADefault: integer): integer; virtual;
// If the attribute with name AName exists, then set its value to the integer
// AValue. If it does not exist, then create a new attribute AName with the
// integer value converted to a quoted string. If ADefault = AValue, and
// WriteOnDefault = False, no attribute will be added.
procedure WriteAttributeInteger(const AName: string; AValue: integer; ADefault: integer {$IFDEF D4UP}= 0{$ENDIF}); virtual;
// If the attribute with name AName exists, then set its value to the string
// AValue. If it does not exist, then create a new attribute AName with the
// value AValue. If ADefault = AValue, and WriteOnDefault = False, no attribute
// will be added.
procedure WriteAttributeString(const AName: string; const AValue: string; const ADefault: string {$IFDEF D4UP}= ''{$ENDIF}); virtual;
// Add or replace the subnode with AName and set its value to represent the boolean
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteBool(const AName: string; AValue: boolean; ADefault: boolean {$IFDEF D4UP}= False{$ENDIF}); virtual;
{$IFDEF USEGRAPHICS}
// Write properties Color and Style of the TBrush object ABrush to the subnode
// with AName. If AName does not exist, it will be created.
procedure WriteBrush(const AName: string; ABrush: TBrush); virtual;
// Add or replace the subnode with AName and set its value to represent the TColor
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteColor(const AName: string; AValue: TColor; ADefault: TColor {$IFDEF D4UP}= clBlack{$ENDIF}); virtual;
// Write properties \Name, Color, Size and Style of the TFont object AFont to
// the subnode with AName. If AName does not exist, it will be created.
procedure WriteFont(const AName: string; AFont: TFont); virtual;
// Write properties Color, Mode, Style and Width of the TPen object APen to
// the subnode with AName. If AName does not exist, it will be created.
procedure WritePen(const AName: string; APen: TPen); virtual;
{$ENDIF}
// Add or replace the subnode with AName and set its value to represent the TDateTime
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
// The XML format used is compliant with W3C's specification of date and time.
procedure WriteDateTime(const AName: string; AValue: TDateTime; ADefault: TDateTime {$IFDEF D4UP}= 0{$ENDIF}); virtual;
// Add or replace the subnode with AName and set its value to represent the double
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteFloat(const AName: string; AValue: double; ADefault: double {$IFDEF D4UP}= 0.0{$ENDIF}); virtual;
// Add or replace the subnode with AName and set its value to represent the hexadecimal representation of
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteHex(const AName: string; AValue: integer; Digits: integer; ADefault: integer {$IFDEF D4UP}= 0{$ENDIF}); virtual;
{$IFDEF D4UP}
// Add or replace the subnode with AName and set its value to represent the int64
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteInt64(const AName: string; AValue: int64; ADefault: int64 {$IFDEF D4UP}= 0{$ENDIF}); virtual;
{$ENDIF}
// Add or replace the subnode with AName and set its value to represent the integer
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteInteger(const AName: string; AValue: integer; ADefault: integer {$IFDEF D4UP}= 0{$ENDIF}); virtual;
// Add or replace the subnode with AName and set its value to represent the string
// AValue. If AValue = ADefault, and WriteOnDefault = False, no subnode will be added.
procedure WriteString(const AName, AValue: string; const ADefault: string {$IFDEF D4UP}= ''{$ENDIF}); virtual;
// Call WriteToString to save the XML node to a string. This method can be used to store
// individual nodes instead of the complete XML document.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -