OpendTect-6_4  6.4
Namespaces | Macros | Functions
string2.h File Reference
Include dependency graph for string2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 OD
 OpendTect.
 

Macros

#define mSkipBlanks(ptr)   { if ( ptr ) { while ( *(ptr) && iswspace(*(ptr)) ) (ptr)++; } }
 Advances given pointer to first non-whitespace. More...
 
#define mSkipNonBlanks(ptr)   { if ( ptr ) { while ( *(ptr) && !iswspace(*(ptr)) ) (ptr)++; } }
 Advances given pointer to first whitespace. More...
 
#define mTrimBlanks(ptr)   { mSkipBlanks(ptr); removeTrailingBlanks(ptr); }
 Advances to first whitespace and removes trailing whitespace. More...
 

Functions

const char * toString (int)
 
const char * toString (unsigned int)
 
const char * toString (int64_t)
 
const char * toString (uint64_t)
 
const char * toString (float)
 
const char * toString (float, int nrdec)
 
const char * toString (float, char format, int precision)
 
const char * toStringLim (float, int maxtxtwdth)
 
const char * toStringPrecise (float)
 
const char * toString (double)
 
const char * toString (double, int nrdec)
 
const char * toString (double, char format, int precision)
 
const char * toStringLim (double, int maxtxtwdth)
 
const char * toStringPrecise (double)
 
const char * toString (short)
 
const char * toString (const char *)
 
const char * toString (signed char)
 
const char * toString (bool)
 
const char * toString (const OD::String &)
 
const char * toString (const CompoundKey &)
 
bool getFromString (int &, const char *, int udfval)
 
bool getFromString (int64_t &, const char *, int64_t udfval)
 
bool getFromString (float &, const char *, float udfval)
 
bool getFromString (double &, const char *, double udfval)
 
bool getFromString (bool &, const char *)
 
bool yesNoFromString (const char *)
 
bool toBool (const char *s, bool defval=true)
 
float toFloat (const char *s, float defval=0)
 
double toDouble (const char *s, double defval=0)
 
int toInt (const char *s, int defval=0)
 
int64_t toInt64 (const char *s, int64_t defval=0)
 
bool caseInsensitiveEqual (const char *, const char *, int match_nrchars=-1)
 
bool stringStartsWith (const char *startstring, const char *maybebigger)
 
bool stringStartsWithCI (const char *, const char *)
 
bool stringEndsWith (const char *endstring, const char *maybebigger)
 
bool stringEndsWithCI (const char *, const char *)
 
void removeTrailingBlanks (char *)
 
void cleanupString (char *, bool, bool, bool)
 
bool isNumberString (const char *, bool int_only=false)
 
bool isAlphaNumString (const char *, bool allowspace=false)
 
const char * getNextWord (const char *, char *)
 
const char * firstOcc (const char *, char)
 
char * firstOcc (char *, char)
 
const char * lastOcc (const char *, char)
 
char * lastOcc (char *, char)
 
const char * firstOcc (const char *, const char *)
 
char * firstOcc (char *, const char *)
 
const char * lastOcc (const char *, const char *)
 
char * lastOcc (char *, const char *)
 
const char * getYesNoString (bool)
 
const char * getDistUnitString (bool isfeet, bool withparentheses)
 
const char * getVelUnitString (bool isfeet, bool withparentheses)
 
const char * getRankPostFix (int)
 
const char * getBytesString (uint64_t)
 
const char * getLimitedDisplayString (const char *, int nrchars, bool trimright)
 
int getIndexInStringArrCI (const char *, const char *const *arr, int startnr=0, int nr_chars_to_match=0, int notfoundidx=-1)
 
int getIndexInStringArrCI (const char *, const BufferStringSet set, int startnr=0, int nr_chars_to_match=0, int notfoundidx=-1)
 
const char * getAreaString (float m2, bool parensonunit, char *str=0)
 
const char * getAreaString (float m2, bool xyinfeet, int precision, bool parensonunit, char *str=0)
 
char * truncateString (char *str, int maxlen)
 

Macro Definition Documentation

#define mSkipBlanks (   ptr)    { if ( ptr ) { while ( *(ptr) && iswspace(*(ptr)) ) (ptr)++; } }

Advances given pointer to first non-whitespace.

#define mSkipNonBlanks (   ptr)    { if ( ptr ) { while ( *(ptr) && !iswspace(*(ptr)) ) (ptr)++; } }

Advances given pointer to first whitespace.

#define mTrimBlanks (   ptr)    { mSkipBlanks(ptr); removeTrailingBlanks(ptr); }

Advances to first whitespace and removes trailing whitespace.

Function Documentation

bool caseInsensitiveEqual ( const char *  ,
const char *  ,
int  match_nrchars = -1 
)

stricmp with option to compare part, default is all

void cleanupString ( char *  ,
bool  ,
bool  ,
bool   
)

replaces whitespace, file separators, dots -> underscores.

