summaryrefslogtreecommitdiffstats
path: root/public/sdk/inc/memser.hxx
blob: b3a8d74a6ac6dbe76ab792755bbae265d3be2f23 (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1992.
//
//  File:       MemSer.hxx
//
//  History:    29-Jul-94 KyleP     Created
//
//--------------------------------------------------------------------------

#if !defined( __MEMSER_HXX__ )
#define __MEMSER_HXX__

#include <restrict.hxx>
#include <SStream.hxx>

class CMemSerStream : public PSerStream
{
public:

    CMemSerStream( unsigned cb );
    CMemSerStream(BYTE * pb, ULONG cb);

    virtual ~CMemSerStream();

    inline BYTE *AcqBuf();

    virtual void PutByte( BYTE b );

    virtual void PutChar( char const * pc, ULONG cc );

    virtual void PutWChar( WCHAR const * pwc, ULONG cc );

    virtual void PutUShort( USHORT us );

    virtual void PutULong( ULONG ul );

    virtual void PutLong( long l );

    virtual void PutFloat( float f );

    virtual void PutDouble( double d );

    virtual void PutString( char const * psz );

    virtual void PutWString( WCHAR const * pwsz );

    virtual void PutBlob( BYTE const * pb, ULONG cb );

    virtual void PutGUID( GUID const & guid );

    inline unsigned Size() { return _cb; }

protected:

    unsigned _cb;
    BYTE *   _pb;
    BYTE *   _pbCurrent;
    BYTE *   _pbEnd;
};

inline BYTE * CMemSerStream::AcqBuf()
{
    BYTE * pb;

    if ( _cb > 0 )
    {
        pb = _pb;
        _pb = 0;
        _cb = 0;
    }
    else
        pb = 0;

    return( pb );
}

#endif // __MEMSER_HXX__