vdk 2.4.0
Public Member Functions | List of all members
VDKString Class Reference

Implements famous cont referenced string objects. More...

#include <vdkstring.h>

Public Member Functions

 VDKString ()
 
 VDKString (const char *s)
 
 VDKString (const char &c)
 
 VDKString (const VDKString &s)
 
VDKStringoperator= (const VDKString &s)
 
VDKStringoperator= (const char *s)
 
 ~VDKString ()
 
 operator char * ()
 
int operator== (const VDKString &s) const
 
int operator< (const VDKString &s) const
 
int operator> (const VDKString &s) const
 
int operator<= (const VDKString &s) const
 
int operator>= (const VDKString &s) const
 
int operator!= (const VDKString &s) const
 
VDKStringoperator+= (const char *s)
 
VDKStringoperator+= (const VDKString &s)
 
VDKString operator+ (const char *s) const
 
VDKString operator+ (const VDKString &s) const
 
bool isNull () const
 
int size () const
 
char operator[] (unsigned int ix) const
 
const char * c_str () const
 
VDKStringDelSelection (unsigned int begin, unsigned int len)
 
VDKStringRTrim ()
 
VDKStringLTrim ()
 
VDKStringTrim ()
 
unsigned int CharCount (const char car) const
 
VDKStringUpperCase ()
 
VDKStringLowerCase ()
 
bool isEmpty () const
 
VDKStringConcatf (const char *format,...)
 
VDKStringSprintf (const char *format,...)
 
VDKStringGetPart (unsigned int i, const char sep= '|')
 
int GetFCharPos (const char car) const
 
int GetLCharPos (const char car) const
 
double StrtoDouble () const
 
int StrtoInt () const
 
VDKStringSubStr (unsigned int start, unsigned int len)
 
VDKStringCut (unsigned int len)
 
VDKStringLPad (unsigned int len, const char car)
 
VDKStringRPad (unsigned int len, const char car)
 
VDKStringDoubleChar (const char car= '\'')
 
VDKStringFormatDate (const char sep, int orig, int ret)
 

Detailed Description

Implements famous cont referenced string objects.

Constructor & Destructor Documentation

VDKString::VDKString ( )

Constructor, makes an empty string

VDKString::VDKString ( const char *  s)

Constructor

Parameters
sa null terminated C string
VDKString s = "uncle bill";
VDKString::VDKString ( const char &  c)

Constructor

Parameters
ca single character
VDKString s(c);
VDKString::VDKString ( const VDKString s)

Copy-initializer

Parameters
sa VDKString reference
VDKString s = "uncle bill";
VDKString s1 = s;
VDKString::~VDKString ( )

Destructor

Member Function Documentation

const char * VDKString::c_str ( ) const

string pointer access for const instances

unsigned int VDKString::CharCount ( const char  car) const

Returns the number of the specified char 'car' contained in the string.

Parameters
carchar to be counted
VDKString s = "uncle bill";
int NumCar = s.CharCount('l'); // NumCar value is 3
VDKString & VDKString::Concatf ( const char *  format,
  ... 
)

Strcat() to the existing string (printf style). Modifies and returns the resulting VDKString.

Warning
Final string is 65534 chars max.
Returns the previous string in case of memory overflow or buffer overflow.
Parameters
formata NULL terminated string
...a list of parameters
VDKString s = "uncle bill";
s.Concatf("%s", " is a smart boy"); // s value is "uncle bill is a smart boy"
VDKString & VDKString::Cut ( unsigned int  len)

Cut the string at 'len' length. Modifies and returns the resulting VDKString.

Parameters
lenlength of the resulting string
VDKString & VDKString::DelSelection ( unsigned int  begin,
unsigned int  len 
)

Removes a part of the string, beginning at 'begin' on 'len' length. Modifies and returns the resulting VDKString.

Parameters
beginchar number where begins the selection (0 based)
lenselection length
VDKString & VDKString::DoubleChar ( const char  car = '\'')

Double all 'car' chars in the string (for SQL purpose). Modifies and returns the resulting VDKString.

Parameters
carchar to be doubled, '\'' (cote) by default
VDKString s = "Don't do that";
VDKString p = s;
p.DoublaChar(); // p value is "Don''t do that"
VDKString & VDKString::FormatDate ( const char  sep,
int  orig,
int  ret 
)

Returns a VDKString containing a formatted date according to parameters settings. Modifies and returns the resulting VDKString.

Warning
Only complete dates are supported. That's to say days and months on two digits and years on 4 digits. For ex. : 02/03/2000.
Parameters
sepdesired separator. If 0, no separator left
origdate style staying in VDKString buffer
retdate style to return
VDKString s = "12/25/2000";
VDKString p = s;
p.FormatDate(0, ENG_DATE, INT_DATE); // p value is "20001225"
VDKString s = "12/25/2000";
VDKString p = s;
p.FormatDate('-', ENG_DATE, EUR_DATE); // p value is "25-12-2000"
int VDKString::GetFCharPos ( const char  car) const

