VizKit  3.3.7
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
VizKit::VisualString Class Reference

Unicode string without styling or formatting information. More...

#include <VisualString.h>

Inheritance diagram for VizKit::VisualString:
VizKit::VisualObject VizKit::VisualStyledString

List of all members.

Classes

struct  VisualStringSubstringPointer
 Substring of the VisualString with start position and length. More...

Public Member Functions

 VisualString ()
 The constructor.
 VisualString (const char *const aStringVal, sint32 numberOfBytes=-1)
 A constructor that constructs a VisualString with a pointer to an UTF-8 string and the number of bytes of the string.
 VisualString (const uint16 *const aStringVal, sint32 aNumberOfCharacters=-1)
 A constructor that constructs a VisualString with a pointer to a wchar_t string and the number of characters of the string.
 VisualString (ConstStringDataRef aStringVal)
 A constructor that constructs a VisualString from a ConstStringDataRef.
void initWithUTF8String (const char *const aStringVal)
 Initializes a VisualString with a pointer to an UTF-8 string.
void initWithUTF8Buffer (const char *const aStringVal, size_t numberOfBytes)
 Initializes a VisualString with a pointer to an UTF-8 string buffer.
void initWithUTF16String (const uint16 *const aStringVal)
 Initializes a VisualString with a pointer to an UTF-16 string.
void initWithUTF16Buffer (const uint16 *const aStringVal, size_t aNumberOfCharacters)
 Initializes a VisualString with a pointer to an UTF-16 string buffer.
bool initWithContentsOfFile (VisualFile &aFile)
 Initializes a VisualString from the contents of a file.
bool initWithContentsOfURL (const char *const aURL, const VisualItemIdentifier &anId)
 Initializes a VisualString with the contents of a URL.
bool initWithConstStringDataRef (ConstStringDataRef constStringDataRef)
 Initializes a VisualString with a platform native string data type (CFStringRef on Mac, wchar_t pointer on Windows).
 ~VisualString ()
 The destructor.
 VisualString (const VisualString &other)
 Copy constructor.
VisualStringoperator= (const VisualString &other)
 Assignment operator.
bool operator< (const VisualString &other) const
 Less than operator.
bool operator== (const VisualString &other) const
 Equality operator.
bool operator!= (const VisualString &other) const
 Inequality operator.
const VisualStringoperator+ (const VisualString &other)
 Plus operator appends another string.
const VisualStringoperator+ (const char *charString)
 Plus operator appends an 8-bit char string.
virtual VisualStringclone (void) const
 Copies the current VisualString and returns a pointer to a new VisualString.
void clear (void)
 Resets internally used variables and releases allocated memory.
size_t getNumberOfCharacters (void) const
 Returns the number of characters of the string.
uint32 getNumberOfNonWhitespaceCharacters (void) const
 Returns the number of non-whitespace characters of the string.
bool isEmpty (void) const
 Returns true if the number of non-whitespace characters of the string is 0.
uint32 getNumberOfWords (void) const
 Returns the number of words of the string.
uint32 getNumberOfLines (void) const
 Returns the number of lines of the string.
VisualStringcreateStringWithLine (uint32 index) const
 Returns one line of the string.
VisualStringcreateStringWithWord (uint32 index) const
 Returns one word of the string.
ConstStringDataRef getCharactersPointer (void) const
 Returns a pointer to the internal string data.
const char *const getUtf8Representation (void)
 Returns a pointer to a char buffer with utf-8 encoded string data.
const uint16 *const getUtf16Representation (void)
 Returns a pointer to a 16-bit buffer with utf-16 encoded string data.
VisualString getSubstring (uint32 startIdx, uint32 numberOfSubstringCharacters) const
 Returns a substring of the VisualString.
void normalizeLineEndings ()
 Normalizes the line endings of the string.
void writeDebugLog (void) const
 Writes information about the VisualString to the log file.
std::vector< VisualStringsplitWithDelimiter (const VisualString &delimiter)
 Returns an array of strings by splitting the string with a separator string (delimiter).
void trim (void)
 Remove whitespace characters from the start and end of the string.
virtual void dataLoadDidEnd (const VisualItemIdentifier &identifier)
 Notification that the loading of data ended.

Static Public Member Functions

static VisualStringcreateJoinedString (std::vector< VisualString > stringVector)
 Joins the strings of the vector to create a joined string.
static VisualStringcreateWithUTF8String (const char *const aStringVal)
 Creates a VisualString from a pointer to an UTF-8 string.
static VisualStringcreateWithUTF8Buffer (const char *const aStringVal, uint32 numberOfBytes)
 Creates a VisualString from a pointer to an UTF-8 string buffer.
