1.2.3
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

enum charTypeT
Enumerator
other 
alpha 
digit 

Function Documentation

charTypeT _charType ( char  c)
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
int askBool ( const String text,
bool  defval 
)

Ask interactively for the value of one boolean

Parameters
textText of the question
defvalDefault value
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)
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)
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 
)
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
void correctNewNameForDuplicates ( VectorString list,
int  rank 
)
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"
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
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
String erase ( const String s,
const String t 
)
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")
VectorString expandList ( const VectorString list,
const VectorString matches 
)
VectorString generateMultipleNames ( const String radix,
int  number,
const String delim 
)
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
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
int gslFScanf ( FILE *  stream,
const char *  format,
  ... 
)
int gslScanf ( const char *  format,
  ... 
)
int gslSPrintf ( char *  dst,
const char *  fmt,
  ... 
)
int gslSScanf ( const char *  str,
const char *  format,
  ... 
)
char* gslStrcat ( char *  dst,
const char *  src 
)
char* gslStrcpy ( char *  dst,
const char *  src 
)
char* gslStrncpy ( char *  dest,
const char *  src,
size_t  n 
)
char* gslStrtok ( char *  str,
const char *  delim 
)
String incrementStringVersion ( const String string,
int  rank,
const String delim 
)
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
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
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
double toDouble ( const String v,
char  dec 
)
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)
String toLower ( const String string)
void toLower ( String string)
String toString ( int  value)
String toString ( double  value)
String toUpper ( const String string)
void toUpper ( String string)
String trim ( const String s,
const String t 
)
String trimLeft ( const String s,
const String t 
)
String trimRight ( const String s,
const String t 
)