Trippin Cyril
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | List of all members
trippingcyril::String Class Reference

A wrapper string class to make a various amount of things just easier to type. All strings used should be of this type, add methods to this class as you need them. More...

#include <String.h>

Inheritance diagram for trippingcyril::String:
[legend]
Collaboration diagram for trippingcyril::String:
[legend]

Public Member Functions

 String (bool b)
 
 String (char c)
 
 String (unsigned char c)
 
 String (short i)
 
 String (unsigned short i)
 
 String (int i)
 
 String (unsigned int i)
 
 String (long i)
 
 String (unsigned long i)
 
 String (long long i)
 
 String (unsigned long long i)
 
 String (double i, unsigned int precision=2)
 
 String (float i, unsigned int precision=2)
 
 String (const std::stringstream &stream)
 
 String ()
 
 String (const char *c)
 
 String (const char *c, size_t l)
 
 String (const string &s)
 
virtual ~String ()
 
bool WildCmp (const String &wild) const
 
bool Trim (const String &to_trim=" \t\r\n")
 
bool TrimLeft (const String &to_trim=" \t\r\n")
 
bool TrimRight (const String &to_trim=" \t\r\n")
 
StringMakeLower ()
 
StringMakeUpper ()
 
bool OnlyContains (const String &characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-") const
 
bool ToBool () const
 
 operator bool () const
 
short ToShort (unsigned int base=10) const
 
 operator short () const
 
unsigned short ToUShort (unsigned int base=10) const
 
 operator unsigned short () const
 
int ToInt (unsigned int base=10) const
 
unsigned int ToUInt (unsigned int base=10) const
 
long ToLong (unsigned int base=10) const
 
unsigned long ToULong (unsigned int base=10) const
 
long long ToLongLong (unsigned int base=10) const
 
unsigned long long ToULongLong (unsigned int base=10) const
 
double ToDouble () const
 
 operator double () const
 
float ToFloat () const
 
 operator float () const
 
int32_t ToInt32 () const
 
 operator int32_t () const
 
uint32_t ToUInt32 () const
 
 operator uint32_t () const
 
int64_t ToInt64 () const
 
 operator int64_t () const
 
uint64_t ToUInt64 () const
 
 operator uint64_t () const
 
bool Base64Encode (String &sRet) const
 
unsigned long Base64Decode (String &sRet) const
 
String SHA1 (bool raw=false) const
 
String SHA256 (bool raw=false) const
 
String SHA512 (bool raw=false) const
 

Static Public Member Functions

static String ToPercent (double d)
 
static String ToByteStr (unsigned long long d)
 

Detailed Description

A wrapper string class to make a various amount of things just easier to type. All strings used should be of this type, add methods to this class as you need them.

Constructor & Destructor Documentation

trippingcyril::String::String ( bool  b)
inlineexplicit
trippingcyril::String::String ( char  c)
explicit
trippingcyril::String::String ( unsigned char  c)
explicit
trippingcyril::String::String ( short  i)
explicit
trippingcyril::String::String ( unsigned short  i)
explicit
trippingcyril::String::String ( int  i)
explicit
trippingcyril::String::String ( unsigned int  i)
explicit
trippingcyril::String::String ( long  i)
explicit
trippingcyril::String::String ( unsigned long  i)
explicit
trippingcyril::String::String ( long long  i)
explicit
trippingcyril::String::String ( unsigned long long  i)
explicit
trippingcyril::String::String ( double  i,
unsigned int  precision = 2 
)
explicit
trippingcyril::String::String ( float  i,
unsigned int  precision = 2 
)
explicit
trippingcyril::String::String ( const std::stringstream &  stream)
trippingcyril::String::String ( )
inline
trippingcyril::String::String ( const char *  c)
inline
trippingcyril::String::String ( const char *  c,
size_t  l 
)
inline
trippingcyril::String::String ( const string &  s)
inline
virtual trippingcyril::String::~String ( )
inlinevirtual

Member Function Documentation

unsigned long trippingcyril::String::Base64Decode ( String sRet) const

Treat this string as base64-encoded data and decode it.

Parameters
sRetString to which the result of the decode is safed.
Returns
The length of the resulting string.
bool trippingcyril::String::Base64Encode ( String sRet) const

Base64-encode the current string.

Parameters
sRetString where the result is saved.
Returns
True if succesfully coded
String& trippingcyril::String::MakeLower ( )

Turn all characters in this string into their lower-case equivalent.

Returns
A reference to *this.
String& trippingcyril::String::MakeUpper ( )

Turn all characters in this string into their upper-case equivalent.

Returns
A reference to *this.
bool trippingcyril::String::OnlyContains ( const String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-") const

Check if the string is formed with only the characters provided

Returns
False if a character not listed in the parameter is found
trippingcyril::String::operator bool ( ) const
inline
Returns
True if this string is not "false".
trippingcyril::String::operator double ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator float ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator int32_t ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator int64_t ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator short ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator uint32_t ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator uint64_t ( ) const
inline
Returns
The numerical value of this string similar to atoi().
trippingcyril::String::operator unsigned short ( ) const
inline
Returns
The numerical value of this string similar to atoi().
String trippingcyril::String::SHA1 ( bool  raw = false) const

Returns a SHA1 hash of this string

Parameters
rawIf true it'll return the raw unencoded hash, probably not printable
String trippingcyril::String::SHA256 ( bool  raw = false) const

Returns a SHA256 hash of this string

Parameters
rawIf true it'll return the raw unencoded hash, probably not printable
String trippingcyril::String::SHA512 ( bool  raw = false) const

Returns a SHA512 hash of this string

Parameters
rawIf true it'll return the raw unencoded hash, probably not printable
bool trippingcyril::String::ToBool ( ) const
Returns
True if this string is not "false".
static String trippingcyril::String::ToByteStr ( unsigned long long  d)
static

Pretty-print a number of bytes.

Parameters
dThe number of bytes.
Returns
A string describing the number of bytes.
double trippingcyril::String::ToDouble ( ) const
Returns
The numerical value of this string similar to atoi().
float trippingcyril::String::ToFloat ( ) const
Returns
The numerical value of this string similar to atoi().
int trippingcyril::String::ToInt ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
int32_t trippingcyril::String::ToInt32 ( ) const
inline
Returns
The numerical value of this string similar to atoi().
int64_t trippingcyril::String::ToInt64 ( ) const
inline
Returns
The numerical value of this string similar to atoi().
long trippingcyril::String::ToLong ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
long long trippingcyril::String::ToLongLong ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
static String trippingcyril::String::ToPercent ( double  d)
static

Pretty-print a percent value.

Parameters
dThe percent value. This should be in range 0-100.
Returns
The "pretty" string.
short trippingcyril::String::ToShort ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
unsigned int trippingcyril::String::ToUInt ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
uint32_t trippingcyril::String::ToUInt32 ( ) const
inline
Returns
The numerical value of this string similar to atoi().
uint64_t trippingcyril::String::ToUInt64 ( ) const
inline
Returns
The numerical value of this string similar to atoi().
unsigned long trippingcyril::String::ToULong ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
unsigned long long trippingcyril::String::ToULongLong ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
unsigned short trippingcyril::String::ToUShort ( unsigned int  base = 10) const
Returns
The numerical value of this string similar to atoi().
bool trippingcyril::String::Trim ( const String to_trim = " \t\r\n")

Trim this string, all leading occurences of characters to_trim are removed.

Parameters
to_trimA list of characters that should be trimmed.
Returns
true if this string as modified.
bool trippingcyril::String::TrimLeft ( const String to_trim = " \t\r\n")

Trim this string, all leading occurences of characters to_trim are removed.

Parameters
to_trimA list of characters that should be trimmed.
Returns
true if this string as modified.
bool trippingcyril::String::TrimRight ( const String to_trim = " \t\r\n")

Trim this string, all leading occurences of characters to_trim are removed.

Parameters
to_trimA list of characters that should be trimmed.
Returns
true if this string as modified.
bool trippingcyril::String::WildCmp ( const String wild) const

Do a wildcard comparison on this string. Where "*" will match any number of characters and "?" will match a single character. For example String("I_am@~bar@foo").WildCmp("*!?bar@foo") would return true.

Parameters
wildThe wildcard to use for this comparison
Returns
true if the wildcard matches

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