Additional
Porting C/C++ code to Delphi. Hello sscanf !
Posted by Diman [Feb 28, 2007]
Last time when I was porting C/C++ code to Delphi, I found almost all counterparts in Delphi RTL. But nothing about sscanf ...

First at all for those, who does not know what is sscanf, I will explain a bit. It is standard C function, which reads string buffer, parses it according to format string and put values into variable  references passed to sscanf. So, it is opposite for Delphi Format function.

 

So, original C/C++ source was using sscanf in a lot of places. I was thinking about 3 options, at least:

  • rewrite using regular expression library - TRegExpr;
  • rewrite using Delphi RTL functions like a Pos, Copy, etc and custom parsing code;
  • port C/C++ sscanf to Delphi.

 

First option required to translate format string from sscanf format to regular expression one. Playing a bit with both things, I got it will be error prone way. Second option - the same, because some format strings were really complex. So ... I have ported sscanf source code to Delphi.

 

Some links how to use sscanf:

 

And Delphi source code and demo application you can find here.


LIST OF COMMENTS


1/1. Another great piece of code from Diman!
Posted by bootsector - Mar 02, 2007
Website
Thanks for another great contribution for the "Delphi Scene", Diman!

I am a big fan of you and your softwares (AnyDAC rocks! ;-)

Regards,

bootsector

Add Comments