Question about ifstream ranges

Hello all! I face the problem of partitioning a file that i read with ifstream into portions that are to be processed by some clients. I want to ensure that a client only views a specific part (window, range) of the stream. So far I store 2 streamoffsets posStart and posEnd, call seekg on the stream, pass it to the client by ref and rely on the client to check when it reached posEnd. However, I certainly cannot copy the whole range into a new stream object and pass that one. Efficiency does matter. Any suggestions? Maybe some iterator-magic can be done? Thanks in advance, -- Christian Pfligersdorffer Dipl.-Ing. Bakk.rer.nat. Software Engineering EOS GmbH - Electro Optical Systems Robert-Stirling-Ring 1 D-82152 Krailling / Munich Phone +49 89 893 36-229 Fax +49 89 893 36-287 christian.pfligersdorffer@eos.info http://www.eos.info

Pfligersdorffer, Christian wrote:
Hello all!
I face the problem of partitioning a file that i read with ifstream into portions that are to be processed by some clients. I want to ensure that a client only views a specific part (window, range) of the stream. So far I store 2 streamoffsets posStart and posEnd, call seekg on the stream, pass it to the client by ref and rely on the client to check when it reached posEnd.
However, I certainly cannot copy the whole range into a new stream object and pass that one. Efficiency does matter.
Any suggestions? Maybe some iterator-magic can be done?
How about Boost.Spirit file_iterator? That is a read-only RandomAccessIterator for files. http://spirit.sourceforge.net/distrib/spirit_1_8_3/libs/spirit/doc/file_iter... -- Shunsuke Sogame
participants (2)
-
Pfligersdorffer, Christian
-
shunsuke