Public Member Functions | Static Public Member Functions

CdcString Class Reference

This class is a wrapper of the STL string class. More...

#include <DcString.h>

Inherits std::string.

List of all members.

Public Member Functions

 CdcString ()
 Constructors.
 CdcString (char ch)
 CdcString (const char *str)
 CdcString (char *str)
 CdcString (const char *str, int len)
 CdcString (char *str, int len)
 CdcString (const string &str)
 CdcString (const CdcString &str)
 CdcString (BufferHolder bh)
int GetLength () const
 Return the length of this string,.
bool IsEmpty () const
 Return True if the string is empty.
int Compare (const CdcString &str) const
 Compare two strings.
int CompareNoCase (const CdcString &str) const
 Compare two strings but ignore the case.
int CompareEnd (const CdcString &str) const
 Compare the end of a string to 'str'.
CdcString Mid (int first, int count=CdcString::npos) const
 Extract a sub string.
CdcString Left (int count) const
 Extract the left part of a string.
CdcString Right (int count) const
 Extract the right part of a string.
void MakeUpper ()
 Make a string upper case.
void MakeLower ()
 Make a string lower case.
void Replace (const CdcString &strOld, const CdcString &strNew)
 Replace chars in a string.
void TrimLeft ()
 Trim white spaces in the left of a string.
void TrimRight ()
 Trim white spaces in the right of a string.
CdcStringTrim ()
 Trim from left and right.
int Find (const CdcString &str, int start=0) const
 Find sub string in a string.
int Find (const char *str, int start=0) const
int Find (char c, int start=0) const
int ReverseFind (const CdcString &str, int start=-1) const
int ReverseFind (const char *str, int start=-1) const
int ReverseFind (char c, int start=-1) const
int FindOneOf (const CdcString &charSet, int start=0) const
 Find one char from a set in a string.
const char * GetBuffer () const
 Return pointer to the inner buffer of a string.
CdcString SpanIncluding (const CdcString &charSet) const
 Format a string like printf.
 operator const char * () const
char operator[] (int place) const
char & operator[] (int place)

Static Public Member Functions

static CdcString IntToString (int num, const char *format="%d")

Detailed Description

This class is a wrapper of the STL string class.

I wrote it because I started the project using MFC, and then decided not to use it. This class take some of the interface of CString and implements it with an STL string. In addition if I will ever decide to make this CdcString working with Reference Counting method, it will be much easier.

Author:
Erez Bibi
Version:
1.0

Definition at line 40 of file DcString.h.


Constructor & Destructor Documentation

CdcString::CdcString (  ) [inline]

Constructors.

Definition at line 45 of file DcString.h.

CdcString::CdcString ( char  ch ) [inline]

Definition at line 47 of file DcString.h.

CdcString::CdcString ( const char *  str ) [inline]

Definition at line 49 of file DcString.h.

CdcString::CdcString ( char *  str ) [inline]

Definition at line 51 of file DcString.h.

CdcString::CdcString ( const char *  str,
int  len 
) [inline]

Definition at line 53 of file DcString.h.

CdcString::CdcString ( char *  str,
int  len 
) [inline]

Definition at line 55 of file DcString.h.

CdcString::CdcString ( const string &  str ) [inline]

Definition at line 57 of file DcString.h.

CdcString::CdcString ( const CdcString str ) [inline]

Definition at line 59 of file DcString.h.

CdcString::CdcString ( BufferHolder  bh ) [inline]

Definition at line 61 of file DcString.h.


Member Function Documentation

int CdcString::Compare ( const CdcString str ) const [inline]

Compare two strings.

Definition at line 73 of file DcString.h.

int CdcString::CompareEnd ( const CdcString str ) const

Compare the end of a string to 'str'.

Definition at line 39 of file DcString.cpp.

int CdcString::CompareNoCase ( const CdcString str ) const

Compare two strings but ignore the case.

CdcString.cpp: implementation of the CdcString class.

for documentation see the header file.

Definition at line 28 of file DcString.cpp.

int CdcString::Find ( const char *  str,
int  start = 0 
) const [inline]

Definition at line 123 of file DcString.h.

int CdcString::Find ( char  c,
int  start = 0 
) const [inline]

Definition at line 125 of file DcString.h.

int CdcString::Find ( const CdcString str,
int  start = 0 
) const [inline]

Find sub string in a string.

Definition at line 121 of file DcString.h.

int CdcString::FindOneOf ( const CdcString charSet,
int  start = 0 
) const [inline]

Find one char from a set in a string.

Definition at line 139 of file DcString.h.

const char* CdcString::GetBuffer (  ) const [inline]

Return pointer to the inner buffer of a string.

Definition at line 143 of file DcString.h.

int CdcString::GetLength (  ) const [inline]

Return the length of this string,.

Definition at line 65 of file DcString.h.

CdcString CdcString::IntToString ( int  num,
const char *  format = "%d" 
) [static]

Definition at line 130 of file DcString.cpp.

bool CdcString::IsEmpty (  ) const [inline]

Return True if the string is empty.

Definition at line 69 of file DcString.h.

CdcString CdcString::Left ( int  count ) const [inline]

Extract the left part of a string.

Definition at line 89 of file DcString.h.

void CdcString::MakeLower (  )

Make a string lower case.

Definition at line 63 of file DcString.cpp.

void CdcString::MakeUpper (  )

Make a string upper case.

Definition at line 52 of file DcString.cpp.

CdcString CdcString::Mid ( int  first,
int  count = CdcString::npos 
) const [inline]

Extract a sub string.

if count is missing, it will extract the sub string from first until the end.

Definition at line 85 of file DcString.h.

CdcString::operator const char * (  ) const [inline]

Definition at line 156 of file DcString.h.

char CdcString::operator[] ( int  place ) const [inline]

Definition at line 159 of file DcString.h.

char& CdcString::operator[] ( int  place ) [inline]

Definition at line 162 of file DcString.h.

void CdcString::Replace ( const CdcString strOld,
const CdcString strNew 
)

Replace chars in a string.

Replace sub strings in a string.

Definition at line 75 of file DcString.cpp.

int CdcString::ReverseFind ( const CdcString str,
int  start = -1 
) const [inline]

Definition at line 128 of file DcString.h.

int CdcString::ReverseFind ( char  c,
int  start = -1 
) const [inline]

Definition at line 134 of file DcString.h.

int CdcString::ReverseFind ( const char *  str,
int  start = -1 
) const [inline]

Definition at line 131 of file DcString.h.

CdcString CdcString::Right ( int  count ) const [inline]

Extract the right part of a string.

Definition at line 93 of file DcString.h.

CdcString CdcString::SpanIncluding ( const CdcString charSet ) const

Format a string like printf.

Extract a sub string from the beginning that includes only characters from charSet.

Definition at line 114 of file DcString.cpp.

CdcString& CdcString::Trim (  ) [inline]

Trim from left and right.

This is not in MFC string.

Definition at line 116 of file DcString.h.

void CdcString::TrimLeft (  )

Trim white spaces in the left of a string.

Definition at line 83 of file DcString.cpp.

void CdcString::TrimRight (  )

Trim white spaces in the right of a string.

Definition at line 98 of file DcString.cpp.


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