Skip to content

TStringStream

Stream that stores its data in a string.

Declaration

Source position: classesh.inc line 1664

type

  TStringStream = class(TBytesStream)
  public
    constructor Create(const ABytes: TBytes); overload;
    constructor Create; overload;
    constructor Create(const AString: AnsiString); overload;
    constructor Create(const AString: Ansistring; AEncoding: TEncoding; 
                  AOwnsEncoding: Boolean=True); overload;
    constructor Create(const AString: Ansistring; ACodePage: Integer); overload;
    constructor Create(const AString: UnicodeString); overload;
    constructor Create(const AString: UnicodeString; AEncoding: TEncoding; 
                  AOwnsEncoding: Boolean=True); overload;
    constructor Create(const AString: UnicodeString; ACodePage: Integer); overload;
    constructor CreateRaw; overload;
    destructor Destroy;
    function ReadUnicodeString : UnicodeString;
    procedure WriteUnicodeString;
    function ReadAnsiString : AnsiString; overload;
    procedure WriteAnsiString;
    function ReadString : string;
    procedure WriteString;
    property DataString: RTLString; {r}
    property AnsiDataString: AnsiString; {r}
    property UnicodeDataString: UnicodeString; {r}
    property OwnsEncoding: Boolean; {r}
    property Encoding: TEncoding; {r}
  end;

Description

TStringStream stores its data in an ansistring. The contents of this string is available as the DataString property. It also introduces some methods to read or write parts of the stringstream's data as a string.

The main purpose of a TStringSTream is to be able to treat a string as a stream from which can be read.

Properties

Member Visibility Description
AnsiDataString read only public
DataString read only public Contains the contents of the stream in string form.
Encoding read only public Encoding of the string with the data.
OwnsEncoding read only public Does the stream instance owns the encoding.
UnicodeDataString read only public Datastring as unicode string.
See all Properties

Methods

Member Visibility Description
Create public Creates a new stringstream and sets its initial content.
CreateRaw public Create stringstream using codepage of string.
Destroy public Free the instance of the stream.
ReadAnsiString public Read an ansistring from the stream.
ReadString public Reads a string of length Count.
ReadUnicodeString public Read a unicode string from the stream.
WriteAnsiString public Write an ansistring to the stream.
WriteString public WriteString writes a string to the stream.
WriteUnicodeString public Write a unicode string to the stream.
See all Methods

See also

Name Description
TStream Base class for streams.
TStringStream.DataString Contains the contents of the stream in string form.
TStringStream.ReadString Reads a string of length Count.
TStringStream.WriteString WriteString writes a string to the stream.