Article View: comp.sys.mac.programmer.codewarrior
Article #9Re: getline() dilemna - text or binary?
From: 712311173 T.M. Steward
Date: Sun, 03 Sep 1995 20:10
Date: Sun, 03 Sep 1995 20:10
35 lines
1887 bytes
1887 bytes
:>I need to process text files one line at a lime. :> :>I'm wondering if anyone has come up with a convenient, efficient way to :>read files a line at a time, regardless of the format of the text file? I've found that using getline or any of the extractor-type functions to be *extremely* inefficent(i.e. time-consuming). If you don't need the portability, it's _much_ faster to read the file using the DosRead() API in chunks that are multiples of the cluster size. Usually, for FAT drives that's 4k. I read at least 16k. Then use a small state machine to decode lines,blocks,whatever back to your program. This is a convienient way also since you can not only handle all the flavors of delimiters, but also comment lines, tab expansion(another thing you forgot), quoted fields, etc.. This is just a bitch, but the latest 'C++' libs have so many features, buffers, etc, that I have a hard time figuring out how to effectively _use_ them. This way, I'm in control. If portability is a problem, you can use the 'C' lib fread() instead. It just calls DosRead on OS/2 anyway. Setup a small class called textfile or similar with open, close, readline; That's what I do. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> On the net or on your knees ... >>> >>> Tully Steward, Software Engineer >>> Weekdays: Tully_Steward%Compressor_Controls@MCIMAIL.com >>> Night/Weekends: 71231,1173@compuserve.com >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Technical Details
Message-ID:
<42d241$63l@insosf1.netins.net>Path:
arc1-ca.pugleaf.net!news.netins.net!usenetShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.netins.net!usenet From: 71231,1173@compuserve.com (T.M. Steward) Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++ Subject: Re: getline() dilemna - text or binary? Date: 3 Sep 1995 20:10:41 GMT Organization: CCC Message-ID: <42d241$63l@insosf1.netins.net> NNTP-Posting-Host: s4165.netins.net X-Newsreader: NeoLogic News for OS/2 [version: 4.2 UNREGISTERED 28 days remaining]