Returns the first occurrence position of the specified char 'car' (0 based) or -1 if 'car ' not found.

Parameters
carchar to be searched for
int VDKString::GetLCharPos ( const char  car) const

Returns the last occurrence position of the specified char 'car' (0 based) or -1 if 'car ' not found.

Parameters
carchar to be searched for
VDKString & VDKString::GetPart ( unsigned int  i,
const char  sep = '|' 
)

Extract the specified part of a formatted string. Modifies and returns the resulting VDKString.

Warning
Returns an isNull() string if the specified part not found.
Parameters
ithe desired part position (starting at 1)
septhe parts separator, '|' by default
VDKString s = "one|two|three|four";
VDKString p = s;
p.GetPart(2); // p value is "two"
bool VDKString::isEmpty ( ) const

Returns true if this is an empty string meaning NULL buffer or strlen() == 0.

bool VDKString::isNull ( ) const

Returns true if this is an empty string

VDKString & VDKString::LowerCase ( )

Returns the lower case VDKString after having modify it.

Warning
Upper case characters are assumed without accents.
VDKString & VDKString::LPad ( unsigned int  len,
const char  car 
)

Pad left of string with a specified char 'car' upon 'len' length. Modifies and returns the resulting VDKString.

Parameters
lenlength of the resulting string
carchar to be padded
VDKString & VDKString::LTrim ( )

Removes all leading spaces. Modifies and returns the resulting VDKString.

VDKString::operator char * ( )
inline

VDKString to char* casting warning ** can violate data hiding OO concept

int VDKString::operator!= ( const VDKString s) const

disequality operator

VDKString VDKString::operator+ ( const char *  s) const

Returns a VDKString concatenated

Parameters
sa null terminated string
VDKString s = "uncle bill";
VDKString s1 = s + " is a smart boy";
VDKString VDKString::operator+ ( const VDKString s) const

Returns a VDKString concatenated

Parameters
sa VDKString
VDKString & VDKString::operator+= ( const char *  s)

cat to this

Parameters
sa null terminated string
VDKString s = "uncle bill";
s += " is a smart boy";
VDKString & VDKString::operator+= ( const VDKString s)

cat to this

Parameters
sa VDKString
VDKString s = "uncle bill";
VDKString s1 = " is a smart boy";
s += s1;
int VDKString::operator< ( const VDKString s) const

less than operator

int VDKString::operator<= ( const VDKString s) const

less-equal operator

VDKString & VDKString::operator= ( const VDKString s)

Assignement operator

Parameters
sa VDKString reference
VDKString s = "uncle bill";
VDKString s1 = s;
VDKString s2 = "uncle sam";
s = s2;
VDKString & VDKString::operator= ( const char *  s)

Assignement operator

Parameters
sa null terminated C string
VDKString s = "uncle bill";
s = "uncle sam";
int VDKString::operator== ( const VDKString s) const

Equality operator

int VDKString::operator> ( const VDKString s) const

greater than operator

int VDKString::operator>= ( const VDKString s) const

greater-equal operator

char VDKString::operator[] ( unsigned int  ix) const

index operator for const instances returns NULL if ix >= size

VDKString & VDKString::RPad ( unsigned int  len,
const char  car 
)

Pad right of string with a specified char 'car' upon 'len' length. Modifies and returns the resulting VDKString.

Parameters
lenlength of the resulting string
carchar to be padded
VDKString & VDKString::RTrim ( )

Removes all trailing spaces. Modifies and returns the resulting VDKString.

int VDKString::size ( ) const

as strlen()

VDKString & VDKString::Sprintf ( const char *  format,
  ... 
)

Assignment to string (printf style). Modifies and returns the resulting VDKString.

Warning
Final string is 65534 chars max.
Returns the previous string in case of memory overflow or buffer overflow.
Parameters
formata NULL terminated string
...a list of parameters
s.Sprintf("%s is %d years old", "uncle bill", 40); // s value is "uncle bill is 40 years old"
double VDKString::StrtoDouble ( ) const

Returns the converted string to double. See atof() for details.

int VDKString::StrtoInt ( ) const

Returns the converted string to int. See atoi() for details.

VDKString & VDKString::SubStr ( unsigned int  start,
unsigned int  len 
)

Extract a part of the string beginning at 'start' upon 'len' length. Modifies and returns the resulting VDKString.

Parameters
startfirst char position (0 based)
lenmaximum length of the resulting string
VDKString & VDKString::Trim ( )

Removes all leading and trailing spaces. Modifies and returns the resulting VDKString.

VDKString & VDKString::UpperCase ( )

Returns the upper case VDKString after having modify it.

Warning
Does not modify unknown characters.
Upper case characters are assumed without accents.

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