static VisualStringcreateWithUTF16String (const uint16 *const aStringVal)
 Creates a VisualString from a pointer to an UTF-16 string.
static VisualStringcreateWithUTF16Buffer (const uint16 *const aStringVal, uint32 aNumberOfCharacters)
 Creates a VisualString from a pointer to an UTF-16 string buffer.
static VisualStringcreateWithContentsOfFile (VisualFile &aFile)
 Creates a VisualString from the contents of a file.
static VisualStringcreateWithContentsOfURL (const char *const aURL, const VisualItemIdentifier &anId)
 Creates a VisualString with the contents of a URL.
static VisualStringcreateWithConstStringDataRef (ConstStringDataRef constStringDataRef)
 Creates a VisualString with a platform native string data type (CFStringRef on Mac, wchar_t pointer on Windows).

Protected Member Functions

void copy (const VisualString &other)
 Copy method for assignment operator and copy constructor.

Private Types

typedef std::vector
< VisualStringSubstringPointer
ArrayOfSubstringPointers
 VisualStringSubstringPointers can be collected in a vector of structs.

Private Member Functions

void calcStatistics (void)
 The number of lines and words are calculated and stored internally.
uint16 getCharacterAtIndex (size_t index) const
 Returns a single character of the string data.
bool characterIsNewlineCharacter (uint16 character)
 Returns true if character is new line character.
bool characterIsWhitespaceCharacter (uint16 character)
 Returns true if character is whitespace character.

Private Attributes

StringDataRef theString
 A pointer to the internally stored string data.
char * utf8representation
 Optionally available utf-8 representation of string data.
uint16utf16representation
 Optionally available utf-16 representation of string data.
size_t numberOfCharacters
 The number of characters of the string.
uint32 numberOfNonWhitespaceCharacters
 The number of characters of the string.
uint32 numberOfWords
 The number of words of the string.
uint32 numberOfLines
 The number of lines of the string.
ArrayOfSubstringPointers arrayOfLines
 The lines (rows) of the VisualString collected as substrings.
ArrayOfSubstringPointers arrayOfWords
 The words of the VisualString collected as substrings.

Detailed Description

Unicode string without styling or formatting information.


Member Typedef Documentation

VisualStringSubstringPointers can be collected in a vector of structs.


Constructor & Destructor Documentation

The constructor.

VisualString::VisualString ( const char *const  aStringVal,
sint32  numberOfBytes = -1 
)

A constructor that constructs a VisualString with a pointer to an UTF-8 string and the number of bytes of the string.

Parameters:
aStringValA pointer to the UTF-8 encoded char string value.
numberOfBytesOptional indication of number of bytes of the char string.
Remarks:
If the number of bytes is not specified, the string must be terminated with a NULL byte. The number of bytes is evaluated by calling strlen() then.
VisualString::VisualString ( const uint16 *const  aStringVal,
sint32  aNumberOfCharacters = -1 
)

A constructor that constructs a VisualString with a pointer to a wchar_t string and the number of characters of the string.

Parameters:
aStringValA pointer to the wchar_t string value.
aNumberOfCharactersThe number of characters of the char string.
Remarks:
If the number of characters is not specified, the string must be terminated with a NULL byte. The number of characters is evaluated by calling sizeof() then.
VisualString::VisualString ( ConstStringDataRef  aStringVal)

A constructor that constructs a VisualString from a ConstStringDataRef.

Parameters:
aStringValA string value in ConstStringDataRef data format.
Remarks:
ConstStringDataRef is the cross-platform data format of VisualString's internal string buffer.

The destructor.

Copy constructor.

Parameters:
otherAnother VisualString.

Member Function Documentation

void VisualString::calcStatistics ( void  ) [private]

The number of lines and words are calculated and stored internally.

bool VisualString::characterIsNewlineCharacter ( uint16  character) [private]

Returns true if character is new line character.

Parameters:
characterThe character to inspect.
Returns:
True if character is new line character, false if not.

Returns true if character is whitespace character.

Parameters:
characterThe character to inspect.
Returns:
True if character is whitespace character, false if not.
void VisualString::clear ( void  )

Resets internally used variables and releases allocated memory.

VisualString * VisualString::clone ( void  ) const [virtual]

Copies the current VisualString and returns a pointer to a new VisualString.

Implements VizKit::VisualObject.

Reimplemented in VizKit::VisualStyledString.

void VisualString::copy ( const VisualString other) [protected]

Copy method for assignment operator and copy constructor.

