Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
SStringBuilder.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
20
21#pragma once
22
23#include <sese/Config.h>
24#include <sese/text/SString.h>
25
26namespace sstr {
27
29class SESE_DEPRECATED_WITH("please use sese::text::StringBuilder") SStringBuilder final {
30public:
31 SStringBuilder(const SStringBuilder &builder); // NOLINT
32 SStringBuilder(SStringBuilder &&builder) noexcept; // NOLINT
33 explicit SStringBuilder(size_t buffer_size);
34 ~SStringBuilder();
35
36public:
37 [[nodiscard]] const uint32_t *data() const;
38 [[nodiscard]] size_t size() const;
39 [[nodiscard]] size_t cap() const;
40
41 [[nodiscard]] bool null() const;
42 [[nodiscard]] bool emtpy() const;
43
44 bool reserve(size_t size);
45 void trim();
46 void reverse();
47 int32_t find(const char *str) const;
48 [[nodiscard]] int32_t find(const SStringView &str) const;
49 void append(const char *str);
50 void append(const SStringView &str);
51
52 // Not supported
53 // std::vector<SString> split(const char *str) const;
54 // std::vector<SString> split(const SString &str) const;
55
56 void clear();
57
58 [[nodiscard]] SChar at(size_t index) const;
59 void set(size_t index, SChar ch);
60 void remove(size_t index);
61 void remove(size_t begin, size_t len);
62 void substring(size_t begin);
63 void substring(size_t begin, size_t len);
64 void insert(size_t index, SChar ch);
65 void insert(size_t index, const char *str);
66 void insert(size_t index, const SStringView &str);
67 void replace(size_t begin, size_t len, const char *str);
68 void replace(size_t begin, size_t len, const SStringView &str);
69
70 [[nodiscard]] SString toString() const;
71
72private:
74 uint32_t *_data = nullptr;
76 size_t _size = 0;
78 size_t _cap = 0;
79};
80
81} // namespace sstr