I had a look at Kem's original code, and it is apparant that my code
is a lot bigger. I'm trying to make sure ElfData is doing efficient
stuff with the file buffering input and output you see, and that
makes it all more complex.
What I think I'll do, is make an ElfDataStream class, probably within
the plugin itself.
It will be a subclass of FastString, so that'll be handy for writing
to the stream.
It'll manage all of this buffering and caching stuff for you, but
give you the ability to fine-tune it, if you need, unlike REALbasic's
streams.
It'll be an input and output stream, just like the binarystream.
And... it will accept many constructors!
Constructor( PathToFile as string ) // handy way to read files
Constructor( stream as Readable ) // read from stdin, or sockets
Constructor( stream as Writeable ) // write to stdout or sockets
Constructor( f as folderitem )
Constructor( bs as binarystream )
It should have an ElfDataFields property, which will allow it to make
use of it ElfDataFields's line processing abilities.
So I could have done something like this:
dim sIn, sOut as ElfDataStream
dim Slider as ElfData
sIn = "input.txt"
sOut = "output.txt"
while sIn.ReadLine(slider) // modifies the value in Slider to
avoid object creation overhead
if slider.length = 0 then
// ignore
elseif Slider.OutCharSet(Numbers) = 0 then // it's a number
sOut.AppendString "case "
sOut.AppendElfData e
else
sOut.AppendString "r = """
sOut.AppendElfData Slider.ReplaceAll( q1, q2 ) // ", ""
sOut.AppendByte 34
sOut.AppendByte 10
end if
sOut.AppendByte 10
wend
// sOut and sIn will auto-close upon object destruction
// but will have explicit closes, for when needed.
It would be just as fast, if not faster, but... as you can see, much
nicer to use.
What do you think?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>