FUStringBuilderT< Char, SPrintF > Class Template Reference
[Utility Classes.]

A dynamically-sized string object. More...

#include <FUStringBuilder.h>

List of all members.

Public Types

typedef std::basic_string<
Char > 
String
 The standard string object which correspond to the builder.

Public Member Functions

 FUStringBuilderT (const String &sz)
 Creates a new builder with the content of the given string.
 FUStringBuilderT (const Char *sz)
 Creates a new builder with the content of the given character array.
 FUStringBuilderT (Char ch, size_t count)
 Creates a new builder with the given character repeated multiple times over the array.
 FUStringBuilderT (size_t reserved)
 Creates a new builder with an empty buffer.
 FUStringBuilderT ()
 Creates a new builder with an empty buffer.
 ~FUStringBuilderT ()
 Deletes the builder.
void reserve (size_t length)
 Reserves a given number of character slots.
size_t length ()
 Retrieves the length of the content within the builder.
void clear ()
 Clears the content of the builder.
bool empty ()
 Retrieves whether the builder is empty.
void append (Char c)
 Appends a character to the content of the builder.
void append (const String &sz)
 Appends a string to the content of the builder.
void append (const Char *sz)
 Appends a character array to the content of the builder.
void append (const FUStringBuilderT &b)
 Appends the content of a builder to the content of this builder.
void append (int32 i)
 Appends the integer value, after converting it to a string, to the content of the builder.
void append (uint32 i)
 See above.
void append (uint64 i)
 See above.
void append (int i)
 See above.
void append (unsigned int i)
 See above.
void append (float f)
 Appends the floating-point value, after converting it to a string, to the content of the builder.
void append (double f)
 See above.
template<typename TYPE>
FUStringBuilderToperator+= (const TYPE &val)
 Appends a value to the content of the builder.
void appendLine (const Char *sz)
 Appends a character array to the content of the builder.
void remove (int32 start)
 Removes a section of the content of the builder.
void remove (int32 start, int32 end)
 Removes a section of the content of the builder.
void pop_back ()
 Removes the last character of the content of the builder.
template<typename TYPE>
void set (const TYPE &val)
 Sets the content of the builder to a given value.
template<typename TYPE>
FUStringBuilderToperator= (const TYPE &val)
 See above.
String ToString ()
 Converts the content of the builder to a standard string.
 operator String ()
 See above.
const Char * ToCharPtr ()
 Converts the content of the builder to a character array.
 operator const Char * ()
 See above.
int32 index (Char c)
 Retrieves the index of the first character within the content of the builder that is equivalent to the given character.
int32 rindex (Char c)
 Retrieves the index of the last character within the content of the builder that is equivalent to the given character.


Detailed Description

template<class Char, class SPrintF>
class FUStringBuilderT< Char, SPrintF >

A dynamically-sized string object.

The template has two arguments: the character definition and the sprintf() functor class for float to string conversions.

This class should be used for all the string operations, as it contains a dynamically-resized buffer that is not directly tied to its content's length.


Constructor & Destructor Documentation

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::FUStringBuilderT const String sz  ) 
 

Creates a new builder with the content of the given string.

Parameters:
sz A string. Its content will be copied within the builder.

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::FUStringBuilderT const Char *  sz  ) 
 

Creates a new builder with the content of the given character array.

Parameters:
sz A character array. Its content will be copied within the builder. It must terminate with an element containing the 'zero' value.

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::FUStringBuilderT Char  ch,
size_t  count
 

Creates a new builder with the given character repeated multiple times over the array.

Parameters:
ch A character to repeat.
count The number of times to repeat the given character.

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::FUStringBuilderT size_t  reserved  ) 
 

Creates a new builder with an empty buffer.

See also:
reserve
Parameters:
reserved The number of character slots to reserve within the empty buffer.

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::~FUStringBuilderT  ) 
 

Deletes the builder.

Its buffer will be cleared. Any pointers to its data will be dangling.


Member Function Documentation

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append float  f  ) 
 

Appends the floating-point value, after converting it to a string, to the content of the builder.

If the floating-point value is the special token that represents infinity, the string "INF" is appended. If it represents the negative infinity, the string "-INF" is appended. If it represents the impossibility, the string "NaN" is appended.

