mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 23:18:58 +00:00
give smallstring some methods to do 'itoa'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49765 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
171c11ec93
commit
c0814dc606
@ -53,6 +53,47 @@ public:
|
||||
this->push_back(C);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SmallString &append_uint_32(uint32_t N) {
|
||||
char Buffer[20];
|
||||
char *BufPtr = Buffer+19;
|
||||
|
||||
if (N == 0) *--BufPtr = '0'; // Handle special case.
|
||||
|
||||
while (N) {
|
||||
*--BufPtr = '0' + char(N % 10);
|
||||
N /= 10;
|
||||
}
|
||||
this->append(BufPtr, Buffer+20);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SmallString &append_uint(uint64_t N) {
|
||||
if (N == uint32_t(N))
|
||||
return append_uint_32(uint32_t(N));
|
||||
|
||||
char Buffer[40];
|
||||
char *BufPtr = Buffer+39;
|
||||
|
||||
if (N == 0) *--BufPtr = '0'; // Handle special case...
|
||||
|
||||
while (N) {
|
||||
*--BufPtr = '0' + char(N % 10);
|
||||
N /= 10;
|
||||
}
|
||||
|
||||
this->append(BufPtr, Buffer+40);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SmallString &append_sint(int64_t N) {
|
||||
// TODO, wrong for minint64.
|
||||
if (N < 0) {
|
||||
this->push_back('-');
|
||||
N = -N;
|
||||
}
|
||||
return append_uint(N);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user