Melon
A C++ library designed for RadishOS.
Loading...
Searching...
No Matches
Melon::String::String Class Reference

A dynamic string. More...

#include <String.hpp>

Public Member Functions

 String (const char *s)
 Constructs the string from a raw char pointer.
 String (const String &other)
 Copy constructor.
 String (String &&other)
 Move constructor.
String substract (this String &self, Typing::USize chars)
 Returns a substring from this string.
const char * raw (this const String &self)
 Gets a raw buffer which contains the string characters.
Typing::USize length (this const String &self)
 Gets the length of the string.
const char * begin (this const String &self)
 Gets the base of the string vector.
const char * end (this const String &self)
 Gets the end of the string vector.
void appendChar (this String &self, char ch)
 Appends a character to the string.
String reverse (this String &self)
 Reverse the string.
String ltrim (this String &self, char ch=' ')
 Removes all occurences of ch at the left of the string.
String rtrim (this String &self, char ch=' ')
 Removes all occurences of ch at the right of the string.
String trim (this String &self, char ch=' ')
 Removes all occurences of ch at the left and the right of the string.
char & operator[] (this String &self, Typing::USize index)
 Gets a character from its index.
const char & operator[] (this const String &self, Typing::USize index)
 Gets a character from its index.
bool operator== (this const String &self, const String &other)
 Checks if both strings are the same.
bool operator!= (this const String &self, const String &other)
 Checks if both strings are different.
bool operator< (this const String &self, const String &other)
 Checks if this string is smaller than another.
bool operator> (this const String &self, const String &other)
 Checks if this string is bigger than another.
bool operator<= (this const String &self, const String &other)
 Checks if this string is smaller than another or if both have the same size.
bool operator>= (this const String &self, const String &other)
 Checks if this string is bigger than another or if both have the same size.
String operator+ (this const String &self, const String &other)
 Creates a new string by concatenating this string and another.
String & operator= (this String &self, const String &other)
 Copy assignment operator.
String & operator= (this String &self, String &&other)
 Move assignment operator.
String & operator+= (this String &self, const String &other)
 Concatenate two strings.

Detailed Description

A dynamic string.

Constructor & Destructor Documentation

◆ String() [1/3]

Melon::String::String::String ( const char * s)

Constructs the string from a raw char pointer.

Parameters
sraw char pointer

◆ String() [2/3]

Melon::String::String::String ( const String & other)

Copy constructor.

Parameters
otherstring to copy

◆ String() [3/3]

Melon::String::String::String ( String && other)

Move constructor.

Parameters
otherstring to move

Member Function Documentation

◆ appendChar()

void Melon::String::String::appendChar ( this String & self,
char ch )

Appends a character to the string.

Parameters
chcharacter to append

◆ begin()

const char * Melon::String::String::begin ( this const String & self)

Gets the base of the string vector.

Returns
pointer to base

◆ end()

const char * Melon::String::String::end ( this const String & self)

Gets the end of the string vector.

Returns
pointer to end

◆ length()

Typing::USize Melon::String::String::length ( this const String & self)

Gets the length of the string.

Returns
internal vector length

◆ ltrim()

String Melon::String::String::ltrim ( this String & self,
char ch = ' ' )

Removes all occurences of ch at the left of the string.

Parameters
chcharacter to remove, =' ' by default
Returns
self

◆ operator!=()

bool Melon::String::String::operator!= ( this const String & self,
const String & other )

Checks if both strings are different.

Parameters
otherstring to compare
Returns
boolean

◆ operator+()

String Melon::String::String::operator+ ( this const String & self,
const String & other )

Creates a new string by concatenating this string and another.

Parameters
otherstring to concatenate with
Returns
new string

◆ operator+=()

String & Melon::String::String::operator+= ( this String & self,
const String & other )

Concatenate two strings.

Parameters
otherstring to add
Returns
self

◆ operator<()

bool Melon::String::String::operator< ( this const String & self,
const String & other )

Checks if this string is smaller than another.

Parameters
otherstring to compare
Returns
boolean

◆ operator<=()

bool Melon::String::String::operator<= ( this const String & self,
const String & other )

Checks if this string is smaller than another or if both have the same size.

Parameters
otherstring to compare
Returns
boolean

◆ operator=() [1/2]

String & Melon::String::String::operator= ( this String & self,
const String & other )

Copy assignment operator.

Parameters
otherstring to copy
Returns
self

◆ operator=() [2/2]

String & Melon::String::String::operator= ( this String & self,
String && other )

Move assignment operator.

Parameters
otherstring to move
Returns
self

◆ operator==()

bool Melon::String::String::operator== ( this const String & self,
const String & other )

Checks if both strings are the same.

Parameters
otherstring to compare
Returns
boolean

◆ operator>()

bool Melon::String::String::operator> ( this const String & self,
const String & other )

Checks if this string is bigger than another.

Parameters
otherstring to compare
Returns
boolean

◆ operator>=()

bool Melon::String::String::operator>= ( this const String & self,
const String & other )

Checks if this string is bigger than another or if both have the same size.

Parameters
otherstring to compare
Returns
boolean

◆ operator[]() [1/2]

const char & Melon::String::String::operator[] ( this const String & self,
Typing::USize index )

Gets a character from its index.

Parameters
indexposition of the character
Returns
character

◆ operator[]() [2/2]

char & Melon::String::String::operator[] ( this String & self,
Typing::USize index )

Gets a character from its index.

Parameters
indexposition of the character
Returns
character

◆ raw()

const char * Melon::String::String::raw ( this const String & self)

Gets a raw buffer which contains the string characters.

Returns
constant char pointer

◆ reverse()

String Melon::String::String::reverse ( this String & self)

Reverse the string.

Returns
self

◆ rtrim()

String Melon::String::String::rtrim ( this String & self,
char ch = ' ' )

Removes all occurences of ch at the right of the string.

Parameters
chcharacter to remove, =' ' by default
Returns
self

◆ substract()

String Melon::String::String::substract ( this String & self,
Typing::USize chars )

Returns a substring from this string.

Parameters
charsnumber of characters to substract
Returns
substring

◆ trim()

String Melon::String::String::trim ( this String & self,
char ch = ' ' )

Removes all occurences of ch at the left and the right of the string.

Parameters
chcharacter to remove, =' ' by default
Returns
self

The documentation for this class was generated from the following files: