blob: b7c88f1b0bc7a379d6c1c1be9e3bf84e512da2b3 (
about) (
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
|
#include <fstream.h>
#include <time.h>
#include "tex.hh"
#include "main.hh"
#include "tstream.hh"
#include "debug.hh"
Tex_stream::Tex_stream(String filename)
{
os = new ofstream(filename);
if (!*os)
error("can't open `" + filename+"\'");
nest_level = 0;
outputting_comment=false;
header();
}
void
Tex_stream::header()
{
*os << "% Creator: " << get_version();
*os << "% Automatically generated, at ";
time_t t(time(0));
*os << ctime(&t);
//*os << "% from input file ..\n";
}
Tex_stream::~Tex_stream()
{
delete os;
assert(nest_level == 0);
}
// print string. don't forget indent.
Tex_stream &
Tex_stream::operator<<(String s)
{
for (const char *cp = s; *cp; cp++) {
if (outputting_comment) {
*os << *cp;
if (*cp == '\n') {
outputting_comment=false;
}
continue;
}
switch(*cp)
{
case '%':
outputting_comment = true;
*os << *cp;
break;
case '{':
nest_level++;
*os << *cp;
break;
case '}':
nest_level--;
*os << *cp;
assert (nest_level >= 0);
/* FALL THROUGH */
case '\n':
*os << "%\n";
*os << String(' ', nest_level);
break;
default:
*os << *cp;
break;
}
}
return *this;
}
/****************************************************************/
|