Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::StringUtils Class Reference

The StringUtils class is a collection of static utility methods for operating on strings. More...

#include <vcf/FoundationKit/StringUtils.h>

List of all members.

Static Public Member Functions

static void trace (const VCF::String &text)
 outputs the text to the debugger output
static VCF::String trimLeft (const VCF::String &text, const char &c)
 trim all the occurrences of a specified character at the beginning of the string until it is met the first character from the left that is different
static VCF::String trimRight (const VCF::String &text, const char &c)
 trim all the occurrences of a specified character at the end of the string until it is met the first character from the right that is different
static VCF::String trim (const VCF::String &text, const char &c)
 trim all the occurrences of a specified character at the beginning and the end of the string i.e.
static void trimWhiteSpacesLeft (VCF::String &text)
 trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the beginning of the string until it is met the first character from the left that is not a whitespace one
static void trimWhiteSpacesRight (VCF::String &text)
 trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the end of the string until it is met the first character from the right that is not a whitespace one
static void trimWhiteSpaces (VCF::String &text)
 trim all the occurrences of any <<space>, <tab>, <CR> and <LF> at the beginning and the end of the string i.e.
static String eraseLeftOfChar (const String &s, const VCFChar &ch, const bool &included=false, const int &count=1)
 gets a copy of the string that is having erased all its characters on the left of the count-th occurrence of the character ch.
static String eraseRightOfChar (const String &s, const VCFChar &ch, const bool &included=false, const int &count=1)
 gets a copy of the string that is having erased all its characters on the right of the count-th occurrence of the character ch.
static VCF::String lowerCase (const VCF::String &text)
 converts the string to lower case
static VCF::String upperCase (const VCF::String &text)
 converts the string to upper case
static int noCaseCompare (const VCF::String &str1, const VCF::String &str2)
 Performs a case insensitive string compare between str1 and str2.
static VCF::String toStringFromHexNumber (const uchar &value)
 converts the value to a string
static VCF::String toString (const int &value)
 converts the value to a string
static VCF::String toString (const VCF::uint32 &value)
 converts the value to a string
static VCF::String toString (const long &value)
 converts the value to a string
static VCF::String toString (const unsigned long &value)
 converts the value to a string
static VCF::String toString (const VCF::int64 &value)
 converts the value to a string
static VCF::String toString (const VCF::uint64 &value)
 converts the value to a string
static VCF::String toString (const float &value)
 converts the value to a string
static VCF::String toString (const double &value)
 converts the value to a string
static VCF::String toString (const char &value)
 converts the value to a string
static VCF::String toString (const bool &value)
 converts the value to a string
static VCF::String toString (const VariantData &value)
 Converts a VariantData instance to a string.
static int fromStringAsHexNumber (const VCF::String &value)
 converts the value to an hexadecimal number
static VCF::int32 fromStringAsInt (const VCF::String &value)
 converts the value to an int
static VCF::uint32 fromStringAsUInt (const VCF::String &value)
 converts the value to an unsigned integer
static long fromStringAsLong (const VCF::String &value)
 converts the value to a long
static unsigned long fromStringAsULong (const VCF::String &value)
 converts the value to an unsigned long
static VCF::int64 fromStringAsInt64 (const VCF::String &value)
 converts the value to a 64 bit signed integer
static VCF::uint64 fromStringAsUInt64 (const VCF::String &value)
 converts the value to a 64 bit unsigned integer
static float fromStringAsFloat (const VCF::String &value)
 converts the value to an int
static double fromStringAsDouble (const VCF::String &value)
 converts the value to an int
static char fromStringAsChar (const VCF::String &value)
 converts the value to an int
static short fromStringAsShort (const VCF::String &value)
 converts the value to an int
static bool fromStringAsBool (const VCF::String &value)
 converts the value to an int
static VCF::String newUUID ()
 generates a new UUID and returns the string representation
static VCF::String getClassNameFromTypeInfo (const std::type_info &typeInfo)
 gets the class name from a type_info struct.
