Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
SStringBuilder.h
浏览该文件的文档.
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 {
30 // 构造相关
31public:
32 SStringBuilder(const SStringBuilder &builder); // NOLINT
33 SStringBuilder(SStringBuilder &&builder) noexcept; // NOLINT
34 explicit SStringBuilder(size_t buffer_size);
35 ~SStringBuilder();
36
37 // 基础功能
38public:
39 [[nodiscard]] const uint32_t *data() const;
40 [[nodiscard]] size_t size() const;
41 [[nodiscard]] size_t cap() const;
42
43 [[nodiscard]] bool null() const;
44 [[nodiscard]] bool emtpy() const;
45
46 bool reserve(size_t size);
47 void trim();
48 void reverse();
49 int32_t find(const char *str) const;
50 [[nodiscard]] int32_t find(const SStringView &str) const;
51 void append(const char *str);
52 void append(const SStringView &str);
53
54 // 不会支持
55 // std::vector<SString> split(const char *str) const;
56 // std::vector<SString> split(const SString &str) const;
57
58 void clear();
59
60 [[nodiscard]] SChar at(size_t index) const;
61 void set(size_t index, SChar ch);
62 void remove(size_t index);
63 void remove(size_t begin, size_t len);
64 void substring(size_t begin);
65 void substring(size_t begin, size_t len);
66 void insert(size_t index, SChar ch);
67 void insert(size_t index, const char *str);
68 void insert(size_t index, const SStringView &str);
69 void replace(size_t begin, size_t len, const char *str);
70 void replace(size_t begin, size_t len, const SStringView &str);
71
72 [[nodiscard]] SString toString() const;
73
74private:
76 uint32_t *_data = nullptr;
78 size_t _size = 0;
80 size_t _cap = 0;
81};
82
83} // namespace sstr