String Class Reference

This class provides a set of utility functions that operate on strings. More...

#include <StringUtilities.h>

Inheritance diagram for String:

Inheritance graph
[legend]

List of all members.

Public Member Functions

Strings lines (const std::string &input, const char *separator="\n")
 Returns a vector of strings splitting the input at the specified separator.
std::string unlines (const Strings &input, const char *filler, int newlineat=1)
 Returns a string with the input strings concatenated.
Strings unlines (const Strings &input)
 Convert all '
' into in the input to new lines.
size_t maxlength (const Strings &content)
 Find the longest line in the input and return it's lenght.
std::string box (const Strings &content, const std::string &header=Global::Get()->EmptyString)
 Draw an ASCII art box around the content using the specified header.
Strings createTable (const std::vector< Strings > &content, const Strings &header)
 Creates a ASCII table out of the content using the specified header.
std::string fromInt (value_type value)
 Returns a string representation of an integer.
std::string toupper (const std::string &convertToUpper)
 Converts a string to upper case.
std::string tolower (const std::string &convertToLower)
 Converts a string to lower case.
std::vector< int > calculateMinimumFieldSizes (const std::vector< Strings > &content, int fieldcount)
 Calculates the minimum size of each field in the content using the specified fieldcount.
void rebaseMinimumFieldSizes (std::vector< int > &sizes, const Strings &header)
 Adjusts the minimum field sizes to take in account the size of the header.
void capFieldSize (std::vector< int > &sizes, const int maxlinesize)
 Cap the field sizes so that their sum is equal to or less than the specified maximum.
void capUnfairFields (std::vector< int > &sizes, int unfairFields, int maxFairSize, int slack)
 Cap the fields that are unproporitonally large using the specified attributes.
std::string packFields (const Strings &fields, const std::vector< int > &fieldsizes)
 Pack the specified fields into one string using the specified fieldsizes.

Friends

class Singleton< String >


Detailed Description

This class provides a set of utility functions that operate on strings.

Definition at line 35 of file StringUtilities.h.


Member Function Documentation

Strings String::lines ( const std::string &  input,
const char *  separator = "\n" 
)

Returns a vector of strings splitting the input at the specified separator.

Parameters:
input The input to search for the separator in.
separator The separator to serach for.
Returns:
The input, split into lines at each separator.

std::string String::unlines ( const Strings input,
const char *  filler,
int  newlineat = 1 
)

Returns a string with the input strings concatenated.

Parameters:
input The input to put together.
filler The character to put between characters parts of the input.
newlineat After how many lines of the input a newline will be added, when 0 no extra newlines will be added.

Strings String::unlines ( const Strings input  ) 

Convert all '
' into in the input to new lines.

Parameters:
input The input to search for lines containing '
'.
Returns:
The output in which lines containing '
' are split.

size_t String::maxlength ( const Strings content  ) 

Find the longest line in the input and return it's lenght.

std::string String::box ( const Strings content,
const std::string &  header = Global::Get()->EmptyString 
)

Draw an ASCII art box around the content using the specified header.

Parameters:
content The lines that should be contained inside the box.
header The header that will be put above the result (centered), will be left out if none is specified.
Returns:
One string that contains the 'boxed' content.

Strings String::createTable ( const std::vector< Strings > &  content,
const Strings header 
)

Creates a ASCII table out of the content using the specified header.

Parameters:
content The 'body' of the table, is asserted to be of same 'length' as the header.
header The header to use for the table.
Returns:
A set of strings that contain the table, each one row of the table.

std::string String::fromInt ( value_type  value  ) 

Returns a string representation of an integer.

std::string String::toupper ( const std::string &  convertToUpper  ) 

Converts a string to upper case.

std::string String::tolower ( const std::string &  convertToLower  ) 

Converts a string to lower case.

std::vector<int> String::calculateMinimumFieldSizes ( const std::vector< Strings > &  content,
int  fieldcount 
)

Calculates the minimum size of each field in the content using the specified fieldcount.

void String::rebaseMinimumFieldSizes ( std::vector< int > &  sizes,
const Strings header 
)

Adjusts the minimum field sizes to take in account the size of the header.

void String::capFieldSize ( std::vector< int > &  sizes,
const int  maxlinesize 
)

Cap the field sizes so that their sum is equal to or less than the specified maximum.

void String::capUnfairFields ( std::vector< int > &  sizes,
int  unfairFields,
int  maxFairSize,
int  slack 
)

Cap the fields that are unproporitonally large using the specified attributes.

std::string String::packFields ( const Strings fields,
const std::vector< int > &  fieldsizes 
)

Pack the specified fields into one string using the specified fieldsizes.


Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo