Recent

Author Topic: IStreams  (Read 3277 times)

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
IStreams
« on: July 21, 2025, 05:29:06 pm »
Hi
<Current version: 0.09.02.2026>
· Implemented the missing bits to make it compile with FPC 3.2.2
· Did some more backporting

Right... So I've been fiddling a bit with "Interfacifying Streams;D
This unit now compiles and works fine, even if I had a few conundrums on the way, specifically with inheritance, so the unit structure is not as clean as I would've liked it...  :P (The joke is on me, I had to write some more, even duplicate code...arghh).
Anyway, I need your help to test it all, 'cause that's way more than one guy/gal can do, so please go and get it while it's hot, it's right HERE at my GitLab crib...
Regards Benny
« Last Edit: February 09, 2026, 02:16:04 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: IStreams
« Reply #1 on: July 21, 2025, 06:19:14 pm »
Just reading the code now, but, Benny, really?:
Code: Pascal  [Select][+][-]
  1. {$ifNdef VER3_2_2}
Which versions, before or after,  do you mean? Always compare to the version you require with:
Code: Pascal  [Select][+][-]
  1. {$if fpc_fullversion < 30202}//do older stuff}{$ifend}
  2. //OR
  3. {$if fpc_fullversion >= 30202}// do newer stuff, including 3.2.2{$ifend}
  4. //OR
  5. {$if fpc_fullversion > 30202// etc.{$ifend}
It is very rare that a capability is tied to a specific version (none that I know of) so fix that first.
Luckily for you that's a search and replace.
And don't use VER3_2_2 in serious code at all unless you want to support versions before 2.4.0.

The format for fpc_fullversion is: two digit major release, two digit minor release, 1 digit revision.
Except for Major, uneven means that is is a version and not a release. In the case of revision uneven means fixes and as such the minor release will be even unless it is trunk /main and also indicates it is not a release.

Regards,

Thaddy

p.s. compilation and evaluation comes later.

You deserve some punishment with a french loaf...
https://da.frwiki.wiki/wiki/Ast%C3%A9rix_chez_les_Helv%C3%A8tes
Look for the cheese fondue orgie.
« Last Edit: July 21, 2025, 06:45:17 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #2 on: July 21, 2025, 08:02:17 pm »
Hi Thaddy
Tihi LMAO  ;D :D That was some kind of reference \o/\ö/\o/ Quite enjoyed that.
So, I fixed the directives, they were a leftover from last year when I started out with streams -> interfaces, Thanks for the tip mate.
While I was at it I moved the class-definitions to the interface section, that improves the "AS & IS" operation a bit -- I know strictly speaking they should be hidden, forcing people to __only__ use the interfaces, but hey, if it makes life easier...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1342
  • Professional amateur ;-P
Re: IStreams
« Reply #3 on: July 21, 2025, 09:18:28 pm »
Hey Benny,

Dumb question: Why getters and setters and not properties with said getters and setters as private functions?

I understand the use of getters and setters in a non Object Pascal context, since in some of the languages that can't do getters/setters for properties, one kinda has to manage it that way.
But, in Object Pascal, that is possible and, at least in my opinion, rather encouraged.

Like I said, dumb question, but I would still like your opinion or your reasoning for doing so.

Have not fully grokked the code, so I have nothing else to add at the moment.

Cheers,
Gus

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #4 on: July 21, 2025, 10:00:02 pm »
Hi Gus
Quote
Why getters and setters and not properties with said getters and setters as private functions?
First off, everything is public in an Interface, second, there cannot be any data-fields in an Interface, that means one cannot do:
Code: Pascal  [Select][+][-]
  1.   private //<--- NONO
  2.     fPosition: ptrint; //<--- NONO
  3.   public //<--- NONO
  4.     ...
  5.     { below, you can't reference the 'fPosition' data-field! }
  6.     property Position: ptrint read fPosition write fPosition;
  7.   end;
Thus one has to write getters and setters, if one supports interfaces and properties.
Third, if you look closer, you'll see I've tried to stay as close to the original definition, as possible and where I've added getters & setters, I've done so with a distinct naming scheme...
The original developers, shure knew some nifty tricks and I did what I had to, to "Interfacify" them tricks  :D
I hope this answers your question?
Regards Benny
« Last Edit: July 22, 2025, 04:02:45 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1342
  • Professional amateur ;-P
Re: IStreams
« Reply #5 on: July 22, 2025, 03:33:36 pm »
Hey Benny,

I hope this answers your question?

It absolutely does!! Many thanks for it !!

Cheers,
Gus

n7800

  • Hero Member
  • *****
  • Posts: 641
  • Lazarus IDE contributor
    • GitLab profile
Re: IStreams
« Reply #6 on: July 23, 2025, 11:22:52 pm »
The format for fpc_fullversion is: two digit major release, two digit minor release, 1 digit revision.

No, the rightmost two digits are the revision, then the two minor digits, and all that's left is the major (mask "MNNRR").

I remember seeing this somewhere, but neither the wiki nor the documentation described it in detail, so I had to look for the FPC sources:

Code: Pascal  [Select][+][-]
  1. set_system_macro('FPC_FULLVERSION',Format('%d%.02d%.02d',[StrToInt(version_nr),StrToInt(release_nr),StrToInt(patch_nr)]));
  2.  

I must have thought of the Lazarus version, which is formed similarly:

Code: Pascal  [Select][+][-]
  1. laz_fullversion = ((laz_major *  100 + laz_minor) * 100 + laz_release) * 100 + laz_patch;
  2.  

So when FPC version 23.8.2 is released (probably in the 23rd century :D), the number will look like: 230802 (mask "MMNNRR"), and so on. That is, the major digit is not limited, and can grow "to the left".

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #7 on: July 24, 2025, 12:22:27 am »
Hi
@n7800: Thanks mate, that's good & useful to know  :)
TBH, I've never been that sharp, with regards to compiler directives, but thankfully I've got Thaddy and now you to tip me in the right direction  :-X
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #8 on: August 27, 2025, 11:39:44 am »
Hi
Today I've made a small update to 'istreams.pas', namely corrected the compiler defines to cater for the upcoming FPC 3.2.4 /fixes/
Small update, therefore only a bumb in the date-part of the version number.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #9 on: January 28, 2026, 08:07:35 pm »
Hellloooo.... ;D
I've added a small feature / property to 'istreams.pas', from the changelog:
Quote
28.01.2026 Implemented 'IStreamFP.AsBytes', so now all the IStreams has it :o)
           (needed it for interfacing with blob-fields in databases, nifty )
In the hope, it can be useful to someone =^
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #10 on: January 29, 2026, 11:09:37 am »
Hi
Sorry guys, yesterday I totally forgot the bits that makes it compile with FPC 3.2.2  -- Today I got that sorted  :-X
Right  ...Get it while it's hot at GitLab
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: IStreams
« Reply #11 on: February 09, 2026, 11:09:34 am »
Helloooo  ;D
Hehehe, at it again ;)
From the changelog:
Quote
08.02.2026 Further bits and pieces implemented -- backporting --
09.02.2026 Added factory function for IMemoryStream: 'CreMemStreamFromFile'
Gitlab
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

 

TinyPortal © 2005-2018