llvm.org GIT mirror llvm / 89a1a85
Implement operator<< in terms of basic types rather than [u]int*_t, which is better for portability. There might be some way to factor this all with metaprogramming magic, but I'm not sure how offhand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55114 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
1 changed file(s) with 39 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
7676 return write(Str.data(), Str.length());
7777 }
7878
79 raw_ostream &operator<<(uint64_t N) {
79 raw_ostream &operator<<(unsigned long N) {
8080 // Zero is a special case.
8181 if (N == 0)
8282 return *this << '0';
9292 return write(CurPtr, EndPtr-CurPtr);
9393 }
9494
95 raw_ostream &operator<<(int64_t N) {
95 raw_ostream &operator<<(long N) {
9696 if (N < 0) {
9797 if (OutBufCur >= OutBufEnd)
9898 flush_impl();
101101 N = -N;
102102 }
103103
104 return this->operator<<(static_cast(N));
105 }
106
107 raw_ostream &operator<<(uint32_t N) {
108 return this->operator<<(static_cast(N));
109 }
110
111 raw_ostream &operator<<(int32_t N) {
112 return this->operator<<(static_cast<int64_t>(N));
104 return this->operator<<(static_cast<unsigned long>(N));
105 }
106
107 raw_ostream &operator<<(unsigned long long N) {
108 // Zero is a special case.
109 if (N == 0)
110 return *this << '0';
111
112 char NumberBuffer[20];
113 char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
114 char *CurPtr = EndPtr;
115
116 while (N) {
117 *--CurPtr = '0' + char(N % 10);
118 N /= 10;
119 }
120 return write(CurPtr, EndPtr-CurPtr);
121 }
122
123 raw_ostream &operator<<(long long N) {
124 if (N < 0) {
125 if (OutBufCur >= OutBufEnd)
126 flush_impl();
127 *OutBufCur++ = '-';
128
129 N = -N;
130 }
131
132 return this->operator<<(static_cast(N));
133 }
134
135 raw_ostream &operator<<(unsigned int N) {
136 return this->operator<<(static_cast(N));
137 }
138
139 raw_ostream &operator<<(int N) {
140 return this->operator<<(static_cast(N));
113141 }
114142
115143 raw_ostream &operator<<(double N) {