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

Protected Attributes

char * buf_
 
unsigned int len_
 
const unsigned int minlen_
 

Private Member Functions

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

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 );
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:37

<>

Member Enumeration Documentation

◆ CleanType

Enumerator
OnlyAlphaNum 
AllowDots 
NoSpaces 
NoFileSeps 
NoSpecialChars 

Constructor & Destructor Documentation

◆ BufferString() [1/8]

BufferString::BufferString ( )
inline

◆ BufferString() [2/8]

BufferString::BufferString ( const char *  s)
inline

◆ BufferString() [3/8]

BufferString::BufferString ( const OD::String s)
inline

◆ BufferString() [4/8]

BufferString::BufferString ( int  minlen,
bool  setnull 
)

◆ BufferString() [5/8]

BufferString::BufferString ( const BufferString )

◆ BufferString() [6/8]

template<class T >
BufferString::BufferString ( const T &  t)
inlineexplicit

◆ BufferString() [7/8]

template<class T >
BufferString::BufferString ( const char *  s1,
const T &  t,
const char *  s = nullptr 
)
inline

◆ BufferString() [8/8]

BufferString::BufferString ( const QString &  )

◆ ~BufferString()

virtual BufferString::~BufferString ( )
virtual

Member Function Documentation

◆ add() [1/7]

BufferString& BufferString::add ( char  )

◆ add() [2/7]

BufferString& BufferString::add ( const char *  )

◆ add() [3/7]

BufferString& BufferString::add ( const OD::String s)
inline

◆ add() [4/7]

BufferString& BufferString::add ( const QString &  )

◆ add() [5/7]

template<class T >
BufferString & BufferString::add ( const T &  t)
inline

◆ add() [6/7]

BufferString& BufferString::add ( double  ,
int  nrdec 
)

◆ add() [7/7]

BufferString& BufferString::add ( float  ,
int  nrdec 
)

◆ addArr32Chars()

BufferString& BufferString::addArr32Chars ( const char *  ,
int   
)
private

◆ addLim() [1/2]

BufferString& BufferString::addLim ( double  ,
int  maxnrchars 
)

◆ addLim() [2/2]

BufferString& BufferString::addLim ( float  ,
int  maxnrchars 
)

◆ addNewLine()

BufferString& BufferString::addNewLine ( int  nrnewlines = 1)

◆ addSpace()

BufferString& BufferString::addSpace ( int  nrspaces = 1)

◆ addTab()

BufferString& BufferString::addTab ( int  nrtabs = 1)

◆ assignTo()

BufferString& BufferString::assignTo ( const char *  )
protected

◆ bufSize()

unsigned int BufferString::bufSize ( ) const
inline

◆ clean()

BufferString& BufferString::clean ( CleanType  ct = OnlyAlphaNum)

◆ destroy()

void BufferString::destroy ( )
inlineprivate

◆ embed()

BufferString& BufferString::embed ( char  open,
char  close 
)

◆ empty()

static const BufferString& BufferString::empty ( )
static

◆ find() [1/4]

char* BufferString::find ( char  )

◆ find() [2/4]

const char * BufferString::find ( char  c) const
inline

◆ find() [3/4]

char* BufferString::find ( const char *  )

◆ find() [4/4]

const char * BufferString::find ( const char *  s) const
inline

◆ findLast() [1/4]

char* BufferString::findLast ( char  )

◆ findLast() [2/4]

const char * BufferString::findLast ( char  c) const
inline

◆ findLast() [3/4]

char* BufferString::findLast ( const char *  )

◆ findLast() [4/4]

const char * BufferString::findLast ( const char *  s) const
inline

◆ first()

char& BufferString::first ( )
inline

◆ getCStr()

char* BufferString::getCStr ( )
inline

◆ gtBuf()

const char* BufferString::gtBuf ( ) const
overrideprotectedvirtual
Returns
empty even if underlying is null

Implements OD::String.

◆ gtStr()

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

Implements OD::String.

◆ init()

void BufferString::init ( )
private

◆ insertAt()

BufferString& BufferString::insertAt ( int  idx,
const char *   
)

◆ last()

