string_utils.h revision 360784
1139804Simp//===-- string_utils.h ------------------------------------------*- C++ -*-===// 246197Sphk// 346197Sphk// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 446197Sphk// See https://llvm.org/LICENSE.txt for license information. 546197Sphk// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 646197Sphk// 746197Sphk//===----------------------------------------------------------------------===// 846197Sphk 946155Sphk#ifndef SCUDO_STRING_UTILS_H_ 10116182Sobrien#define SCUDO_STRING_UTILS_H_ 11116182Sobrien 12116182Sobrien#include "internal_defs.h" 13131177Spjd#include "vector.h" 14131177Spjd 1546155Sphk#include <stdarg.h> 1646155Sphk 1746155Sphknamespace scudo { 1846155Sphk 1946155Sphkclass ScopedString { 2046155Sphkpublic: 2146155Sphk explicit ScopedString(uptr MaxLength) : String(MaxLength), Length(0) { 22164032Srwatson String[0] = '\0'; 2346155Sphk } 24124882Srwatson uptr length() { return Length; } 2546155Sphk const char *data() { return String.data(); } 2687275Srwatson void clear() { 2787275Srwatson String[0] = '\0'; 28168401Spjd Length = 0; 29113275Smike } 30147185Spjd void append(const char *Format, va_list Args); 31113275Smike void append(const char *Format, ...); 3246155Sphk void output() const { outputRaw(String.data()); } 33113275Smike 3457163Srwatsonprivate: 35113275Smike Vector<char> String; 3646155Sphk uptr Length; 3746155Sphk}; 3846155Sphk 39163606Srwatsonvoid Printf(const char *Format, ...); 40163606Srwatson 4146155Sphk} // namespace scudo 4246155Sphk 4389414Sarr#endif // SCUDO_STRING_UTILS_H_ 4457163Srwatson