1.3.2
CCC
 
String.hpp File Reference
#include "gstlearn_export.hpp"
#include "geoslib_define.h"
#include "Basic/AException.hpp"
#include "Basic/VectorT.hpp"
#include "Basic/VectorNumT.hpp"
#include <memory>

Macros

#define SPACES   " \t\r\n"
 

Functions

GSTLEARN_EXPORT void skipBOM (std::ifstream &ins)
 
GSTLEARN_EXPORT String toUpper (const String &string)
 
GSTLEARN_EXPORT String toLower (const String &string)
 
GSTLEARN_EXPORT void toUpper (String &string)
 
GSTLEARN_EXPORT void toLower (String &string)
 
GSTLEARN_EXPORT bool matchKeyword (const String &string1, const String &string2, bool caseSensitive=true)
 
GSTLEARN_EXPORT bool matchRegexp (const String &string1, const String &string2, bool caseSensitive=true)
 
GSTLEARN_EXPORT int getRankInList (const VectorString &list, const String &string, bool caseSensitive=true)
 
GSTLEARN_EXPORT int decodeInString (const String &symbol, const String &node, int *facies, bool caseSensitive=true)
 
GSTLEARN_EXPORT int decodeInList (const VectorString &symbols, const String &node, int *rank, int *facies, bool caseSenstive=true)
 
GSTLEARN_EXPORT void correctNamesForDuplicates (VectorString &list)
 
GSTLEARN_EXPORT void correctNewNameForDuplicates (VectorString &list, int rank)
 
GSTLEARN_EXPORT String incrementStringVersion (const String &string, int rank=1, const String &delim=".")
 
GSTLEARN_EXPORT String concatenateString (const String &string, double value, const String &delim="-")
 
GSTLEARN_EXPORT String concatenateStrings (const String &delimt=".", const String &string1="", const String &string2="", const String &string3="", const String &string4="")
 
GSTLEARN_EXPORT VectorString generateMultipleNames (const String &radix, int number, const String &delim="-")
 
GSTLEARN_EXPORT VectorString expandList (const VectorString &list, const String &match, bool onlyOne=false)
 
GSTLEARN_EXPORT VectorString expandList (const VectorString &list, const VectorString &matches)
 
GSTLEARN_EXPORT int getMaxStringSize (const VectorString &list)
 
GSTLEARN_EXPORT VectorString separateKeywords (const String &code)
 
GSTLEARN_EXPORT int toInteger (const String &v)
 
GSTLEARN_EXPORT double toDouble (const String &v, char dec='.')
 
GSTLEARN_EXPORT String toString (int value)
 
GSTLEARN_EXPORT String toString (double value)
 
GSTLEARN_EXPORT int askInt (const String &text, int defval=ITEST, bool authTest=false)
 
GSTLEARN_EXPORT double askDouble (const String &text, double defval=TEST, bool authTest=false)
 
GSTLEARN_EXPORT int askBool (const String &text, bool defval=false)
 
GSTLEARN_EXPORT String trimRight (const String &s, const String &t=SPACES)
 
GSTLEARN_EXPORT String trimLeft (const String &s, const String &t=SPACES)
 
GSTLEARN_EXPORT String trim (const String &s, const String &t=SPACES)
 
GSTLEARN_EXPORT String erase (const String &s, const String &t=SPACES)
 
GSTLEARN_EXPORT VectorInt decodeGridSorting (const String &name, const VectorInt &nx, bool verbose=false)
 
GSTLEARN_EXPORT char * gslStrcpy (char *dst, const char *src)
 
GSTLEARN_EXPORT char * gslStrcat (char *dst, const char *src)
 
GSTLEARN_EXPORT int gslSPrintf (char *dst, const char *fmt,...)
 
GSTLEARN_EXPORT char * gslStrtok (char *str, const char *delim)
 
GSTLEARN_EXPORT char * gslStrncpy (char *dest, const char *src, size_t n)
 
GSTLEARN_EXPORT int gslScanf (const char *format,...)
 
GSTLEARN_EXPORT int gslSScanf (const char *str, const char *format,...)
 
GSTLEARN_EXPORT int gslFScanf (FILE *stream, const char *format,...)
 

