Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Text< SIZE >

String of characters representing text. More...

#include <klang.h>

Public Member Functions

int capacity () const
 Maximum size of the string.
 
 operator const char * () const
 Automatic cast to constant C-string.
 
const char * c_str () const
 Return constant C-string.
 
void operator= (const char *in)
 Assign C-String to Text object.
 
bool operator== (const char *in) const
 Returns true if Text matches the given C-string.
 
bool operator!= (const char *in) const
 Returns true if Text does not matches the given C-string.
 

Static Public Member Functions

static Text from (const char *in)
 Create a new Text object from a C-string.
 

Public Attributes

char string [SIZE+1] = { 0 }
 The character buffer.
 

Detailed Description

template<int SIZE>
struct klang::Text< SIZE >

Definition at line 317 of file klang.h.

Member Function Documentation

◆ c_str()

template<int SIZE>
const char * klang::Text< SIZE >::c_str ( ) const
inline

Definition at line 328 of file klang.h.

328{ return string; }
char string[SIZE+1]
The character buffer.
Definition klang.h:319

◆ capacity()

template<int SIZE>
int klang::Text< SIZE >::capacity ( ) const
inline

Definition at line 322 of file klang.h.

322{ return SIZE; }

Referenced by klang::Console::operator+=(), klang::Console::operator=(), and klang::Console::operator=().

◆ from()

template<int SIZE>
static Text klang::Text< SIZE >::from ( const char * in)
inlinestatic

Definition at line 331 of file klang.h.

331 {
332 Text text;
333 text = in;
334 return text;
335 }

Referenced by klang::Button(), klang::Dial(), klang::Meter(), klang::Slider(), and klang::Toggle().

◆ operator const char *()

template<int SIZE>
klang::Text< SIZE >::operator const char * ( ) const
inline

Definition at line 325 of file klang.h.

325{ return string; }

References klang::Text< SIZE >::string.

◆ operator!=()

template<int SIZE>
bool klang::Text< SIZE >::operator!= ( const char * in) const
inline

Definition at line 349 of file klang.h.

349 {
350 return !operator==(in);
351 }
bool operator==(const char *in) const
Returns true if Text matches the given C-string.
Definition klang.h:344

References klang::Text< SIZE >::operator==().

Referenced by klang::Debug::printOnce().

◆ operator=()

template<int SIZE>
void klang::Text< SIZE >::operator= ( const char * in)
inline

Definition at line 338 of file klang.h.

338 {
339 memcpy(string, in, SIZE);
340 string[SIZE] = 0;
341 }

References klang::Text< SIZE >::string.

Referenced by klang::Controls::add().

◆ operator==()

template<int SIZE>
bool klang::Text< SIZE >::operator== ( const char * in) const
inline

Definition at line 344 of file klang.h.

344 {
345 return strcmp(string, in) == 0;
346 }

References klang::Text< SIZE >::string.

Referenced by klang::Text< SIZE >::operator!=().

Member Data Documentation

◆ string

template<int SIZE>
char klang::Text< SIZE >::string[SIZE+1] = { 0 }