Flecs: include/flecs/addons/cpp/utils/stringstream.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
stringstream.hpp
Go to the documentation of this file.
1
5
6namespace flecs {
7
9 struct stringstream {
11 explicit stringstream()
12 : buf_({}) { }
13
15 ~stringstream() {
16 ecs_strbuf_reset(&buf_);
17 }
18
20 stringstream(stringstream&& str) noexcept {
21 ecs_strbuf_reset(&buf_);
22 buf_ = str.buf_;
23 str.buf_ = {};
24 }
25
27 stringstream& operator=(stringstream&& str) noexcept {
28 ecs_strbuf_reset(&buf_);
29 buf_ = str.buf_;
30 str.buf_ = {};
31 return *this;
32 }
33
35 stringstream& operator=(const stringstream& str) = delete;
37 stringstream(const stringstream& str) = delete;
38
40 stringstream& operator<<(const char* str) {
41 ecs_strbuf_appendstr(&buf_, str);
42 return *this;
43 }
44
46 flecs::string str() {
47 return flecs::string(ecs_strbuf_get(&buf_));
48 }
49
50private:
51 ecs_strbuf_t buf_;
52};
53
54}
flecs::string
Owned string wrapper.
Definition string.hpp:15
flecs::stringstream::operator=
stringstream & operator=(stringstream &&str) noexcept
Move assignment operator.
Definition stringstream.hpp:27
flecs::stringstream::stringstream
stringstream(const stringstream &str)=delete
Ban implicit copies/allocations.
flecs::stringstream::operator=
stringstream & operator=(const stringstream &str)=delete
Ban implicit copies/allocations.
flecs::stringstream::stringstream
stringstream()
Default constructor.
Definition stringstream.hpp:11
flecs::stringstream::stringstream
stringstream(stringstream &&str) noexcept
Move constructor.
Definition stringstream.hpp:20
flecs::stringstream::str
flecs::string str()
Get the accumulated string as an owned flecs::string.
Definition stringstream.hpp:46
flecs::stringstream::operator<<
stringstream & operator<<(const char *str)
Append a C string to the stream.
Definition stringstream.hpp:40
flecs::stringstream::~stringstream
~stringstream()
Destructor.
Definition stringstream.hpp:15