OpendTect-6_4  6.4
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
BufferString Class Reference

OD::String with its own variable length buffer. The buffer has a guaranteed minimum size. More...

Inheritance diagram for BufferString:
[legend]

Public Types

enum  CleanType {
  OnlyAlphaNum, AllowDots, NoSpaces, NoFileSeps,
  NoSpecialChars
}
 

Public Member Functions

 BufferString ()
 
 BufferString (const char *)
 
 BufferString (const OD::String &)
 
 BufferString (int minlen, bool setnull)
 
 BufferString (const BufferString &)
 
template<class T >
 BufferString (const char *, const T &, const char *s=0)
 
 BufferString (const QString &)
 
virtual ~BufferString ()
 
BufferStringoperator= (const BufferString &b)
 
BufferStringoperator= (const char *s)
 
BufferStringoperator= (const FixedString &s)
 
BufferStringoperator= (const OD::String &s)
 
template<class T >
BufferStringoperator= (const T &)
 
 operator const char * () const
 
bool operator== (const BufferString &) const
 
bool operator!= (const BufferString &) const
 
bool operator== (const char *) const
 
bool operator!= (const char *) const
 
bool operator== (const OD::String &) const
 
bool operator!= (const OD::String &) const
 
bool operator== (const FixedString &) const
 
bool operator!= (const FixedString &) const
 
char * getCStr ()
 
void fill (char *, int maxnrchar) const
 fill old C-style char buf More...
 
char & operator[] (int idx)
 
char * find (char)
 
char * find (const char *)
 
const char * find (char) const
 
const char * find (const char *) const
 
char * findLast (char)
 
char * findLast (const char *)
 
const char * findLast (char) const
 
const char * findLast (const char *) const
 
BufferStringsetEmpty ()
 
BufferStringset (const char *)
 
BufferStringset (const OD::String &s)
 
template<class T >
BufferStringset (const T &)
 
BufferStringset (float, int nrdec)
 
BufferStringset (double, int nrdec)
 
BufferStringsetLim (float, int maxnrchars)
 
BufferStringsetLim (double, int maxnrchars)
 
BufferStringadd (char)
 
BufferStringadd (const char *)
 
BufferStringadd (const OD::String &s)
 
BufferStringadd (const QString &)
 
template<class T >
BufferStringadd (const T &)
 
BufferStringadd (float, int nrdec)
 
BufferStringadd (double, int nrdec)
 
BufferStringaddLim (float, int maxnrchars)
 
BufferStringaddLim (double, int maxnrchars)
 
BufferStringaddSpace (int nrspaces=1)
 
BufferStringaddTab (int nrtabs=1)
 
BufferStringaddNewLine (int nrnewlines=1)
 
unsigned int bufSize () const
 
bool setBufSize (unsigned int)
 
unsigned int minBufSize () const
 
void setMinBufSize (unsigned int)
 
BufferStringreplace (char from, char to)
 
BufferStringreplace (const char *from, const char *to)
 
BufferStringremove (char)
 
BufferStringremove (const char *s)
 
BufferStringtrimBlanks ()
 removes front and back whitespaces More...
 
BufferStringinsertAt (int idx, const char *)
 
BufferStringreplaceAt (int idx, const char *, bool cutoff=true)
 
BufferStringtoLower ()
 
BufferStringtoUpper ()
 
BufferStringembed (char open, char close)
 
BufferStringunEmbed (char open, char close)
 
BufferStringquote (char q='\'')
 
BufferStringunQuote (char q='\'')
 
BufferStringclean (CleanType ct=OnlyAlphaNum)
 
BufferStringoperator+= (const char *s)
 
BufferStringoperator+= (const OD::String &s)
 
template<class T >
BufferStringoperator+= (const T &t)
 
- Public Member Functions inherited from OD::String
virtual ~String ()
 
bool operator== (const String &) const
 
bool operator!= (const String &) const
 
bool operator== (const char *) const
 
bool operator!= (const char *) const
 
template<class T >
bool operator== (const T &) const
 
