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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
// -*- C++ -*-
// $Id$
#include "PSDL_Stream.h"
TAO_PSDL_Stream::TAO_PSDL_Stream (void)
{
}
TAO_PSDL_Stream::~TAO_PSDL_Stream (void)
{
}
int
TAO_PSDL_Stream::open (const char *fname)
{
if (fname != 0)
{
// File name exists, open an I/O file handle.
this->fp_ = ACE_OS::fopen (fname, "w");
if (this->fp_ != 0)
{
return 0;
}
else
{
return -1;
}
}
else
{
return -1;
}
}
// Return the underlying lowlevel file pointer.
// indentation.
FILE *
TAO_PSDL_Stream::file (void)
{
return this->fp_;
}
int
TAO_PSDL_Stream::incr_indent (unsigned short flag)
{
indent_level_++;
if (flag != 0)
{
return this->indent ();
}
else
{
// Do not indent output.
return 0;
}
}
// Indentation
int
TAO_PSDL_Stream::decr_indent (unsigned short flag)
{
this->indent_level_--;
// Just in case somebody gets "unindent happy".
if (this->indent_level_ < 0)
{
// ACE_DEBUG ((LM_DEBUG, "negative indentation?\n"));
this->indent_level_ = 0;
}
if (flag != 0)
{
return this->indent ();
}
else
{
// Do not indent output.
return 0;
}
}
int
TAO_PSDL_Stream::reset (void)
{
this->indent_level_ = 0;
return 0;
}
// Indented print.
int
TAO_PSDL_Stream::indent (void)
{
// Based on the current indentation level, leave appropriate number of blank
// spaces in the output.
if (this->indent_level_ > 0)
{
for (int i = 0; i < this->indent_level_; i++)
{
ACE_OS::fprintf (this->fp_, " ");
ACE_OS::fflush (this->fp_);
}
}
return 0;
}
int
TAO_PSDL_Stream::nl (void)
{
ACE_OS::fprintf (this->fp_, "\n");
this->indent ();
return 0;
}
TAO_PSDL_Stream &
TAO_PSDL_Stream::operator<< (const char *str)
{
ACE_OS::fprintf (this->fp_, "%s", str);
ACE_OS::fflush (this->fp_);
return *this;
}
TAO_PSDL_Stream &
TAO_PSDL_Stream::operator<< (ACE_CString str)
{
ACE_OS::fprintf (this->fp_, "%s", str.c_str ());
ACE_OS::fflush (this->fp_);
return *this;
}
TAO_PSDL_Stream &
TAO_PSDL_Stream::operator<< (const unsigned long num)
{
ACE_OS::fprintf (this->fp_,
"%lu",
num);
ACE_OS::fflush (this->fp_);
return *this;
}
TAO_PSDL_Stream &
TAO_PSDL_Stream::operator<< (const long num)
{
ACE_OS::fprintf (this->fp_,
"%ld",
num);
ACE_OS::fflush (this->fp_);
return *this;
}
|