112 return length((
const char *) str);
138 buffer =
new char[
size];
203 for (
Size i = 0; i < len; i++)
242 const bool caseSensitive,
243 const Size count)
const
245 const char *dest =
m_string, *src = str;
248 while (*dest && *src)
250 if (
count && n-1 == 0)
253 if (( caseSensitive && *dest != *src) ||
270 const char *end =
ZERO;
272 while (*
string && *mask)
289 for (; *string;
string++)
291 const char *s = string, *m = mask;
293 while (*s && *m && *s == *m)
302 else if (*
string != *mask)
305 if (*
string)
string++;
311 return (*
string == *mask);
410 const char str[] = { delimiter,
ZERO };
420 Size from = 0, i = 0;
423 char *saved =
copy.m_string;
442 copy.m_string++, i++;
452 copy.m_string = saved;
459 long acc = 0, cutoff;
460 bool negative =
false;
461 int cutlim, basenum = 10;
477 negative =
true; s++;
481 if (basenum == 16 && s[0] ==
'0' && s[1] ==
'x')
486 cutlim = cutoff % basenum;
499 unsigned char c = (
unsigned char) *s++;
513 if (acc < cutoff || (acc == cutoff && c > cutlim))
521 if (acc > cutoff || (acc == cutoff && c > cutlim))
543 volatile char *p, *p1, *p2, *saved, tmp;
544 unsigned long ud = number;
545 int remainder, divisor = 10;
563 if (sign && (
long)number < 0)
581 remainder = ud % divisor;
582 *p++ = (remainder < 10) ? remainder +
'0' : remainder +
'a' - 10;
584 while (ud /= divisor);
Simple linked list template class.
void append(T t)
Insert an item at the end of the list.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
const char * operator*() const
Dereference operator (read-only).
Number::Base m_base
Number format to use for convertions.
bool startsWith(const String &prefix) const
Tests if this String starts with the specified prefix.
virtual Size count() const
Number of characters in the string.
String & trim()
Remove leading and trailing whitespace from the String.
Size m_size
Size of the string buffer, including any NULL byte(s) at the end.
long toLong(const Number::Base base=Number::Dec) const
Convert the String to a signed long integer.
virtual bool equals(const String &str) const
Alias for compareTo().
String substring(const Size index, const Size size=0) const
Returns a part of the String as a copy.
String & operator<<(const char *str)
Append character string to the String.
Size length() const
Same as count().
Size setUnsigned(const ulong number, const Number::Base base=Number::Dec, char *string=ZERO, const bool sign=false)
Set text-representation of an unsigned number.
virtual bool reserve(const Size count)
Make sure at least given number of bytes available.
Size set(const long number, const Number::Base base=Number::Dec, char *string=ZERO)
Set text-representation of a signed number.
virtual bool contains(const char character) const
Check if the given character occurs in the String.
virtual const char * get(const Size position) const
Returns the item at the given position.
bool endsWith(const String &suffix) const
Tests if this String ends with the specified suffix.
char * m_string
Current value of the String.
String()
Default constructor.
virtual Size size() const
Calculates the length of the String.
String & lower()
Convert all Characters to lower case.
void operator=(const char *str)
Assignment operator.
String & pad(const Size length)
Pad line with trailing whitespace.
bool operator==(const String &str) const
Comparision operator.
Size m_count
Length of the string text, excluding NULL byte(s) at the end.
virtual int compareTo(const String &str) const
Compares this String to the given String.
virtual ~String()
Destructor.
bool operator!=(const String &str) const
Inequal operator.
List< String > split(const char delimiter) const
Split the String into parts separated by a delimiter.
String & upper()
Convert all Characters to upper case.
virtual const char & at(const Size position) const
Returns a reference to the item at the given position.
bool match(const char *mask) const
Matches the String against a mask.
bool m_allocated
True if the string buffer is a deep copy, false otherwise.
virtual const char value(const Size position) const
Return value at the given position.
virtual bool resize(const Size size)
Change the size of the String buffer.
#define STRING_DEFAULT_SIZE
Default maximum length of a String's value.
#define LONG_MAX
Maximum value of an object of type long int.
unsigned long ulong
Unsigned long number.
unsigned int Size
Any sane size indicator cannot go negative.
#define LONG_MIN
Minimum value of an object of type long int.
void copy(Terminal *term, const teken_rect_t *rect, const teken_pos_t *pos)
Copy bytes to the terminal.
bool isAlpha(char c)
Test for an alphabetic character.
char upper(char c)
Converts the letter c to uppercase.
bool isWildcard(char c)
Test for a wildcard character.
bool isDigit(char c)
Test for a decimal digit.
bool isWhitespace(char c)
Test for a white-space character.
bool isUpper(char c)
Test for an uppercase letter.
char lower(char c)
Converts the letter c to lowercase.
Base
Numeral system base type.