Parameters:
otherAnother VisualString.
VisualString * VisualString::createJoinedString ( std::vector< VisualString stringVector) [static]

Joins the strings of the vector to create a joined string.

The items of the vector are separated by newline.

Parameters:
stringVectorThe vector of strings.
Returns:
A VisualString.

Returns one line of the string.

Parameters:
indexThe requested line number. The first line has an index of 0.
Returns:
One line of the string.
Remarks:
The caller has to delete the VisualString.

Returns one word of the string.

Parameters:
indexThe requested index number. The first word has an index of 0.
Returns:
One word of the string.
Remarks:
The caller has to delete the VisualString.
VisualString * VisualString::createWithConstStringDataRef ( ConstStringDataRef  constStringDataRef) [static]

Creates a VisualString with a platform native string data type (CFStringRef on Mac, wchar_t pointer on Windows).

Parameters:
constStringDataRefOn Mac a CFStringRef, on Windows a wchar_t pointer.

Creates a VisualString from the contents of a file.

Parameters:
aFileReference to a file.
Remarks:
The file is opened, the content is read as a string, then the file is closed again.
VisualString * VisualString::createWithContentsOfURL ( const char *const  aURL,
const VisualItemIdentifier anId 
) [static]

Creates a VisualString with the contents of a URL.

Parameters:
aURLA URL (aka URI).
anIdAn identifier.
VisualString * VisualString::createWithUTF16Buffer ( const uint16 *const  aStringVal,
uint32  aNumberOfCharacters 
) [static]

Creates a VisualString from a pointer to an UTF-16 string buffer.

Parameters:
aStringValA pointer to the UTF-16 encoded char string buffer.
aNumberOfCharactersThe number of characters of the UTF-16 encoded char string buffer.
Remarks:
The caller has to delete the VisualString.
VisualString * VisualString::createWithUTF16String ( const uint16 *const  aStringVal) [static]

Creates a VisualString from a pointer to an UTF-16 string.

Parameters:
aStringValA pointer to the UTF-16 encoded char string value.
Remarks:
The string must be terminated with a NULL byte. The caller has to delete the VisualString.
VisualString * VisualString::createWithUTF8Buffer ( const char *const  aStringVal,
uint32  numberOfBytes 
) [static]

Creates a VisualString from a pointer to an UTF-8 string buffer.

Parameters:
aStringValA pointer to the UTF-8 encoded char string buffer.
numberOfBytesThe number of bytes of the UTF-8 encoded char string buffer.
Remarks:
The caller has to delete the VisualString.
VisualString * VisualString::createWithUTF8String ( const char *const  aStringVal) [static]

Creates a VisualString from a pointer to an UTF-8 string.

Parameters:
aStringValA pointer to the UTF-8 encoded char string value.
Remarks:
The string must be terminated with a NULL byte. The caller has to delete the VisualString.
void VisualString::dataLoadDidEnd ( const VisualItemIdentifier identifier) [virtual]

Notification that the loading of data ended.

Parameters:
identifierThe identifier of the data load request.

Reimplemented from VizKit::VisualObject.

uint16 VisualString::getCharacterAtIndex ( size_t  index) const [private]

Returns a single character of the string data.

Parameters:
indexThe position of the character in the string. First position starts with 0.
Returns:
A single character of the string data.
ConstStringDataRef VisualString::getCharactersPointer ( void  ) const

Returns a pointer to the internal string data.

Returns:
A pointer to the internal string data.
Remarks:
On Mac the string data is stored as a CFString. On Windows the string data is stored as a wchar_t type.
size_t VisualString::getNumberOfCharacters ( void  ) const

Returns the number of characters of the string.

Returns:
The number of characters of the string.
Remarks:
The number of characters are not the number of bytes in memory but the number of glyphs or code points.

Returns the number of lines of the string.

Returns:
The number of lines of the string.
Remarks:
The number of lines is evaluated by counting the number of lines that contain at least one non-whitespace character.

Returns the number of non-whitespace characters of the string.

Returns:
The number of non-whitespace characters of the string.

Returns the number of words of the string.

Returns:
The number of words of the string.
VisualString VisualString::getSubstring ( uint32  startIdx,
uint32  numberOfSubstringCharacters 
) const

Returns a substring of the VisualString.

Parameters:
startIdxThe 0-based start index of the requested substring.
numberOfSubstringCharactersThe number of characters to include in the substring.

Returns a pointer to a 16-bit buffer with utf-16 encoded string data.

Returns:
A pointer to a 16-bit buffer with utf-16 encoded string data.
Remarks:
The memory is owned by VisualString and deallocated on destruct of VisualString instance.
const char *const VisualString::getUtf8Representation ( void  )

