aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/tests/dump.cpp
blob: b9382d21892695e46834accca9849e32aca57cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (C) 2007-2013 Xagasoft, All rights reserved.
 *
 * This file is part of the libgats library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include <bu/sio.h>
#include <bu/file.h>
#include <gats/gatsstream.h>
#include <gats/types.h>

using namespace Bu;

int main( int argc, char *argv[] )
{
    File fIn( argv[1], File::Read );
    Gats::GatsStream gsIn( fIn );

    for(;;)
    {
        sio << "Reading from file position: " << fIn.tell() << sio.nl;
        Gats::Object *pObj = gsIn.readObject();
        if( !pObj )
        {
            if( gsIn.hasReadBuffer() )
            {
                sio << "Premature end of stream detected, have "
                    << gsIn.getReadBufferSize() << "b." << sio.nl;
            }
            return 0;
        }

        sio << *pObj << sio.nl;
    }
}