static VCF::String toString (const std::type_info &typeInfo)
 Converts a typeinfo to a string.
static VCF::String format (const DateTime &date, const String &formatting)
 Formats a string from date time object using the various argument/formatting tags in the formatting string.
static VCF::String convertFormatString (const String &formattedString)
 This functions is used to change, if neccessary, a format string to one accceptable for the native platforms string formatting routines.
static VCF::String translateVKCodeToString (VirtualKeyCode code)
 Translate a VirtualKey code into a human readable string.

Static Protected Attributes

static String weekdays []
static String abbrevWeekdays []
static String months []
static String abbrevMonths []


Detailed Description

The StringUtils class is a collection of static utility methods for operating on strings.


Member Function Documentation

static VCF::String VCF::StringUtils::convertFormatString const String formattedString  )  [static]
 

This functions is used to change, if neccessary, a format string to one accceptable for the native platforms string formatting routines.

Its existance is due to the fact that OSX's Core Foundation string formatting routines do not understand how to deal with unicode buffers without the use of the "%S" format directive. Naturally, no other system uses the "%S" directive, hence the neccessity of this function, which will search for the presence of the "%ls" directive (which on both Win32 and linux based systems accepts a unicode/wchar_t buffer) and replace it with the S directive. To be smart the search/replace will only occur if called on OSX.

static String VCF::StringUtils::eraseLeftOfChar const String s,
const VCFChar ch,
const bool &  included = false,
const int &  count = 1
[static]
 

gets a copy of the string that is having erased all its characters on the left of the count-th occurrence of the character ch.

If the character is not found, the result string is equal to the original one.

Parameters:
String the source string
const VCFChar& ch, the char to be searched
const bool& included, includes the found char in the erasing. By default is false.
const int& count, number of occurrences of the character to search for. A negative value means a search from the end of the string. Default is +1. in the string. A count = 0 means no erasing on the string. It the count exceeds the number of occurrences in the string then search stops at the last one.
Returns:
String, the modified string.

static String VCF::StringUtils::eraseRightOfChar const String s,
const VCFChar ch,
const bool &  included = false,
const int &  count = 1
[static]
 

gets a copy of the string that is having erased all its characters on the right of the count-th occurrence of the character ch.

If the character is not found, the result string is equal to the original one.

Parameters:
String the source string
const VCFChar& ch, the char to be searched
const bool& included, includes the found char in the erasing. By default is false.
const int& count, number of occurrences of the character to search for. A negative value means a search from the end of the string. Default is +1. in the string. A count = 0 means no erasing on the string. It the count exceeds the number of occurrences in the string then search stops at the last one.
Returns:
String, the modified string.

static VCF::String VCF::StringUtils::format const DateTime date,
const String formatting
[static]
 

Formats a string from date time object using the various argument/formatting tags in the formatting string.

For example, a date that equals "Jan 2, 2005", and a formatting string of "%a %B %#d, %Y" will return string that equals "Sunday January 2, 2005". A listing of the possible format codes follows:
Format code Meaning
%% outputs just a "%" character
a Abbreviated weekday name
A Full weekday name
b Abbreviated month name
B Full month name
c Date and time representation appropriate for locale
d Day of month as decimal number (01 31)
D Day of the year as decimal number
H Hour in 24-hour format (00 23)
I Hour in 12-hour format (01 12)
j Day of year as decimal number (001 366)
m Month as decimal number (01 12)
M Minute as decimal number (00 59)
p Current locale's A.M./P.M. indicator for 12-hour clock
S Second as decimal number (00 59)
U Week of year as decimal number, with Sunday as first day of week (00 53)
w Weekday as decimal number (0 6; Sunday is 0)
W Week of year as decimal number, with Monday as first day of week (00 53)
x Date representation for current locale
X Time representation for current locale
y Year without century, as decimal number (00 99)
Y Year with century, as decimal number
s millisecond part

Parameters:
Date the date to use
String a string with formatting codes in it.
Returns:
String the newly formatted string

static bool VCF::StringUtils::fromStringAsBool const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int the integer representation of the String value