const char* firstOcc ( const char *  ,
char   
)

Replacement for strchr: const version

char* firstOcc ( char *  ,
char   
)

Replacement for strchr: non-const version

const char* firstOcc ( const char *  ,
const char *   
)

Replacement for strstr: const version

char* firstOcc ( char *  ,
const char *   
)

Replacement for strstr: non-const version

const char* getAreaString ( float  m2,
bool  parensonunit,
char *  str = 0 
)
const char* getAreaString ( float  m2,
bool  xyinfeet,
int  precision,
bool  parensonunit,
char *  str = 0 
)

Returns a string with an area and its unit, depending on survey and area size, unit is ft^2, m^2, km^2 or mile^2.

const char* getBytesString ( uint64_t  )

returns a nicely, readable size, in bytes, KB, MB, GB, or TB

const char* getDistUnitString ( bool  isfeet,
bool  withparentheses 
)

returns ptr to static buffer with "m" or "ft"

bool getFromString ( int &  ,
const char *  ,
int  udfval 
)
bool getFromString ( int64_t &  ,
const char *  ,
int64_t  udfval 
)
bool getFromString ( float &  ,
const char *  ,
float  udfval 
)
bool getFromString ( double &  ,
const char *  ,
double  udfval 
)
bool getFromString ( bool &  ,
const char *   
)
int getIndexInStringArrCI ( const char *  ,
const char *const *  arr,
int  startnr = 0,
int  nr_chars_to_match = 0,
int  notfoundidx = -1 
)

Finds a string in string array, case insensitive

int getIndexInStringArrCI ( const char *  ,
const BufferStringSet  set,
int  startnr = 0,
int  nr_chars_to_match = 0,
int  notfoundidx = -1 
)

Finds a string in string array, case insensitive

const char* getLimitedDisplayString ( const char *  ,
int  nrchars,
bool  trimright 
)

returns a string for display, never larger than nrchars

const char* getNextWord ( const char *  ,
char *   
)

fills a buffer with the next word (delimited by whitespace). It returns a ptr just after the word.

const char* getRankPostFix ( int  )

returns "th" or "st" or "nd" or "rd"; like in 1st, 2nd, 3rd etc.

const char* getVelUnitString ( bool  isfeet,
bool  withparentheses 
)

returns ptr to static buffer with "m/s" or "ft/s"

const char* getYesNoString ( bool  )

returns ptr to static buffer with "yes" or "No".

bool isAlphaNumString ( const char *  ,
bool  allowspace = false 
)

tells whether has printable characters only.

bool isNumberString ( const char *  ,
bool  int_only = false 
)

tells whether a string holds a parseable number

const char* lastOcc ( const char *  ,
char   
)

Replacement for strrchr: const version

char* lastOcc ( char *  ,
char   
)

Replacement for strrchr: non-const version

const char* lastOcc ( const char *  ,
const char *   
)

Replacement for (imaginary) strrstr: const version

char* lastOcc ( char *  ,
const char *   
)

Replacement for (imaginary) strrstr: non-const version

void removeTrailingBlanks ( char *  )

bluntly puts a '\0' on trailing white space.

bool stringEndsWith ( const char *  endstring,
const char *  maybebigger 
)

checks whether a string is the end of another string.

bool stringEndsWithCI ( const char *  ,
const char *   
)

is a case insensitive version of stringEndsWith

bool stringStartsWith ( const char *  startstring,
const char *  maybebigger 
)

checks whether a string is the start of another string.

bool stringStartsWithCI ( const char *  ,
const char *   
)

is a case insensitive version of matchString

bool toBool ( const char *  s,
bool  defval = true 
)
inline
double toDouble ( const char *  s,
double  defval = 0 
)
inline
float toFloat ( const char *  s,
float  defval = 0 
)
inline
int toInt ( const char *  s,
int  defval = 0 
)
inline
int64_t toInt64 ( const char *  s,
int64_t  defval = 0 
)
inline
const char* toString ( int  )
const char * toString ( unsigned  int)
const char* toString ( int64_t  )
const char* toString ( uint64_t  )
const char* toString ( float  )
const char* toString ( float  ,
int  nrdec 
)
const char* toString ( float  ,
char  format,
int  precision 
)
const char* toString ( double  )
const char* toString ( double  ,
int  nrdec 
)
const char* toString ( double  ,
char  format,
int  precision 
)
const char* toString ( short  )
const char* toString ( const char *  )
const char* toString ( signed  char)
const char* toString ( bool  )
const char* toString ( const OD::String )
const char* toString ( const CompoundKey )
const char* toStringLim ( float  ,
int  maxtxtwdth 
)
const char* toStringLim ( double  ,
int  maxtxtwdth 
)
const char* toStringPrecise ( float  )
const char* toStringPrecise ( double  )
char* truncateString ( char *  str,
int  maxlen 
)

If str is longer than maxlen-4, string will be truncated and a " ..." will be appended".

bool yesNoFromString ( const char *  )

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