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

A null-terminated string. More...

#include <CString.hpp>

Public Member Functions

 CString (const char *s)
 Constructs the object from a given null-terminated string.
 ~CString ()
 Free the internal buffer since it is allocated on the heap.
CStringcopy (this const CString &self, CString &dest, Typing::USize chars)
 Copies somes bytes from the internal buffer to another string's internal buffer.
bool has (this const CString &self, char ch)
 Checks if this string contains a given character.
Typing::USize length (this const CString &self)
 Computes the length of this string.
const char * begin (this const CString &self)
 Gets a pointer to the base of the internal buffer.
const char * end (this const CString &self)
 Gets a pointer to the end of the internal buffer.
const char * get (this const CString &self)
 Gets the internal buffer.
bool operator== (this const CString &self, const CString &other)
 Checks if a string is the same than this one.
bool operator!= (this const CString &self, const CString &other)
 Checks if a string is different to this one.
bool operator< (this const CString &self, const CString &other)
 Checks if this string is smaller than another.
bool operator> (this const CString &self, const CString &other)
 Checks if this string is bigger than another.
bool operator<= (this const CString &self, const CString &other)
 Checks if this string is smaller than or equals another.
bool operator>= (this const CString &self, const CString &other)
 Checks if this string is bigger than or equals another.
char & operator[] (this CString &self, Typing::USize index)
 Gets a character by its index in the string.

Detailed Description

A null-terminated string.

This kind of string is not intended to be extended or shortened. Its size should be always the same.

Constructor & Destructor Documentation

◆ CString()

Melon::Memory::CString::CString ( const char * s)

Constructs the object from a given null-terminated string.

The internal buffer is allocated on the heap.

Parameters
snull-terminated string

Member Function Documentation

◆ copy()

CString & Melon::Memory::CString::copy ( this const CString & self,
CString & dest,
Typing::USize chars )

Copies somes bytes from the internal buffer to another string's internal buffer.

Parameters
otherdestination string
charscharacter count
Returns
destination string

◆ get()

const char * Melon::Memory::CString::get ( this const CString & self)

Gets the internal buffer.

Returns
internal buffer (constant)

◆ has()

bool Melon::Memory::CString::has ( this const CString & self,
char ch )

Checks if this string contains a given character.

Parameters
chcharacter to find
Returns
boolean

◆ length()

Typing::USize Melon::Memory::CString::length ( this const CString & self)

Computes the length of this string.

The null-terminating character is not treated as a part of the string.

Returns
string length

◆ operator!=()

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

Checks if a string is different to this one.

Parameters
otherstring to compare
Returns
boolean

◆ operator<()

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

Checks if this string is smaller than another.

Parameters
otherstring to compare
Returns
boolean

◆ operator<=()

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

Checks if this string is smaller than or equals another.

Parameters
otherstring to compare
Returns
boolean

◆ operator==()

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

Checks if a string is the same than this one.

Parameters
otherstring to compare
Returns
boolean

◆ operator>()

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

Checks if this string is bigger than another.

Parameters
otherstring to compare
Returns
boolean

◆ operator>=()

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

Checks if this string is bigger than or equals another.

Parameters
otherstring to compare
Returns
boolean

◆ operator[]()

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

Gets a character by its index in the string.

Parameters
indexcharacter position
Returns
character at given position

The documentation for this class was generated from the following files:
  • Include/Internal/Memory/CString.hpp
  • Source/Memory/CString.cpp