1.3.2
CCC
 
String.cpp File Reference
#include "Basic/String.hpp"
#include "Basic/AStringable.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string.h>
#include <regex>
#include <locale>
#include <ctype.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <math.h>

Classes

class  dec_separator< T >
 

Enumerations

enum  charTypeT { other , alpha , digit }
 

Functions

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

Enumeration Type Documentation

◆ charTypeT

enum charTypeT
Enumerator
other 
alpha 
digit 

Function Documentation

◆ _charType()

charTypeT _charType ( char  c)

◆ _protectRegexp()

std::regex _protectRegexp ( const String match)

Protect the matching pattern against Crash which happens when the string contains "*" without any preceding character

Parameters
matchInitial matching pattern
Returns
The std::regex item used for further comparisons

◆ askBool()

int askBool ( const String text,
bool  defval 
)

Ask interactively for the value of one boolean

Parameters
textText of the question
defvalDefault value

◆ askDouble()

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()

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()

String concatenateString ( const String string,
double  value,
const String delim 
)

◆ concatenateStrings()

String concatenateStrings ( const String delim,
const String string1,
const String string2,
const String string3,
const String string4 
)

◆ correctNamesForDuplicates()

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()

void correctNewNameForDuplicates ( VectorString list,
int  rank 
)

◆ decodeGridSorting()

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()

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()

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()

String erase ( const String s,
const String t 
)

◆ expandList() [1/2]

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]

VectorString expandList ( const VectorString list,
const VectorString matches 
)

◆ generateMultipleNames()

VectorString generateMultipleNames ( const String radix,
int  number,
const String delim 
)

◆ getMaxStringSize()

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()

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()

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

◆ gslScanf()

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

◆ gslSPrintf()

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

◆ gslSScanf()

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

◆ gslStrcat()

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

◆ gslStrcpy()

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

◆ gslStrncpy()

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

◆ gslStrtok()

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

◆ incrementStringVersion()

String incrementStringVersion ( const String string,
int  rank,
const String delim 
)

◆ matchKeyword()

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()

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()

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

◆ toDouble()

double toDouble ( const String v,
char  dec 
)

◆ toInteger()

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]

String toLower ( const String string)

◆ toLower() [2/2]

void toLower ( String string)

◆ toString() [1/2]

String toString ( double  value)

◆ toString() [2/2]

String toString ( int  value)

◆ toUpper() [1/2]

String toUpper ( const String string)

◆ toUpper() [2/2]

void toUpper ( String string)

◆ trim()

String trim ( const String s,
const String t 
)

◆ trimLeft()

String trimLeft ( const String s,
const String t 
)

◆ trimRight()

String trimRight ( const String s,
const String t 
)