13 #ifndef DEMANGLE_UTILITY_H 14 #define DEMANGLE_UTILITY_H 28 char *Buffer =
nullptr;
29 size_t CurrentPosition = 0;
30 size_t BufferCapacity = 0;
34 if (N + CurrentPosition >= BufferCapacity) {
36 if (BufferCapacity < N + CurrentPosition)
37 BufferCapacity = N + CurrentPosition;
38 Buffer =
static_cast<char *
>(std::realloc(Buffer, BufferCapacity));
39 if (Buffer ==
nullptr)
44 void writeUnsigned(uint64_t N,
bool isNeg =
false) {
55 *--TempPtr =
'0' +
char(N % 10);
67 : Buffer(StartBuf), CurrentPosition(0), BufferCapacity(Size) {}
69 void reset(
char *Buffer_,
size_t BufferCapacity_) {
72 BufferCapacity = BufferCapacity_;
85 std::memmove(Buffer + CurrentPosition, R.
begin(),
Size);
86 CurrentPosition +=
Size;
92 Buffer[CurrentPosition++] =
C;
102 writeUnsigned(static_cast<unsigned long long>(-N),
true);
104 writeUnsigned(static_cast<unsigned long long>(N));
109 writeUnsigned(N,
false);
114 return this->operator<<(static_cast<long long>(
N));
118 return this->operator<<(static_cast<unsigned long long>(
N));
122 return this->operator<<(static_cast<long long>(
N));
126 return this->operator<<(static_cast<unsigned long long>(
N));
133 return CurrentPosition ? Buffer[CurrentPosition - 1] :
'\0';
136 bool empty()
const {
return CurrentPosition == 0; }
146 bool ShouldRestore =
true;
152 : Restore(Restore_), OriginalValue(Restore) {
153 Restore = std::move(NewVal);
157 Restore = std::move(OriginalValue);
163 if (!Force && !ShouldRestore)
166 Restore = std::move(OriginalValue);
167 ShouldRestore =
false;
177 if (Buf ==
nullptr) {
178 Buf =
static_cast<char *
>(std::malloc(InitSize));
181 BufferSize = InitSize;
185 S.
reset(Buf, BufferSize);
const_iterator end(StringRef path)
Get end iterator over path.
OutputStream & operator+=(char C)
OutputStream & operator<<(char C)
OutputStream & operator<<(unsigned int N)
OutputStream & operator<<(long N)
unsigned CurrentPackIndex
If a ParameterPackExpansion (or similar type) is encountered, the offset into the pack that we're cur...
void restoreNow(bool Force)
#define DEMANGLE_NAMESPACE_END
const char * begin() const
OutputStream & operator+=(StringView R)
size_t getBufferCapacity() const
OutputStream & operator<<(long long N)
OutputStream & operator<<(int N)
OutputStream(char *StartBuf, size_t Size)
void shouldRestore(bool ShouldRestore_)
size_t getCurrentPosition() const
SwapAndRestore(T &Restore_)
OutputStream & operator<<(unsigned long N)
void setCurrentPosition(size_t NewPos)
SwapAndRestore(T &Restore_, T NewVal)
#define DEMANGLE_NAMESPACE_BEGIN
OutputStream & operator<<(unsigned long long N)
Align max(MaybeAlign Lhs, Align Rhs)
OutputStream & operator<<(StringView R)
bool initializeOutputStream(char *Buf, size_t *N, OutputStream &S, size_t InitSize)
void reset(char *Buffer_, size_t BufferCapacity_)