Xmipp
v3.23.11-Nereus
|
Macros | |
#define | STR_EQUAL(str1, str2) (strcmp((str1), (str2)) == 0) |
Functions | |
String | removeChar (const String &str, char character) |
String | unescape (const String &str) |
int | bestPrecision (float F, int _width) |
float | textToFloat (const char *str) |
float | textToFloat (const String &str) |
int | textToInteger (const char *str) |
size_t | textToSizeT (const char *str) |
int | textToInteger (const String &str) |
long long | textToLongLong (const char *str) |
String | floatToString (float F, int _width=8, int _prec=0) |
String | integerToString (int I, int _width=0, char fill_with='0') |
int | charToInt (const char *str) |
String | stringToString (const String &str, size_t _width=0) |
void | checkAngle (const String &str) |
void | toLower (char *_str) |
void | toLower (String &_str) |
String | simplify (const String &str) |
void | trim (String &str) |
String | removeSpaces (const String &_str) |
void | removeQuotes (char **_str) |
String | findAndReplace (const String &tInput, const String &tFind, const String &tReplace) |
String | formatString (const char *format,...) |
void | formatStringFast (String &str, const char *format,...) |
bool | matchRegExp (const String &inputString, const String &pattern) |
String | WordWrap (const String &inputString, size_t lineLength) |
String | escapeForRegularExpressions (const String &str) |
bool | endsWith (const char *str1, const char *str2) |
Tokenization | |
These functions allow to split a string into small pieces separated by blank spaces, giving you a pointer to the different word each time. The different elements from the string are selected using strtok, so after the application of this function to the input string, this is modified and NULL characters are introduced as delimiters of the elements. This is useful in most situations since after reading a list you might go on reading more things, but you must be aware of it. Here goes an example of doing so: std::cout << "Whole line: " << line << std::endl; std::cout << "First word: " << firstToken(line) << std::endl; std::cout << "Second word: " << nextToken() << std::endl; std::cout << "Third word: " << nextToken() << std::endl; ... When there are no more words, both functions return a NULL pointer. Here we make a distinction between tokens (words that might be empty) and words (words that cannot be empty, if they are then an exception or an exit error is thrown). For STL there is another way. You supply a string object and a vector of strings is returned with all the elements | |
int | splitString (const String &input, const String &delimiter, StringVector &results, bool includeEmpties=false) |
char * | firstToken (const char *str) |
char * | firstToken (const String &str) |
char * | nextToken () |
String | nextToken (const String &str, size_t &i) |
char * | firstWord (char *str) |
char * | firstWord (String &str) |
char * | nextWord () |
void | tokenize (const String &str, StringVector &tokens, const String &delimiters=" \) |
char * | memtok (char **src, char **_end, const char *sep) |
void * | _memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) |
#define STR_EQUAL | ( | str1, | |
str2 | |||
) | (strcmp((str1), (str2)) == 0) |
Macro to test if to string are the same
Definition at line 42 of file xmipp_strings.h.
void* _memmem | ( | const void * | haystack, |
size_t | haystack_len, | ||
const void * | needle, | ||
size_t | needle_len | ||
) |
int bestPrecision | ( | float | F, |
int | _width | ||
) |
Best precision for a float number.
This function returns the best precision to be used in a "printf" format if this number is to fit in a given width. It returns -1 if the exponential format is advised.
Definition at line 176 of file xmipp_strings.cpp.
int charToInt | ( | const char * | str | ) |
Character to integer conversion.
Takes a character and produces a number according to its ASCII code minus 48. For instance, ASCII=48 produces number 0, ASCII=49 produces 1, ..., ASCII=57 produces 9, ASCII=58 produces 10!!, ... This is used when you have codified numbers greater than 9 in a single character.
Definition at line 293 of file xmipp_strings.cpp.
void checkAngle | ( | const String & | str | ) |
Check angle.
If the argument is not "rot", "tilt" nor "psi" an exception is thrown
Definition at line 320 of file xmipp_strings.cpp.
bool endsWith | ( | const char * | str1, |
const char * | str2 | ||
) |
Ends with. Detects if str1 finishes with str2.
Definition at line 684 of file xmipp_strings.cpp.
Escape for regular expressions. Escape characters that could be misunderstood by regular expressions
Definition at line 677 of file xmipp_strings.cpp.
Replace. This function replaces in the string all the occurrences of tFind and replaces it with tReplace.
Definition at line 492 of file xmipp_strings.cpp.
|
inline |
Returns first token (char*).
Definition at line 274 of file xmipp_strings.h.
|
inline |
Returns first token (STL).
Definition at line 287 of file xmipp_strings.h.
char* firstWord | ( | char * | str | ) |
Get non empty string (char*).
This function returns the first word found in the given line disregarding the leading blanks. If no word is found then an exception or an exit error is produced. After calling this function the first blank character after the word is substituted by a NULL character (as it uses the function firstToken. Further word readings should use the function read_nextWord
Definition at line 453 of file xmipp_strings.cpp.
|
inline |
Get non empty string (STL).
Same as the previous function but for STL strings
Definition at line 335 of file xmipp_strings.h.
String floatToString | ( | float | F, |
int | _width = 8 , |
||
int | _prec = 0 |
||
) |
Float to string conversion.
If precision==0 the precision is automatically computed in such a way that the number fits the width (the exponential format might be chosen). If precision==-1 then the exponential format is forced. If width==0 then the minimum width is used.
Definition at line 204 of file xmipp_strings.cpp.
String formatString | ( | const char * | format, |
... | |||
) |
Obtain an string from a format in the way of printf works Example: formatString("vectorHeader@%s",fn_out.c_str())
Definition at line 602 of file xmipp_strings.cpp.
void formatStringFast | ( | String & | str, |
const char * | format, | ||
... | |||
) |
Obtain an string from a format in the way of printf works
Definition at line 617 of file xmipp_strings.cpp.
String integerToString | ( | int | I, |
int | _width = 0 , |
||
char | fill_with = '0' |
||
) |
Integer to string conversion.
If width==0 then writes the number with the number of digits needed. The fill_with field indicates which is the filling character for the left positions.
Definition at line 253 of file xmipp_strings.cpp.
True if the inputString matches the regular expression in pattern
Definition at line 629 of file xmipp_strings.cpp.
char* memtok | ( | char ** | src, |
char ** | _end, | ||
const char * | sep | ||
) |
Tokenizer for char arrays. Similar to strtok but does NOT modify the input array src is a pointer to the array beginning. It may be modified to trim the token _end is a pointer to the end of the token sep is an array with the valid separator
Definition at line 525 of file xmipp_strings.cpp.
|
inline |
Returns next token.
This functions returns the next word of the line we have given last as parameter to firstToken.
Definition at line 309 of file xmipp_strings.h.
Returns next token.
It reads from position i. Returns (in i) the following position to search on. When there are no more tokens. It returns "".
Definition at line 436 of file xmipp_strings.cpp.
|
inline |
Get next non empty string.
This is the same as the nextToken, but an exception is thrown or an exit error produced if the word is empty
Definition at line 346 of file xmipp_strings.h.
Removes all occurrences of 'character' from the string no matter where they are
Definition at line 36 of file xmipp_strings.cpp.
void removeQuotes | ( | char ** | _str | ) |
Remove quotes.
This function removes the first character if it is a double or single quote, as well as the last character. The char pointer might be moved.
Definition at line 363 of file xmipp_strings.cpp.
Remove consecutive spaces.
All consecutive spaces are replaced by a single one and starting and finishing spaces are removed
Definition at line 336 of file xmipp_strings.cpp.
Removes white spaces from the beginning and the end of the string as well as escaped characters and simplifies the rest of groups of white spaces of the string to a single white space
Definition at line 69 of file xmipp_strings.cpp.
int splitString | ( | const String & | input, |
const String & | delimiter, | ||
StringVector & | results, | ||
bool | includeEmpties = false |
||
) |
Split a STL string given some delimiter.
Returns a the number of tokens found. The tokens are in the variable results.
Definition at line 379 of file xmipp_strings.cpp.
String to string with given length conversion.
The output string will have the information of the input one with the given width. If the width is smaller than the string length then the string is truncated and if it is greater the string is right padded with spaces. If width==0 then the same string is returned.
Definition at line 308 of file xmipp_strings.cpp.
float textToFloat | ( | const char * | str | ) |
|
inline |
int textToInteger | ( | const char * | str | ) |
|
inline |
long long textToLongLong | ( | const char * | str | ) |
String (char*) to long long integer conversion.
Definition at line 163 of file xmipp_strings.cpp.
size_t textToSizeT | ( | const char * | str | ) |
void tokenize | ( | const String & | str, |
StringVector & | tokens | ||
) |
void toLower | ( | char * | _str | ) |
To lower.
All characters between A-Z are brought to a-z. Result is rewritten on input string
Definition at line 413 of file xmipp_strings.cpp.
void toLower | ( | String & | _str | ) |
void trim | ( | String & | str | ) |
Remove trailing spaces
Definition at line 109 of file xmipp_strings.cpp.
Removes escaped symbols ESC+n, t, v, b, r, f, and a
Definition at line 49 of file xmipp_strings.cpp.
split long comments in several lines starting with #
Definition at line 645 of file xmipp_strings.cpp.