static char VCF::StringUtils::fromStringAsChar const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int the integer representation of the String value

static double VCF::StringUtils::fromStringAsDouble const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int the integer representation of the String value

static float VCF::StringUtils::fromStringAsFloat const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int the integer representation of the String value

static int VCF::StringUtils::fromStringAsHexNumber const VCF::String value  )  [static]
 

converts the value to an hexadecimal number

Parameters:
String the value to convert
Returns:
int the hexadecimal representation of the String value

static VCF::int32 VCF::StringUtils::fromStringAsInt const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int32 the integer representation of the String value

static VCF::int64 VCF::StringUtils::fromStringAsInt64 const VCF::String value  )  [static]
 

converts the value to a 64 bit signed integer

Parameters:
String the value to convert
Returns:
int64 the 64 bit signed integer representation of the String value

static long VCF::StringUtils::fromStringAsLong const VCF::String value  )  [static]
 

converts the value to a long

Parameters:
String the value to convert
Returns:
long the long integer representation of the String value

static short VCF::StringUtils::fromStringAsShort const VCF::String value  )  [static]
 

converts the value to an int

Parameters:
String the value to convert
Returns:
int the integer representation of the String value

static VCF::uint32 VCF::StringUtils::fromStringAsUInt const VCF::String value  )  [static]
 

converts the value to an unsigned integer

Parameters:
String the value to convert
Returns:
uint32 the unsigned integer representation of the String value

static VCF::uint64 VCF::StringUtils::fromStringAsUInt64 const VCF::String value  )  [static]
 

converts the value to a 64 bit unsigned integer

Parameters:
String the value to convert
Returns:
uint64 the 64 bit unsigned integer representation of the String value

static unsigned long VCF::StringUtils::fromStringAsULong const VCF::String value  )  [static]
 

converts the value to an unsigned long

Parameters:
String the value to convert
Returns:
unsigned long the unsigned long integer representation of the String value

static VCF::String VCF::StringUtils::getClassNameFromTypeInfo const std::type_info &  typeInfo  )  [static]
 

gets the class name from a type_info struct.

Parameters:
type_info the value returned from the expression :
        typeid(AClass)
Returns:
String the name of the class the typeInfo references

static VCF::String VCF::StringUtils::lowerCase const VCF::String text  )  [static]
 

converts the string to lower case

Parameters:
String the text to convert
Returns:
String the converted string

static VCF::String VCF::StringUtils::newUUID  )  [static]
 

generates a new UUID and returns the string representation

Returns:
String the new UUID as a string value

static int VCF::StringUtils::noCaseCompare const VCF::String str1,
const VCF::String str2
[static]
 

Performs a case insensitive string compare between str1 and str2.

This may not be locale safe, but it will try and use the lower level OS facilities for case insensitive string comparison if they exist. Otherwise it will simply convert both strings to uppercase and compare the results.

Returns:
int returns 0 if the strings are equivalent, returns greater than 0 if str1 is greater than str2, and returns less than 0 if str1 is less than str2.

static VCF::String VCF::StringUtils::toString const std::type_info &  typeInfo  )  [static]
 

Converts a typeinfo to a string.

GCC does such a piss poor job of this that we have to write our own coverter, since the data returned by the GCC implemented type_info::name() is useless.

static VCF::String VCF::StringUtils::toString const VariantData value  )  [static]
 

Converts a VariantData instance to a string.

Parameters:
VariantData the variant to convert
Returns:
String the string returned from calling VariantData::toString

static VCF::String VCF::StringUtils::toString const bool &  value  )  [static]
 

converts the value to a string

Parameters:
char bool the value to convert
Returns:
String the string representation of the bool value (either "true" or "false")

static VCF::String VCF::StringUtils::toString const char &  value  )  [static]
 

converts the value to a string

Parameters:
char int the value to convert
Returns:
String the string representation of the char value

static VCF::String VCF::StringUtils::toString const double &  value  )  [static]
 

converts the value to a string

Parameters:
double the value to convert
Returns:
String the string representation of the double value

