sscanf() equivalent for D using Phobos library?

BCS ao at pathlink.com
Thu Dec 4 22:09:31 PST 2008


Reply to Bill,

> On Fri, Dec 5, 2008 at 11:09 AM, BCS <ao at pathlink.com> wrote:
> 
>> Reply to Bill,
>> 
>>>>>> On Wed, Dec 3, 2008 at 6:37 PM, rocknroll714
>>>>>> <rocknroll714 at gmail.com> wrote:
>>>>>>> I'm looping through a text file using the File.getline() command
>>>>>>> 
>>> scope thestream = new std.stream.MemoryStream(thebuffer);
>>> 
>> One new MemoeryStream per line!?!?
>> 
> It's scope!  No worries mate! ;-)
> 
> But seriously, it does sound heavyweight compared to a single sscanf
> function call.
> Honestly, std.stream is just barely functional enough to write the
> simplest stream code, so I wouldn't be surprised if that's what it
> takes to scan strings with it.  Not much worse than what it takes to
> do it with std::stream in c++ though.
> I'm really talking out of my ass though, because I can probably count
> on one hand how many times written code to use scanf or stringstream
> in my life.  If I have to parse input I'm much more likely to reach
> for the regexp hammer or write a simpler parser.
> 
> --bb
> 

there should so be a std.scan.scan function to go with the std.format.format.




More information about the Digitalmars-d-learn mailing list