Klang C++ 0.7.15
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 1078 of file klang.h.

Member Function Documentation

◆ c_str()

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

Definition at line 1089 of file klang.h.

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

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

◆ capacity()

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

Definition at line 1083 of file klang.h.

1083{ return SIZE; }

◆ from()

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

Definition at line 1092 of file klang.h.

1092 {
1093 Text text;
1094 text = in;
1095 return text;
1096 }

◆ operator const char *()

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

Definition at line 1086 of file klang.h.

1086{ return string; }

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

◆ operator!=()

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

Definition at line 1110 of file klang.h.

1110 {
1111 return !operator==(in);
1112 }
bool operator==(const char *in) const
Returns true if Text matches the given C-string.
Definition klang.h:1105

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

◆ operator=()

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

Definition at line 1099 of file klang.h.

1099 {
1100 memcpy(string, in, SIZE);
1101 string[SIZE] = 0;
1102 }

◆ operator==()

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

Definition at line 1105 of file klang.h.

1105 {
1106 return strcmp(string, in) == 0;
1107 }

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

Member Data Documentation

◆ string

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

Definition at line 1080 of file klang.h.

1080{ 0 };

Referenced by klang::Text< SIZE >::c_str(), and klang::Text< SIZE >::operator const char *().