PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Public Member Functions | Static Public Attributes | List of all members
PropWare::StringBuilder Class Reference

Build a dynamically-sized string in RAM using the PropWare::Printer interface. More...

#include <PropWare/string/stringbuilder.h>

+ Inheritance diagram for PropWare::StringBuilder:
+ Collaboration diagram for PropWare::StringBuilder:

Public Member Functions

 StringBuilder (const size_t initialSize=DEFAULT_SPACE_ALLOCATED)
 Initialize with a given size to start with. Picking the correct size can increase performance. More...
 
 ~StringBuilder ()
 Free all memory allocated for the string buffer.
 
void put_char (const char c)
 Print a single character. More...
 
void puts (const char string[])
 Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them. More...
 
const charto_string () const
 Retrieve the address of the string buffer.
 
uint16_t get_size () const
 Determine the length of the string, not including the null terminator.
 
void clear ()
 Remove all characters from the string and reallocate to the original size (if needed)
 

Static Public Attributes

static const uint16_t DEFAULT_SPACE_ALLOCATED = 64
 

Detailed Description

Build a dynamically-sized string in RAM using the PropWare::Printer interface.

Examples
StringBuilder_Demo.cpp.

Definition at line 37 of file stringbuilder.h.

Constructor & Destructor Documentation

◆ StringBuilder()

PropWare::StringBuilder::StringBuilder ( const size_t  initialSize = DEFAULT_SPACE_ALLOCATED)

Initialize with a given size to start with. Picking the correct size can increase performance.

Parameters
[in]initialSizeNumber of bytes that should be (dynamically) allocated for the string buffer

Definition at line 47 of file stringbuilder.h.

Member Function Documentation

◆ put_char()

void PropWare::StringBuilder::put_char ( const char  c)
virtual

Print a single character.

Parameters
[in]cIndividual char to be printed

Implements PropWare::PrintCapable.

Definition at line 62 of file stringbuilder.h.

◆ puts()

void PropWare::StringBuilder::puts ( const char  string[])
virtual

Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them.

Precondition
string[] must be terminated with a null terminator
Parameters
[in]string[]Array of data words with the final word being 0 - the null terminator

Implements PropWare::PrintCapable.

Definition at line 70 of file stringbuilder.h.


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