TStringStream

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Stream that stores its data in a string.

Declaration

Source position: classesh.inc line 1243

Type
  TStringStream = class (TBytesStream)
  private
    FEncoding : TEncoding;
    FOwnsEncoding : Boolean;
    function GetDataString : string;
    function GetUnicodeDataString : UnicodeString;
  public
    constructor Create(const ABytes: TBytes);  Override;  Overload;
    constructor Create(const AString: string);  Overload;
    constructor Create(const AString: string; AEncoding: TEncoding; 
                      AOwnsEncoding: Boolean);  Overload;
    constructor Create(const AString: string; ACodePage: Integer);  Overload;
    constructor Create(const AString: UnicodeString);  Overload;
    constructor Create(const AString: UnicodeString; AEncoding: TEncoding; 
                      AOwnsEncoding: Boolean);  Overload;
    constructor Create(const AString: UnicodeString; ACodePage: Integer)
                      ;  Overload;
    constructor CreateRaw(const AString: RawByteString);  Overload;
    destructor Destroy;  Override;
    function ReadUnicodeString(Count: LongInt) : UnicodeString;
    procedure WriteUnicodeString(const AString: UnicodeString);
    function ReadAnsiString(Count: LongInt) : AnsiString;  Overload;
    procedure WriteAnsiString(const AString: AnsiString);  Override;
    function ReadString(Count: LongInt) : string;
    procedure WriteString(const AString: string);
    DataString : string;
    UnicodeDataString : UnicodeString;
    OwnsEncoding : Boolean;
    Encoding : TEncoding;
  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.

Members

Member Type Visibility Description
Create Method public Creates a new stringstream and sets its initial content.
CreateRaw Method public Create stringstream using codepage of string
DataString Property public Contains the contents of the stream in string form
Destroy Method public Free the instance of the stream
Encoding Property public Encoding of the string with the data
FEncoding Field private
FOwnsEncoding Field private
GetDataString Method private
GetUnicodeDataString Method private
OwnsEncoding Property public Does the stream instance owns the encoding
ReadAnsiString Method public Read an ansistring from the stream
ReadString Method public Reads a string of length Count
ReadUnicodeString Method public Read a unicode string from the stream
UnicodeDataString Property public Datastring as unicode string
WriteAnsiString Method public Write an ansistring to the stream
WriteString Method public WriteString writes a string to the stream.
WriteUnicodeString Method public Write a unicode string to the stream

Inheritance

Class Description
TStringStream Stream that stores its data in a string.

See also

Name Description
TEncoding
TEncoding
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.
UnicodeString A string consisting of widechars.