Ok. The problem is that it is a bit fuzzy where cryptopp is fitting in.
You mean skip x lines from (i) the raw input file or (ii) the
decrypted/decompressed/whatever file? If (ii) is the case, you should
create a special skipping filter, maybe even subclassing StringSink...
Then you might go pumping fixed-length blocks till your special sink
signals that what you've got what you want. ONLY THEN pass the data on to
the xmlparser. Your design that pumps from inside the callback function
will lead you nowhere, in my opinion ...
It is perfectly possible to develop a sink that will enable you to keep
memory under control.
Jorge.
kan escreveu:
>
> On Jan 25, 5:34 pm, "Jorge Marques Pelizzoni" <[EMAIL PROTECTED]>
> wrote:
>
>> One way to do it is exemplified below.
> ...
>> string rslt;
>> {
>> FileSource fs(is, true /* automatically call PumpAll */,
> It reads whole file into the rslt, all goes into memory. I try to avoid
> it.
> For instance, if I have a big file, say 500mb and want to read a line
> number 12345 I don't need to read whole file into memory, I may just
> skip 12344 lines.
>
> I feel it's impossible... :(
> I have only idea something like this, may be it's best possible
> solution:
>
> struct InputReadCallbackContext
> {
> CryptoPP::Source *pump;
> CryptoPP::BufferedTransformation *source;
> };
> static int xmlInputReadFromStreamCallback(void *_ctx, char *buffer, int
> len)
> {
> using namespace CryptoPP;
> InputReadCallbackContext *ctx = (InputReadCallbackContext *)_ctx;
> try
> {
> ctx->pump->Pump(1234);// Just a random number!!! And difficult
> to
> understand what should be here.
> return ctx->source->Get((byte *)buffer, (size_t) len);
> }
> catch(Exception &e)
> {
> return -1;
> }
> }
>
> ...
> FileSource source("a file", false);
> InputReadCallbackContext ctx;
> ctx.pump = &source;
> source.Detach(ctx.source = new ZlibDecompressor);
> xmlDocPtr doc = xmlReadIO(xmlInputReadFromStreamCallback, ... &ctx,
> ...);
>
>
> >
Jorge M. Pelizzoni
ICMC - Universidade de São Paulo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---