Returns a pointer to a char buffer with utf-8 encoded string data.

Returns:
A pointer to a char buffer with utf-8 encoded string data.
Remarks:
The memory is owned by VisualString and deallocated on destruct of VisualString instance.
bool VisualString::initWithConstStringDataRef ( ConstStringDataRef  constStringDataRef)

Initializes a VisualString with a platform native string data type (CFStringRef on Mac, wchar_t pointer on Windows).

Parameters:
constStringDataRefOn Mac a CFStringRef, on Windows a wchar_t pointer.

Initializes a VisualString from the contents of a file.

Parameters:
aFileReference to a file.
Returns:
True on success, false on failure.
Remarks:
The file is opened, the content is read as an UTF-8 encoded string, then the file is closed again.
bool VisualString::initWithContentsOfURL ( const char *const  aURL,
const VisualItemIdentifier anId 
)

Initializes a VisualString with the contents of a URL.

Parameters:
anIdAn identifier.
aURLA URL (aka URI).
void VisualString::initWithUTF16Buffer ( const uint16 *const  aStringVal,
size_t  aNumberOfCharacters 
)

Initializes a VisualString with a pointer to an UTF-16 string buffer.

Parameters:
aStringValA pointer to the UTF-16 encoded char string buffer.
aNumberOfCharactersThe number of characters of the UTF-16 encoded char string buffer.
void VisualString::initWithUTF16String ( const uint16 *const  aStringVal)

Initializes a VisualString with a pointer to an UTF-16 string.

Parameters:
aStringValA pointer to the UTF-16 encoded char string value.
Remarks:
The string must be terminated with a NULL byte.
void VisualString::initWithUTF8Buffer ( const char *const  aStringVal,
size_t  numberOfBytes 
)

Initializes a VisualString with a pointer to an UTF-8 string buffer.

Parameters:
aStringValA pointer to the UTF-8 encoded char string buffer.
numberOfBytesThe number of bytes of the UTF-8 encoded char string buffer.
void VisualString::initWithUTF8String ( const char *const  aStringVal)

Initializes a VisualString with a pointer to an UTF-8 string.

Parameters:
aStringValA pointer to the UTF-8 encoded char string value.
Remarks:
The string must be terminated with a NULL byte.
bool VisualString::isEmpty ( void  ) const

Returns true if the number of non-whitespace characters of the string is 0.

Returns:
True if the number of non-whitespace characters of the string is 0.

Normalizes the line endings of the string.

Remarks:
Line endings can be incorrect when transfering audio files from MacOS to Windows (Windows expects line ending to consist of CR+LF).
bool VisualString::operator!= ( const VisualString other) const

Inequality operator.

Parameters:
otherAnother VisualString.
const VisualString & VisualString::operator+ ( const VisualString other)

Plus operator appends another string.

Parameters:
otherAnother VisualString.
const VisualString & VisualString::operator+ ( const char *  charString)

Plus operator appends an 8-bit char string.

Parameters:
charStringPointer to 8-bit character string.
Remarks:
The charString must be NULL-terminated so that strlen can determine the correct length of the string.
bool VisualString::operator< ( const VisualString other) const

Less than operator.

Parameters:
otherAnother VisualString.
Remarks:
The less than operator is used by std::map for find() and sorting (if VisualString is used as key_type).
VisualString & VisualString::operator= ( const VisualString other)

Assignment operator.

bool VisualString::operator== ( const VisualString other) const

Equality operator.

Parameters:
otherAnother VisualString.
std::vector< VisualString > VisualString::splitWithDelimiter ( const VisualString delimiter)

Returns an array of strings by splitting the string with a separator string (delimiter).

Parameters:
delimiterThe string to use as separator.
Returns:
An array with VisualStrings.
void VisualString::trim ( void  )

Remove whitespace characters from the start and end of the string.

void VisualString::writeDebugLog ( void  ) const

Writes information about the VisualString to the log file.

Remarks:
Useful for debuggin and tracing purposes.

Member Data Documentation

The lines (rows) of the VisualString collected as substrings.

The words of the VisualString collected as substrings.

The number of characters of the string.

The number of lines of the string.

The number of characters of the string.

The number of words of the string.

StringDataRef VizKit::VisualString::theString [private]

A pointer to the internally stored string data.

Optionally available utf-16 representation of string data.

Optionally available utf-8 representation of string data.


The documentation for this class was generated from the following files:

Generated on Sun May 3 2015 20:26:31 for VizKit by doxygen 1.8.0