template<class T >
bool operator!= (const T &t) const
 
const char * buf () const
 
const char * str () const
 
 operator const char * () const
 
unsigned int size () const
 
bool isEmpty () const
 
const char & operator[] (int idx) const
 
virtual char firstChar () const
 
bool isEqual (const char *, CaseSensitivity c=CaseSensitive) const
 
bool isStartOf (const char *, CaseSensitivity c=CaseSensitive) const
 
bool startsWith (const char *, CaseSensitivity c=CaseSensitive) const
 
bool isEndOf (const char *, CaseSensitivity c=CaseSensitive) const
 
bool endsWith (const char *, CaseSensitivity c=CaseSensitive) const
 
bool matches (const char *, CaseSensitivity c=CaseSensitive) const
 
bool contains (char) const
 
bool contains (const char *) const
 
const char * find (char) const
 
const char * findLast (char) const
 
const char * find (const char *) const
 
const char * findLast (const char *) const
 
unsigned int count (char) const
 
unsigned int getLevenshteinDist (const char *, bool casesens) const
 
bool isNumber (bool int_only=false) const
 
bool isYesNo () const
 
int toInt () const
 
float toFloat () const
 
double toDouble () const
 
bool toBool () const
 
bool operator> (const char *) const
 
bool operator< (const char *) const
 
template<class T >
bool operator> (const T &) const
 
template<class T >
bool operator< (const T &) const
 

Static Public Member Functions

static const BufferStringempty ()
 
- Static Public Member Functions inherited from OD::String
static const Stringempty ()
 

Protected Member Functions

BufferStringassignTo (const char *)
 
const char * gtBuf () const
 
const char * gtStr () const
 

Protected Attributes

char * buf_
 
unsigned int len_
 
const unsigned int minlen_
 

Private Member Functions

void init ()
 
void destroy ()
 
BufferStringaddArr32Chars (const char *, int)
 

Detailed Description

OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.

The minimum buffer size makes life easier in worlds where strcpy etc. rule. Overhead is 4 extra bytes for variable length and 4 bytes for minimum length.

Constructing/asigning/comparing etc. with a (char*) null pointer is no problem.

Don't try to add constructors with a single basic type - this leads to nasty hidden bugs because the compiler will try to convert all kinds of things into BufferStrings. If you just need a string from an int, float, ..., just use str = toString( var ). If you need the BufferString later, use:

BufferString istr( "", intvar );

Member Enumeration Documentation

Enumerator
OnlyAlphaNum 
AllowDots 
NoSpaces 
NoFileSeps 
NoSpecialChars 

Constructor & Destructor Documentation

BufferString::BufferString ( )
inline
BufferString::BufferString ( const char *  s)
inline
BufferString::BufferString ( const OD::String s)
inline
BufferString::BufferString ( int  minlen,
bool  setnull 
)
BufferString::BufferString ( const BufferString )
template<class T >
BufferString::BufferString ( const char *  s1,
const T &  t,
const char *  s = 0 
)
inline
BufferString::BufferString ( const QString &  )
virtual BufferString::~BufferString ( )
virtual

Member Function Documentation

BufferString& BufferString::add ( char  )
BufferString& BufferString::add ( const char *  )
BufferString& BufferString::add ( const OD::String s)
inline
BufferString& BufferString::add ( const QString &  )
template<class T >
BufferString & BufferString::add ( const T &  t)
inline
BufferString& BufferString::add ( float  ,
int  nrdec 
)
BufferString& BufferString::add ( double  ,
int  nrdec 
)
BufferString& BufferString::addArr32Chars ( const char *  ,
int   
)
private
BufferString& BufferString::addLim ( float  ,
int  maxnrchars 
)
BufferString& BufferString::addLim ( double  ,
int  maxnrchars 
)
BufferString& BufferString::addNewLine ( int  nrnewlines = 1)
BufferString& BufferString::addSpace ( int  nrspaces = 1)
BufferString& BufferString::addTab ( int  nrtabs = 1)
BufferString& BufferString::assignTo ( const char *  )
protected
unsigned int BufferString::bufSize ( ) const
inline
BufferString& BufferString::clean ( CleanType  ct = OnlyAlphaNum)
void BufferString::destroy ( )
inlineprivate
BufferString& BufferString::embed ( char  open,
char  close 
)
static const BufferString& BufferString::empty ( )
static
void BufferString::fill ( char *  ,
int  maxnrchar 
) const

