🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6418

Re: memory stream parsing

#6418
From: Remy Lebeau (TeamB)
Date: Mon, 16 May 2005 17:12
40 lines
1972 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message
news:4287a0a4$1@newsgroups.borland.com...

> // UNTESTED !!!

You don't need a second stream, you can modify the source stream's data
directly, ie:

    {
        TMemoryStream *MS = new TMemoryStream;
        // fill stream as needed...

        LPBYTE Original = static_cast<LPBYTE>(MS->Memory);
        LPBYTE Ptr = Original;
        LPBYTE End = (Original + MS->Size);

        while( Ptr < End )
        {
            if( IS_CR_OR_LF(*Ptr) )
            {
                LPBYTE Temp = (Ptr + 1);
                while( (Temp < End) && IS_CR_OR_LF(*Temp) )
                    ++Temp;

                ::MoveMemory(Ptr, Temp, End - Temp);
                End -= (Temp - Ptr);
            }
            else
                ++Ptr;
        }

        MS->Size = (End - Original);
        // use new stream data as needed...

        delete MS;
    }


Gambit
Technical Details
Message-ID: <4288d437$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42878a87$1@newsgroups.borland.com> <4287a0a4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,cb77108e6b3d9403
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <42878a87$1@newsgroups.borland.com> <4287a0a4$1@newsgroups.borland.com>
Subject: Re: memory stream parsing
Date: Mon, 16 May 2005 10:12:18 -0700
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4288d437$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116263479 68.69.17.41 (16 May 2005 10:11:19 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail