• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef OHOS_HDI_STRINGBUILDER_H
10 #define OHOS_HDI_STRINGBUILDER_H
11 
12 #include "util/string.h"
13 
14 namespace OHOS {
15 namespace HDI {
16 class StringBuilder {
17 public:
18     ~StringBuilder();
19 
20     StringBuilder& Append(char c);
21 
22     StringBuilder& Append(const char* string);
23 
24     StringBuilder& Append(const String& string);
25 
26     StringBuilder& AppendFormat(const char* format, ...);
27 
28     String ToString() const;
29 
30 private:
31     bool Grow(size_t size);
32 
33     static const char* TAG;
34     char* buffer_ = nullptr;
35     size_t position_ = 0;
36     size_t capacity_ = 0;
37 };
38 } // namespace HDI
39 } // namespace OHOS
40 
41 #endif // OHOS_HDI_STRINGBUILDER_H