Macro Definition Documentation

◆ SPACES

#define SPACES   " \t\r\n"

Function Documentation

◆ askBool()

GSTLEARN_EXPORT int askBool ( const String text,
bool  defval 
)

Ask interactively for the value of one boolean

Parameters
textText of the question
defvalDefault value

◆ askDouble()

GSTLEARN_EXPORT double askDouble ( const String text,
double  defval,
bool  authTest 
)

Ask interactively for the value of one Real (Double)

Parameters
textText of the question
defvalDefault value (or IFFFF)
authTestTrue if a TEST answer is authorized (TEST)

◆ askInt()

GSTLEARN_EXPORT int askInt ( const String text,
int  defval,
bool  authTest 
)

Ask interactively for the value of one integer

Parameters
textText of the question
defvalDefault value (or IFFFF)
authTestTrue if TEST value is authorized (TEST)

◆ concatenateString()

GSTLEARN_EXPORT String concatenateString ( const String string,
double  value,
const String delim = "-" 
)

◆ concatenateStrings()

GSTLEARN_EXPORT String concatenateStrings ( const String delimt = ".",
const String string1 = "",
const String string2 = "",
const String string3 = "",
const String string4 = "" 
)

◆ correctNamesForDuplicates()

GSTLEARN_EXPORT void correctNamesForDuplicates ( VectorString list)

Check that the names in 'list' are not conflicting with any previous name. If it does, increment its name by a version number.

Parameters
list

◆ correctNewNameForDuplicates()

GSTLEARN_EXPORT void correctNewNameForDuplicates ( VectorString list,
int  rank 
)

◆ decodeGridSorting()

GSTLEARN_EXPORT VectorInt decodeGridSorting ( const String string,
const VectorInt nx,
bool  verbose 
)

Decode the grid sorting order

Returns
Array describing the order
Parameters
[in]stringName of the sorting string
[in]nxArray giving the number of cells per direction
[in]verboseVerbose flag
Remarks
The value of order[i] gives the dimension of the space along
which sorting takes place at rank "i". This value is positive
for increasing order and negative for decreasing order.
'order' values start from 1 (for first space dimension)
Example: "+x1-x3+x2"

◆ decodeInList()

GSTLEARN_EXPORT int decodeInList ( const VectorString symbols,
const String node,
int *  rank,
int *  facies,
bool  caseSensitive 
)

Decode the input string 'node' as a one-character keyword followed by an integer rank The keyword must match one of the symbols: its rank is 'rank' The integer rank is returned as 'facies'

Parameters
symbols
node
rank
facies
caseSensitive
Returns
Error returned code

◆ decodeInString()

GSTLEARN_EXPORT int decodeInString ( const String symbol,
const String node,
int *  facies,
bool  caseSensitive 
)

Decode the input string 'node' as a one-character keyword followed by an integer rank The keyword must match the symbol. The integer rank is returned as 'facies'

Parameters
symbol
node
facies
caseSensitive
Returns
Error returned code

◆ erase()

GSTLEARN_EXPORT String erase ( const String s,
const String t = SPACES 
)

◆ expandList() [1/2]

GSTLEARN_EXPORT VectorString expandList ( const VectorString list,
const String match,
bool  onlyOne 
)

Returns the list of matching names

Parameters
listList of eligible names
matchName to be expanded
onlyOneTrue if the expanded list may only contain a single name
Returns
The list of matching possibilities
Note
The returned list is empty if no match has been found or if several matches have been found but onlyOne flag is True (message issued).
Remarks
Example: expandList(["x", "y", "xcol"], "x.*") -> ("x", "xcol")

◆ expandList() [2/2]

GSTLEARN_EXPORT VectorString expandList ( const VectorString list,
const VectorString matches 
)

◆ generateMultipleNames()

GSTLEARN_EXPORT VectorString generateMultipleNames ( const String radix,
int  number,
const String delim = "-" 
)

◆ getMaxStringSize()

GSTLEARN_EXPORT int getMaxStringSize ( const VectorString list)

Returns the maximum string size of a list of strings

Parameters
listList of strings
Returns
The maximum number of characters

