Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 1 | //===-- string_utils.h ------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef SCUDO_STRING_UTILS_H_ |
| 10 | #define SCUDO_STRING_UTILS_H_ |
| 11 | |
| 12 | #include "internal_defs.h" |
| 13 | #include "vector.h" |
| 14 | |
| 15 | #include <stdarg.h> |
| 16 | |
| 17 | namespace scudo { |
| 18 | |
| 19 | class ScopedString { |
| 20 | public: |
| 21 | explicit ScopedString(uptr MaxLength) : String(MaxLength), Length(0) { |
| 22 | String[0] = '\0'; |
| 23 | } |
| 24 | uptr length() { return Length; } |
| 25 | const char *data() { return String.data(); } |
| 26 | void clear() { |
| 27 | String[0] = '\0'; |
| 28 | Length = 0; |
| 29 | } |
| 30 | void append(const char *Format, va_list Args); |
| 31 | void append(const char *Format, ...); |
Dynamic Tools Team | 3e8c65b | 2019-10-18 20:00:32 +0000 | [diff] [blame] | 32 | void output() const { outputRaw(String.data()); } |
Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | Vector<char> String; |
| 36 | uptr Length; |
| 37 | }; |
| 38 | |
Kostya Kortchinsky | 4d022f5 | 2021-05-24 09:26:21 -0700 | [diff] [blame^] | 39 | int formatString(char *Buffer, uptr BufferLength, const char *Format, ...); |
Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 40 | void Printf(const char *Format, ...); |
| 41 | |
| 42 | } // namespace scudo |
| 43 | |
| 44 | #endif // SCUDO_STRING_UTILS_H_ |