Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | enhanced doc about ReadStringFromStream() |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
518822d71669ac6620b61b677b653c61 |
User & Date: | User 2014-05-26 07:00:53 |
2014-05-26
| ||
07:47 | introduced StrLenPas() function, to be used when buffer is protected and SSE2 StrLen() function may raise an error by reading some chars after the buffer itself (it won't occur with normal stack-allocated or GetMem-allocated buffers, but may happen e.g. when working on memory mapped files) check-in: 10aaa3da08 user: User tags: trunk | |
07:00 | enhanced doc about ReadStringFromStream() check-in: 518822d716 user: User tags: trunk | |
06:54 | added Project04ServerRegister.dpr program, to make clear how to register an URI for http.sys at installation: it is not mandatory at all (and even not a good idea) to run the server instance with administrator rights! check-in: 67a189846a user: User tags: trunk | |
Changes to SQLite3/Samples/04 - HTTP Client-Server/Project04ServerRegister.dpr.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
under Vista or Seven, call first this program with Administrator rights
- you can unregister it later with command line parameter /delete }
program Project04ServerRegister;
{$APPTYPE CONSOLE}
uses
SynCommons,
SynCrtSock,
SysUtils;
const
REGSTR: array[boolean] of string = (
'Registration', 'Deletion');
|
< |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
under Vista or Seven, call first this program with Administrator rights - you can unregister it later with command line parameter /delete } program Project04ServerRegister; {$APPTYPE CONSOLE} uses SynCrtSock, SysUtils; const REGSTR: array[boolean] of string = ( 'Registration', 'Deletion'); |
Changes to SynCommons.pas.
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 ..... 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 ..... 35055 35056 35057 35058 35059 35060 35061 35062 35063 35064 35065 35066 35067 35068 35069 |
// case, the current string code page is used (i.e. CurrentAnsiConvert class) function AnyTextFileToSynUnicode(const FileName: TFileName; ForceUTF8: boolean=false): SynUnicode; /// read an UTF-8 text from a TStream // - format is Length(Integer):Text, i.e. the one used by WriteStringToStream // - will return '' if there is no such text in the stream // - you can set a MaxAllowedSize value, if you know how long the size should be function ReadStringFromStream(S: TStream; MaxAllowedSize: integer=255): RawUTF8; /// write an UTF-8 text into a TStream // - format is Length(Integer):Text, i.e. the one used by ReadStringFromStream procedure WriteStringToStream(S: TStream; const Text: RawUTF8); /// get the file date and time ................................................................................ if Stream.InheritsFrom(TCustomMemoryStream) then begin Posi := MemStream.Seek(0,soFromCurrent); PosiEnd := Posi+SaveToLength; if PosiEnd>MemStream.Size then MemStream.Size := PosiEnd; if SaveTo(PAnsiChar(MemStream.Memory)+Posi)-MemStream.Memory<>PosiEnd then EStreamError.Create('TDynArray.SaveToStream'); MemStream.Seek(PosiEnd,soFromBeginning); end else begin tmp := SaveTo; Stream.Write(pointer(tmp)^,length(tmp)); end; end; procedure TDynArray.LoadFromStream(Stream: TCustomMemoryStream); ................................................................................ fTotalWritten := 0; end; procedure TFileBufferWriter.CancelAll; begin fTotalWritten := 0; fPos := 0; fStream.Seek(0,soFromBeginning); end; procedure TFileBufferWriter.Write(Data: pointer; DataLen: integer); begin if (DataLen<=0) or (Data=nil) then exit; if fPos+DataLen>fBufLen then begin |
> > > > > | | |
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 ..... 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 28293 28294 28295 28296 28297 ..... 35060 35061 35062 35063 35064 35065 35066 35067 35068 35069 35070 35071 35072 35073 35074 |
// case, the current string code page is used (i.e. CurrentAnsiConvert class) function AnyTextFileToSynUnicode(const FileName: TFileName; ForceUTF8: boolean=false): SynUnicode; /// read an UTF-8 text from a TStream // - format is Length(Integer):Text, i.e. the one used by WriteStringToStream // - will return '' if there is no such text in the stream // - you can set a MaxAllowedSize value, if you know how long the size should be // - it will read from the current position in S: so if you just write into S, // it could be a good idea to rewind it before call, e.g.: // ! Report.SaveToStream(Stream); // ! Stream.Seek(0,soBeginning); // ! str := ReadStringFromStream(Stream); function ReadStringFromStream(S: TStream; MaxAllowedSize: integer=255): RawUTF8; /// write an UTF-8 text into a TStream // - format is Length(Integer):Text, i.e. the one used by ReadStringFromStream procedure WriteStringToStream(S: TStream; const Text: RawUTF8); /// get the file date and time ................................................................................ if Stream.InheritsFrom(TCustomMemoryStream) then begin Posi := MemStream.Seek(0,soFromCurrent); PosiEnd := Posi+SaveToLength; if PosiEnd>MemStream.Size then MemStream.Size := PosiEnd; if SaveTo(PAnsiChar(MemStream.Memory)+Posi)-MemStream.Memory<>PosiEnd then EStreamError.Create('TDynArray.SaveToStream'); MemStream.Seek(PosiEnd,soBeginning); end else begin tmp := SaveTo; Stream.Write(pointer(tmp)^,length(tmp)); end; end; procedure TDynArray.LoadFromStream(Stream: TCustomMemoryStream); ................................................................................ fTotalWritten := 0; end; procedure TFileBufferWriter.CancelAll; begin fTotalWritten := 0; fPos := 0; fStream.Seek(0,soBeginning); end; procedure TFileBufferWriter.Write(Data: pointer; DataLen: integer); begin if (DataLen<=0) or (Data=nil) then exit; if fPos+DataLen>fBufLen then begin |