◆ getRankInList()

GSTLEARN_EXPORT int getRankInList ( const VectorString list,
const String match,
bool  caseSensitive 
)

Return the rank of the (first) item in 'list' which matches 'match'

Parameters
listList of keywords used for search
matchSearched pattern
caseSensitiveCase Sensitive flag
Returns
The index of the matching item or -1

◆ gslFScanf()

GSTLEARN_EXPORT int gslFScanf ( FILE *  stream,
const char *  format,
  ... 
)

◆ gslScanf()

GSTLEARN_EXPORT int gslScanf ( const char *  format,
  ... 
)

◆ gslSPrintf()

GSTLEARN_EXPORT int gslSPrintf ( char *  dst,
const char *  fmt,
  ... 
)

◆ gslSScanf()

GSTLEARN_EXPORT int gslSScanf ( const char *  str,
const char *  format,
  ... 
)

◆ gslStrcat()

GSTLEARN_EXPORT char* gslStrcat ( char *  dst,
const char *  src 
)

◆ gslStrcpy()

GSTLEARN_EXPORT char* gslStrcpy ( char *  dst,
const char *  src 
)

◆ gslStrncpy()

GSTLEARN_EXPORT char* gslStrncpy ( char *  dest,
const char *  src,
size_t  n 
)

◆ gslStrtok()

GSTLEARN_EXPORT char* gslStrtok ( char *  str,
const char *  delim 
)

◆ incrementStringVersion()

GSTLEARN_EXPORT String incrementStringVersion ( const String string,
int  rank = 1,
const String delim = "." 
)

◆ matchKeyword()

GSTLEARN_EXPORT bool matchKeyword ( const String string1,
const String string2,
bool  caseSensitive 
)

Check if two keywords are similar, up to their case

Parameters
string1First keyword
string2Second keyword
caseSensitivetrue if the case of both strings should be considered Otherwise, both strings are converted into upper case before comparison
Returns
true if both keywords are identical; false otherwise

◆ matchRegexp()

GSTLEARN_EXPORT bool matchRegexp ( const String string1,
const String string2,
bool  caseSensitive 
)

Check if two keywords match up to "Regular Expression" on the second string and their case

Parameters
string1First keyword
string2Second keyword (through Regular Expression interpretation)
caseSensitivetrue if the case of both strings should be considered Otherwise, both strings are converted into upper case before comparison
Returns
true if both keywords are identical; false otherwise

◆ separateKeywords()

GSTLEARN_EXPORT VectorString separateKeywords ( const String code)

Separate keywords in the input string The keywords are identified when switching between alpha, digit and other

Parameters
codeString to be split
Returns

◆ skipBOM()

GSTLEARN_EXPORT void skipBOM ( std::ifstream &  ins)

This file contains all the OLD-STYLE declarations causing warnings on Windows They should gradually be replaced by modern statements However, they are kept there to keep track on these statements

◆ toDouble()

GSTLEARN_EXPORT double toDouble ( const String v,
char  dec = '.' 
)

◆ toInteger()

GSTLEARN_EXPORT int toInteger ( const String v)

Decode an integer from a string. Returns ITEST if impossible

Parameters
vString to be decoded
Returns
The integer value or ITEST (in case of failure)

◆ toLower() [1/2]

GSTLEARN_EXPORT String toLower ( const String string)

◆ toLower() [2/2]

GSTLEARN_EXPORT void toLower ( String string)

◆ toString() [1/2]

GSTLEARN_EXPORT String toString ( double  value)

◆ toString() [2/2]

GSTLEARN_EXPORT String toString ( int  value)

◆ toUpper() [1/2]

GSTLEARN_EXPORT String toUpper ( const String string)

◆ toUpper() [2/2]

GSTLEARN_EXPORT void toUpper ( String string)

◆ trim()

GSTLEARN_EXPORT String trim ( const String s,
const String t = SPACES 
)

◆ trimLeft()

GSTLEARN_EXPORT String trimLeft ( const String s,
const String t = SPACES 
)

◆ trimRight()

GSTLEARN_EXPORT String trimRight ( const String s,
const String t = SPACES 
)