"Streams"

From: bonj (a_at_b.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 14:58:29 +0000

hello
I hope somebody can help me get my head around this area of 'stream'
programming... I know that streams are very fashionable nowadays so
hopefully there'll be lots of replies. ;-)

Basically I have an operation which the input and output for are streams -
a function which receives a certain 'chunk' of data each time it runs, and
it runs many times until it has received all the data, in a similar way to
a socket.
What the processing involves is treating the data like a string, and
picking out certain 'words' and putting 'tags' round them. For instance,
say if the word 'dog' came along, I want to replace it with
<animal>dog</animal> or something like that.
So that if the input stream was "table kennel dog coffee beer" the output
stream would be "table kennel <animal>dog</animal> coffee beer" or
something like that.
So say, if in a stream-like fashion, the stream function was called 5
times, each receiving 100 bytes of a transmission which is 500 bytes
in total.

What if the word 'dog' occurred from characters 99 to 101?
The first invocation would *end* in the characters "...do" and the second
would start with the characters "g ..."
I can't think how I can solve this, it is eluding me unfortunately. It
sounds like it should be simple, but isn't. I need to do it in a way that
doesn't involve storing the whole string in memory at once (for
performance reasons - the whole data might be as large as 64K), and hope
somebody can shed any further light on it!

Please don't say "You need to examine the bytes at the end of one
invocation and compare them with the ones at the start of the next"...
because I know this is *what* I've got to do, the question is *how*?



Relevant Pages

  • "Streams"
    ... I know that streams are very fashionable nowadays so ... So that if the input stream was "table kennel dog coffee beer" the output ... The first invocation would *end* in the characters "...do" and the second ...
    (microsoft.public.vc.language)
  • "Streams"
    ... I know that streams are very fashionable nowadays so ... So that if the input stream was "table kennel dog coffee beer" the output ... The first invocation would *end* in the characters "...do" and the second ...
    (comp.lang.c)
  • Re: "Read stuff from a file and chop it up to do stuff" code advice wanted.
    ... ;; OUTPUT: T or NIL ... ;; characters (I think it is Unicode at least! ... a stream and an array to hold characters in temp memory. ... ;; resulting string. ...
    (comp.lang.lisp)
  • Re: java i/o streams graphical representation and more ....
    ... this stream consists classes that are used to read data and also ... characters and writing data in the form of characters. ... OutputStream (byte oriented class for writing data) ...
    (comp.lang.java.programmer)
  • Re: sscanf question
    ... Input characters are taken from a supplied stdio stream (which is ... (The failure is an "input failure" if fgetc() ... would return EOF on ...
    (comp.lang.c)