summaryrefslogtreecommitdiff
path: root/tvision/classes/pstream.cc
blob: 4286d6981d0dfc9509868c8cda3a8cc3c05468d9 (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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 *      Turbo Vision - Version 2.0
 *
 *      Copyright (c) 1994 by Borland International
 *      All Rights Reserved.
 *

Modified by Robert H”hne to be used for RHIDE.
Modified to compile with gcc v3.x by Salvador E. Tropea, with the help of
Andris Pavenis and Christoph Bauer.

 *
 *
 */
// SET: Moved the standard headers here because according to DJ
// they can inconditionally declare symbols like NULL
#include <stdlib.h>

#define Uses_TStreamableTypes
#define Uses_TStreamableClass
#define Uses_TStreamable
#define Uses_pstream
#include <tv.h>

UsingNamespaceStd

pstream::pstream( CLY_streambuf *sb )
{
    init( sb );
}

pstream::~pstream()
{
}

void pstream::deInitTypes(void)
{
 if (types)
    delete types;
}

// The following call to new is overloaded, avoid
// using MSS for it.
#include <tv/no_mss.h>

void pstream::initTypes()
{
 if (!types)
   {
    types=new TStreamableTypes;
    atexit(pstream::deInitTypes);
   }
}

#include <tv/yes_mss.h>

int pstream::rdstate() const
{
    return state;
}

int pstream::eof() const
{
    return state & CLY_IOSEOFBit;
}

int pstream::fail() const
{
    return state & (CLY_IOSFailBit | CLY_IOSBadBit);
}

int pstream::bad() const
{
    return state & (CLY_IOSBadBit);
}

int pstream::good() const
{
    return state == 0;
}

void pstream::clear( int i )
{
    state = (i & 0xFF);
}

void pstream::registerType( TStreamableClass *ts )
{ 
    types->registerType( ts ); 
}

pstream::operator void *() const
{
    return fail() ? 0 : (void *)this;
}

int pstream::operator! () const
{
    return fail();
}

CLY_streambuf * pstream::rdbuf() const
{
    return bp;
}

pstream::pstream()
{
}

void pstream::error( StreamableError )
{
    abort();
}

void pstream::error( StreamableError, const TStreamable& )
{
    abort();
}

void pstream::init( CLY_streambuf *sbp )
{
    state = 0;
    bp = sbp;
}

void pstream::setstate( int b )
{
    state |= (b&0xFF);
}

TStreamableTypes * pstream::types;