static VCF::String VCF::StringUtils::toString const float &  value  )  [static]
 

converts the value to a string

Parameters:
float the value to convert
Returns:
String the string representation of the float value

static VCF::String VCF::StringUtils::toString const VCF::uint64 value  )  [static]
 

converts the value to a string

Parameters:
VCF::uint64 the value to convert
Returns:
String the string representation of the VCF::uint64 value

static VCF::String VCF::StringUtils::toString const VCF::int64 value  )  [static]
 

converts the value to a string

Parameters:
VCF::int64 the value to convert
Returns:
String the string representation of the VCF::int64 value

static VCF::String VCF::StringUtils::toString const unsigned long &  value  )  [static]
 

converts the value to a string

Parameters:
unsigned long the value to convert
Returns:
String the string representation of the unsigned long value

static VCF::String VCF::StringUtils::toString const long &  value  )  [static]
 

converts the value to a string

Parameters:
long the value to convert
Returns:
String the string representation of the long value

static VCF::String VCF::StringUtils::toString const VCF::uint32 value  )  [static]
 

converts the value to a string

Parameters:
uint32 the value to convert
Returns:
String the string representation of the unsigned int value

static VCF::String VCF::StringUtils::toString const int &  value  )  [static]
 

converts the value to a string

Parameters:
int the value to convert
Returns:
String the string representation of the int value

static VCF::String VCF::StringUtils::toStringFromHexNumber const uchar value  )  [static]
 

converts the value to a string

Parameters:
uchar the hexadecimal value to convert
Returns:
String the string representation of the hexadecimal value

static void VCF::StringUtils::trace const VCF::String text  )  [static]
 

outputs the text to the debugger output

Parameters:
String the text to output

static VCF::String VCF::StringUtils::translateVKCodeToString VirtualKeyCode  code  )  [static]
 

Translate a VirtualKey code into a human readable string.

This can be used to display an accelerator key into a string to be displayed in a MenuItem when an accelerator is associated to it.

static VCF::String VCF::StringUtils::trim const VCF::String text,
const char &  c
[static]
 

trim all the occurrences of a specified character at the beginning and the end of the string i.e.

calls trimLeft + trimRight

Parameters:
String the text to trim
char the character to trim
Returns:
String the trimmed string

static VCF::String VCF::StringUtils::trimLeft const VCF::String text,
const char &  c
[static]
 

trim all the occurrences of a specified character at the beginning of the string until it is met the first character from the left that is different

Parameters:
String the text to trim
char the character to trim
Returns:
String the trimmed string

static VCF::String VCF::StringUtils::trimRight const VCF::String text,
const char &  c
[static]
 

trim all the occurrences of a specified character at the end of the string until it is met the first character from the right that is different

Parameters:
String the text to trim
char the character to trim
Returns:
String the trimmed string

static void VCF::StringUtils::trimWhiteSpaces VCF::String text  )  [static]
 

trim all the occurrences of any <<space>, <tab>, <CR> and <LF> at the beginning and the end of the string i.e.

calls trimWhiteSpacesLeft + trimWhiteSpacesRight

Parameters:
String the text to trim

static void VCF::StringUtils::trimWhiteSpacesLeft VCF::String text  )  [static]
 

trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the beginning of the string until it is met the first character from the left that is not a whitespace one

Parameters:
String the text to trim

static void VCF::StringUtils::trimWhiteSpacesRight VCF::String text  )  [static]
 

trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the end of the string until it is met the first character from the right that is not a whitespace one

Parameters:
String the text to trim

static VCF::String VCF::StringUtils::upperCase const VCF::String text  )  [static]
 

converts the string to upper case

Parameters:
String the text to convert
Returns:
String the converted string


Member Data Documentation

String VCF::StringUtils::abbrevMonths[] [static, protected]
 

String VCF::StringUtils::abbrevWeekdays[] [static, protected]
 

String VCF::StringUtils::months[] [static, protected]
 

String VCF::StringUtils::weekdays[] [static, protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information