-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathostream
45 lines (36 loc) · 1.06 KB
/
ostream
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
#ifndef OSTREAM
#define OSTREAM
#include <ion/console.h>
#include <poincare/print_int.h>
namespace std {
class ostream {
public:
template <typename T>
ostream& operator<<(const T& any) {
return *this;
}
ostream& operator<<(const char* str) {
Ion::Console::writeLine(str, false);
return *this;
}
ostream& operator<<(int i) {
constexpr char bufferSize = 32;
char buffer[bufferSize];
if (i < 0) {
Ion::Console::writeChar('-');
}
int p = Poincare::PrintInt::Left(i, buffer, bufferSize);
buffer[p] = 0;
Ion::Console::writeLine(buffer, false);
return *this;
}
ostream& operator<<(unsigned int i) { return *this << static_cast<int>(i); }
ostream& operator<<(unsigned short i) { return *this << static_cast<int>(i); }
ostream& operator<<(short i) { return *this << static_cast<int>(i); }
ostream& operator<<(unsigned char i) { return *this << static_cast<int>(i); }
ostream& operator<<(char i) { return *this << static_cast<int>(i); }
};
static ostream cout;
static char endl = '\n';
} // namespace std
#endif