Melon
A C++ library designed for RadishOS.
Loading...
Searching...
No Matches
String.hpp
1#pragma once
2
3#include "Vector.hpp"
4#include "Typing.hpp"
5
7namespace Melon::String
8{
10 class String
11 {
13
14 public:
15 String();
16
19 String(const char *s);
20
23 String(const String &other);
24
27 String(String &&other);
28
32 String substract(this String &self, Typing::USize chars);
33
36 const char *raw(this const String &self);
37
40 Typing::USize length(this const String &self);
41
44 const char *begin(this const String &self);
45
48 const char *end(this const String &self);
49
52 void appendChar(this String &self, char ch);
53
56 String reverse(this String &self);
57
61 String ltrim(this String &self, char ch = ' ');
62
66 String rtrim(this String &self, char ch = ' ');
67
71 String trim(this String &self, char ch = ' ');
72
76 char &operator [](this String &self, Typing::USize index);
77
81 const char &operator [](this const String &self, Typing::USize index);
82
86 bool operator ==(this const String &self, const String &other);
87
91 bool operator !=(this const String &self, const String &other);
92
96 bool operator <(this const String &self, const String &other);
97
101 bool operator >(this const String &self, const String &other);
102
106 bool operator <=(this const String &self, const String &other);
107
111 bool operator >=(this const String &self, const String &other);
112
116 String operator +(this const String &self, const String &other);
117
121 String &operator =(this String &self, const String &other);
122
126 String &operator =(this String &self, String &&other);
127
131 String &operator +=(this String &self, const String &other);
132 };
133} // namespace Melon::String
String rtrim(this String &self, char ch=' ')
Removes all occurences of ch at the right of the string.
Definition String.cpp:100
bool operator!=(this const String &self, const String &other)
Checks if both strings are different.
Definition String.cpp:140
const char * begin(this const String &self)
Gets the base of the string vector.
Definition String.cpp:52
bool operator<(this const String &self, const String &other)
Checks if this string is smaller than another.
Definition String.cpp:145
bool operator<=(this const String &self, const String &other)
Checks if this string is smaller than another or if both have the same size.
Definition String.cpp:155
bool operator>=(this const String &self, const String &other)
Checks if this string is bigger than another or if both have the same size.
Definition String.cpp:160
char & operator[](this String &self, Typing::USize index)
Gets a character from its index.
Definition String.cpp:125
String reverse(this String &self)
Reverse the string.
Definition String.cpp:69
bool operator==(this const String &self, const String &other)
Checks if both strings are the same.
Definition String.cpp:135
String ltrim(this String &self, char ch=' ')
Removes all occurences of ch at the left of the string.
Definition String.cpp:89
Typing::USize length(this const String &self)
Gets the length of the string.
Definition String.cpp:47
void appendChar(this String &self, char ch)
Appends a character to the string.
Definition String.cpp:62
String & operator=(this String &self, const String &other)
Copy assignment operator.
Definition String.cpp:177
String operator+(this const String &self, const String &other)
Creates a new string by concatenating this string and another.
Definition String.cpp:165
String & operator+=(this String &self, const String &other)
Concatenate two strings.
Definition String.cpp:196
String substract(this String &self, Typing::USize chars)
Returns a substring from this string.
Definition String.cpp:30
const char * raw(this const String &self)
Gets a raw buffer which contains the string characters.
Definition String.cpp:42
const char * end(this const String &self)
Gets the end of the string vector.
Definition String.cpp:57
bool operator>(this const String &self, const String &other)
Checks if this string is bigger than another.
Definition String.cpp:150
String trim(this String &self, char ch=' ')
Removes all occurences of ch at the left and the right of the string.
Definition String.cpp:117
A linear dynamic generic container. TODO: if possible, support objects with no default constructor.
Definition Vector.hpp:13
Contains dynamic strings related features.
Definition String.hpp:8
size_t USize
Biggest unsigned type.
Definition Typing.hpp:38