char& BufferString::last ( )
inline

◆ minBufSize()

unsigned int BufferString::minBufSize ( ) const
inline

◆ operator!=() [1/4]

bool BufferString::operator!= ( const BufferString s) const
inline

◆ operator!=() [2/4]

bool BufferString::operator!= ( const char *  s) const
inline

◆ operator!=() [3/4]

bool BufferString::operator!= ( const OD::String s) const
inline

◆ operator!=() [4/4]

bool BufferString::operator!= ( const StringView s) const
inline

◆ operator+=() [1/3]

BufferString& BufferString::operator+= ( const char *  s)
inline

◆ operator+=() [2/3]

BufferString& BufferString::operator+= ( const OD::String s)
inline

◆ operator+=() [3/3]

template<class T >
BufferString& BufferString::operator+= ( const T &  t)
inline

◆ operator=() [1/6]

BufferString& BufferString::operator= ( const BufferString b)
inline

◆ operator=() [2/6]

BufferString& BufferString::operator= ( const char *  s)
inline

◆ operator=() [3/6]

BufferString& BufferString::operator= ( const OD::String s)
inline

◆ operator=() [4/6]

BufferString& BufferString::operator= ( const std::string &  )

◆ operator=() [5/6]

BufferString& BufferString::operator= ( const StringView s)
inline

◆ operator=() [6/6]

template<class T >
BufferString & BufferString::operator= ( const T &  t)
inline

◆ operator==() [1/4]

bool BufferString::operator== ( const BufferString s) const
inline

◆ operator==() [2/4]

bool BufferString::operator== ( const char *  s) const
inline

◆ operator==() [3/4]

bool BufferString::operator== ( const OD::String s) const
inline

◆ operator==() [4/4]

bool BufferString::operator== ( const StringView s) const
inline

◆ operator[]()

char& BufferString::operator[] ( int  idx)
inline

◆ quote()

BufferString& BufferString::quote ( char  q = '\'')
inline

◆ remove() [1/2]

BufferString& BufferString::remove ( char  )

◆ remove() [2/2]

BufferString& BufferString::remove ( const char *  s)
inline

◆ replace() [1/2]

BufferString& BufferString::replace ( char  from,
char  to 
)

◆ replace() [2/2]

BufferString& BufferString::replace ( const char *  from,
const char *  to 
)

◆ replaceAt()

BufferString& BufferString::replaceAt ( int  idx,
const char *  ,
bool  cutoff = true 
)

◆ set() [1/5]

BufferString & BufferString::set ( const char *  s)
inline

◆ set() [2/5]

BufferString& BufferString::set ( const OD::String s)
inline

◆ set() [3/5]

template<class T >
BufferString & BufferString::set ( const T &  t)
inline

◆ set() [4/5]

BufferString & BufferString::set ( double  d,
int  nrdec 
)
inline

◆ set() [5/5]

BufferString & BufferString::set ( float  f,
int  nrdec 
)
inline

◆ setBufSize()

bool BufferString::setBufSize ( unsigned int  )

◆ setEmpty()

BufferString& BufferString::setEmpty ( )

◆ setLim() [1/2]

BufferString & BufferString::setLim ( double  d,
int  maxnrchars 
)
inline

◆ setLim() [2/2]

BufferString & BufferString::setLim ( float  f,
int  maxnrchars 
)
inline

◆ setMinBufSize()

void BufferString::setMinBufSize ( unsigned int  )

◆ toLower()

BufferString& BufferString::toLower ( )

◆ toTitleCase()

BufferString& BufferString::toTitleCase ( )

◆ toUpper()

BufferString& BufferString::toUpper ( )

◆ trimBlanks()

BufferString& BufferString::trimBlanks ( )

removes front and back whitespaces

◆ unEmbed()

BufferString& BufferString::unEmbed ( char  open,
char  close 
)

◆ unQuote()

BufferString& BufferString::unQuote ( char  q = '\'')
inline

Member Data Documentation

◆ buf_

char* BufferString::buf_
protected

◆ len_

unsigned int BufferString::len_
protected

◆ minlen_

const unsigned int BufferString::minlen_
protected

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