Jive reference manual
List of all members | Public Member Functions
jem::BasicString Class Reference

Helps the String class converting various types of strings. More...

#include <jem/base/String.h>

Public Member Functions

 BasicString (const char *str)
 Character array conversion constructor. More...
 
 BasicString (const char *str, int n)
 String conversion constructor. More...
 
 BasicString (const String &str)
 String conversion constructor. More...
 
char operator[] (int i) const
 BasicString subscript operator. More...
 
int size () const
 Returns the size of this BasicString. More...
 

Detailed Description

The BasicString class is used by the String class to convert null-terminated character arrays and String objects to a common representation. It is a light-weight class that contains just a pointer to a character array and an integer specifying the length of that array. The instantiation of a BasicString object is therefore a cheap operation.

This class is normally instantiated implicitly by the compiler using one of the conversion constructors.

Constructor & Destructor Documentation

jem::BasicString::BasicString ( const char *  str)

Creates a BasicString from a null-terminated character array

Parameters
str- a null-terminated character array or NULL.
jem::BasicString::BasicString ( const char *  str,
int  n 
)

Creates a BasicString from the first n elements in the character array str.

Parameters
str- a null-terminated character array of length n. If n is zero, str may be NULL.
n- the length of the character array str.
Precondition
n >= 0
Postcondition
this->size() == n
jem::BasicString::BasicString ( const String str)

Creates a BasicString from the String str.

Parameters
str- a String object.
Postcondition
this->size() == str.size()

Member Function Documentation

char jem::BasicString::operator[] ( int  i) const

Returns the i-th character of this BasicString.

Parameters
i- the character index.
Returns
The i-th character of this BasicString.
Precondition
i >= 0 && i < this->size()
int jem::BasicString::size ( ) const
Returns
The number of characters in this BasicString.