View previous topic :: View next topic |
Author |
Message |
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Tue May 23, 2006 1:29 pm Post subject: |
|
|
kris wrote: | BTW: if you just want a single line of input, then you can dispense with the foreach() and instead do a get() on the LineIterator instance. This will simply wait until there's either a line available in the input or an eof is encountered. The foreach() is just a wrapper around get(). Oh, and you can reuse a LineIterator instance via the various set...() methods. |
Thanks for the get() suggestion. Also, I'm not worried anymore about creating new LineIterators because I can just reuse the same over and over again.
kris wrote: | I thought about having an output equivalent of Iterator, but couldn't come up with anything compelling. If you have some ideas, please make them known |
My gut feeling is that there is no output equivalent of Iterator (I had an idea about how to explain it, but I lost it...)
kris wrote: | Currently there's at least three (layered) ways to output content to a conduit, from lowest level to highest:
* conduit.write()
* buffer.append()
* writer.put()
The latter handles various conversion as necessary (including unicode conversion), whereas the former two are simple unformatted output using void[] arguments. If you don't need conversion, the former two are more appropriate, with the middle (buffered) one probably being the right balance for common designs. |
writer.put () is what I want, but I want a DisplayWriter or a TextWriter to use with a SocketConduit. That's it. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Tue May 23, 2006 1:34 pm Post subject: |
|
|
kris wrote: | Carlos wrote: | Ok, now that I have a working trunk, is this how I should do the original example?
Code: |
auto reader = new TextReader (new NumericParser (new LineIterator (client)), new UnicodeExporter!(char) ());
|
I'm sorry but, are you kidding me? Worst is, I don't even know if that's going to work.
|
I've no idea why anyone would wish to do such a thing with a socket |
I almost forgot about this: forget that this is about a SocketConduit: it's just a Conduit. Forget it's about reading line by line: someone just wants to use a TextReader with a Conduit. Is this how it should be done?
Code: |
auto reader = new TextReader (new NumericParser (new SomeIterator (conduit)), new UnicodeExporter!(char) ());
|
If not, how? If yes, shouldn't it be simpler? If one can just use SomeIterator, what's the purpose of TextReader? |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue May 23, 2006 1:41 pm Post subject: |
|
|
Readers and Iterators are used for quite different purposes. But the TextReader should certainly be easier to instantiate. Next release will have something better. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue May 23, 2006 4:04 pm Post subject: |
|
|
Carlos wrote: | Anyway, I'm ok with reading with Iterators now |
I should note that an Iterator slices the content (as noted in the doc) so your application may, or may not, need to .dup the returned slice ~ just an FYI |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Tue May 23, 2006 6:08 pm Post subject: |
|
|
kris wrote: | Readers and Iterators are used for quite different purposes. But the TextReader should certainly be easier to instantiate. Next release will have something better. |
Thanks! |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Tue May 23, 2006 6:10 pm Post subject: |
|
|
kris wrote: | Carlos wrote: | Anyway, I'm ok with reading with Iterators now |
I should note that an Iterator slices the content (as noted in the doc) so your application may, or may not, need to .dup the returned slice ~ just an FYI |
Thanks for the reminder |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|