Parameters:
f A floating-point value.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append int32  i  ) 
 

Appends the integer value, after converting it to a string, to the content of the builder.

Parameters:
i An integer value.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append const FUStringBuilderT< Char, SPrintF > &  b  ) 
 

Appends the content of a builder to the content of this builder.

Parameters:
b A string builder.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append const Char *  sz  ) 
 

Appends a character array to the content of the builder.

Parameters:
sz A character array. It must terminate with an element containing the 'zero' value.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append const String sz  ) 
 

Appends a string to the content of the builder.

Parameters:
sz A string.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::append Char  c  ) 
 

Appends a character to the content of the builder.

Parameters:
c A character. May not be the 'zero' value.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::appendLine const Char *  sz  ) 
 

Appends a character array to the content of the builder.

A newline character will be appended after the character array.

Parameters:
sz A character array. It must terminate with an element containing the 'zero' value.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::clear  ) 
 

Clears the content of the builder.

This does not re-allocate a new buffer.

template<class Char, class SPrintF>
bool FUStringBuilderT< Char, SPrintF >::empty  )  [inline]
 

Retrieves whether the builder is empty.

A builder is considered empty when it has no content, regardless of the size or allocation status of its buffer.

Returns:
Whether the builder is empty.

template<class Char, class SPrintF>
int32 FUStringBuilderT< Char, SPrintF >::index Char  c  ) 
 

Retrieves the index of the first character within the content of the builder that is equivalent to the given character.

Parameters:
c The character to match.
Returns:
The index of the first equivalent character. -1 is returned if no character matches the given character.

template<class Char, class SPrintF>
size_t FUStringBuilderT< Char, SPrintF >::length  )  [inline]
 

Retrieves the length of the content within the builder.

Returns:
The length of the string.

template<class Char, class SPrintF>
template<typename TYPE>
FUStringBuilderT& FUStringBuilderT< Char, SPrintF >::operator+= const TYPE &  val  )  [inline]
 

Appends a value to the content of the builder.

This is a shortcut for the append function.

See also:
append
Parameters:
val A value. This may be numerical, a character, a character array or a string.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::remove int32  start,
int32  end
 

Removes a section of the content of the builder.

The substring defined by the 'start' and 'end' indices will be removed. The 'start' character is removed and is replaced by the 'end' character.

Parameters:
start The index of the first character of the substring to remove.
end The index of the first character after the removed substring.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::remove int32  start  ) 
 

Removes a section of the content of the builder.

Every character that occurs after the given index will be removed, resulting in a shrunk string.

Parameters:
start An index within the content of the builder.

template<class Char, class SPrintF>
void FUStringBuilderT< Char, SPrintF >::reserve size_t  length  ) 
 

Reserves a given number of character slots.

If the builder has a buffer with a different number of character slots, a new buffer will be allocated. If the builder has contents, it will be copied within the new buffer. If there is more content than the new buffer can handle, it will be discarded.

Parameters:
length The number of character slots to reserve.

template<class Char, class SPrintF>
int32 FUStringBuilderT< Char, SPrintF >::rindex Char  c  ) 
 

Retrieves the index of the last character within the content of the builder that is equivalent to the given character.

Parameters:
c The character to match.
Returns:
The index of the last equivalent character. -1 is returned if no character matches the given character.

template<class Char, class SPrintF>
template<typename TYPE>
void FUStringBuilderT< Char, SPrintF >::set const TYPE &  val  )  [inline]
 

Sets the content of the builder to a given value.

This clears the builder of all its content and appends the given value.

Parameters:
val A value. This may be numerical, a character, a character array or a string.

template<class Char, class SPrintF>
const Char * FUStringBuilderT< Char, SPrintF >::ToCharPtr  ) 
 

Converts the content of the builder to a character array.

Returns:
A character array with the content of the builder. This pointer is valid for the lifetime of the buffer of the builder, so do not keep it around. This character array should not be modified.

template<class Char, class SPrintF>
FUStringBuilderT< Char, SPrintF >::String FUStringBuilderT< Char, SPrintF >::ToString  ) 
 

Converts the content of the builder to a standard string.

Returns:
A string with the content of the builder.


The documentation for this class was generated from the following files:
Generated on Fri May 12 16:44:44 2006 for FCollada by  doxygen 1.4.6-NO