fill old C-style char buf

char* BufferString::find ( char  )
char* BufferString::find ( const char *  )
const char * BufferString::find ( char  c) const
inline
const char * BufferString::find ( const char *  s) const
inline
char* BufferString::findLast ( char  )
char* BufferString::findLast ( const char *  )
const char * BufferString::findLast ( char  c) const
inline
const char * BufferString::findLast ( const char *  s) const
inline
char* BufferString::getCStr ( )
inline
const char* BufferString::gtBuf ( ) const
protectedvirtual
Returns
empty even if underlying is null

Implements OD::String.

const char * BufferString::gtStr ( ) const
inlineprotectedvirtual
Returns
null if empty

Implements OD::String.

void BufferString::init ( )
private
BufferString& BufferString::insertAt ( int  idx,
const char *   
)
unsigned int BufferString::minBufSize ( ) const
inline
BufferString::operator const char * ( ) const
inline
bool BufferString::operator!= ( const BufferString s) const
inline
bool BufferString::operator!= ( const char *  s) const
inline
bool BufferString::operator!= ( const OD::String s) const
inline
bool BufferString::operator!= ( const FixedString s) const
inline
BufferString& BufferString::operator+= ( const char *  s)
inline
BufferString& BufferString::operator+= ( const OD::String s)
inline
template<class T >
BufferString& BufferString::operator+= ( const T &  t)
inline
BufferString& BufferString::operator= ( const BufferString b)
inline
BufferString& BufferString::operator= ( const char *  s)
inline
BufferString& BufferString::operator= ( const FixedString s)
inline
BufferString& BufferString::operator= ( const OD::String s)
inline
template<class T >
BufferString & BufferString::operator= ( const T &  t)
inline
bool BufferString::operator== ( const BufferString s) const
inline
bool BufferString::operator== ( const char *  s) const
inline
bool BufferString::operator== ( const OD::String s) const
inline
bool BufferString::operator== ( const FixedString s) const
inline
char& BufferString::operator[] ( int  idx)
inline
BufferString& BufferString::quote ( char  q = '\'')
inline
BufferString& BufferString::remove ( char  )
BufferString& BufferString::remove ( const char *  s)
inline
BufferString& BufferString::replace ( char  from,
char  to 
)
BufferString& BufferString::replace ( const char *  from,
const char *  to 
)
BufferString& BufferString::replaceAt ( int  idx,
const char *  ,
bool  cutoff = true 
)
BufferString & BufferString::set ( const char *  s)
inline
BufferString& BufferString::set ( const OD::String s)
inline
template<class T >
BufferString & BufferString::set ( const T &  t)
inline
BufferString & BufferString::set ( float  f,
int  nrdec 
)
inline
BufferString & BufferString::set ( double  d,
int  nrdec 
)
inline
bool BufferString::setBufSize ( unsigned  int)
BufferString& BufferString::setEmpty ( )
BufferString & BufferString::setLim ( float  f,
int  maxnrchars 
)
inline
BufferString & BufferString::setLim ( double  d,
int  maxnrchars 
)
inline
void BufferString::setMinBufSize ( unsigned  int)
BufferString& BufferString::toLower ( )
BufferString& BufferString::toUpper ( )
BufferString& BufferString::trimBlanks ( )

removes front and back whitespaces

BufferString& BufferString::unEmbed ( char  open,
char  close 
)
BufferString& BufferString::unQuote ( char  q = '\'')
inline

Member Data Documentation

char* BufferString::buf_
protected
unsigned int BufferString::len_
protected
const unsigned int BufferString::minlen_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019