-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutstream.cpp
More file actions
43 lines (35 loc) · 719 Bytes
/
Copy pathoutstream.cpp
File metadata and controls
43 lines (35 loc) · 719 Bytes
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
#include "outstream.h"
#include "common.h"
#include <cstdio> // for EOF
int buf::overflow(int c) {
if (c == EOF) {
return EOF;
}
else {
unsigned int max_line_len = log_line_length;
int last = data.size()-1;
if (c == '\n' || data[last].size() >= max_line_len) {
std::string s;
if (c != '\n') s.push_back(c);
if (data.size() >= (unsigned int)max_size) {
for(int j = 0; j < last; ++j) {
data[j] = data[j+1];
}
data.pop_back();
}
data.push_back(s);
}
else{
data[last].push_back(c);
}
return c;
}
}
int buf::sync() {
return 0;
}
buf::buf() {
max_size = 8;
data.resize(1);
data[0] = "";
}