IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Various string operations, random strings, random characters, etc. More...
Static Public Member Functions | |
static string | GetCommandLine (string CommandName, string[] CommandArguments) |
Assembles and returns the commandline string that corresponds to the specified command name and arguments. | |
static string | GetCommandLine (string[] commandNameAndArguments) |
Assembles and returns the commandline string that corresponds to the specified command name and arguments. | |
static string[] | GetArgumentsArray (string commandLine) |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array. | |
static void | GetArguments (string commandLine, ref List< string > ret) |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array. | |
static char | RandomCharCapitalLetter () |
Returns a random character that is a capital letter (A-Z) | |
static char | RandomCharSmallLetter () |
Returns a random character that is a small letter (a-z) | |
static char | RandomCharNumeric () |
Returns a random numeric character (0-9) | |
static char | RandomChar (CharType typeflags) |
Returns a random character whose type is specified by type flags. Type flags can be combined by bitwise operations. | |
static char | RandomChar () |
Returns a random character that is either a capital letter (A-Y) or a small letter (a-z). Type flags can be combined by bitwise operations. | |
static string | RandomString (int length, CharType flags, bool firstletter) |
Returns a randomly generated string of a specified length whose characters are of specified type(result). It can also be specified that the first character is a letter. | |
static string | RandomString (int length, CharType flags) |
Returns a randomly generated string of a specified length whose characters are of specified type(result). | |
static string | RandomString (int length, bool firstletter) |
Returns a randomly generated string composed of alphanumeric characters. It can be specified that the first character is a letter. | |
static string | RandomString (int length) |
Returns a randomly generated string of a specified length containing alphanumeric characters. The first character is a letter. | |
static string | RandomString () |
Returns a randomly generated string of a random length containing alphanumeric characters. The first character is a letter. Length is between 1 and the value specified by the MaxStringLength property. | |
static bool | IsAscii (char ch) |
Returns true if the specified character is an ASCII characters, and false otherwise. Characters that qualify: from 0 to 255. | |
static bool | IsAsciiLetter (char ch) |
Returns true if the specified character is an ASCII letter, and false otherwise. Characters that qualify: from 'a' to 'z' and from 'A' to 'Z'. | |
static bool | IsAsciiDigit (char ch) |
Returns true if the specified character is an ASCII digit, and false otherwise. Characters that qualify: from '0' to '9'. | |
static bool | IsAsciiLetterOrDigit (char ch) |
Returns true if the specified character is either an ASCII letter or an ASCII digit, and false otherwise. Characters that qualify: from 'a' to 'z', from 'A' to 'Z' and from '0' to '9'. | |
static bool | IsVarName (char[] str) |
Returns true if the string corresponding to the specified array of characters is a legal standard representation of a variable name, and false otherwise. | |
static bool | IsVariableName (string str) |
Returns true if the specified string is a legal standard representation of a variable name, and false otherwise. | |
static bool | IsAsciiString (char[] str) |
Returns true if the string corresponding to the specified array of characters is an ASCII string (i.e. it contains only ASCII characters - from 0 to 255), and false otherwise. True is returned for null or empty strings. | |
static bool | IsAsciiString (string str) |
Returns true if the string specified string is an ASCII string (i.e. it contains only ASCII characters - from 0 to 255), and false otherwise. | |
static bool | ToBoolean (string strsetting) |
Converts a string representation of a boolean setting to boolean. Strings "true", "yes" and "on" (regardless of capitalization) or non-zero integer representations result to true, "false", "no", "off" or zero integer representations result in false. | |
static bool | IsBoolean (string str) |
Returns a boolean value indicating whether the specified string can represent a boolean value. Strings "true", "yes" and "on" (regardless of capitalization) or non-zero integer representations result to true, "false", "no", "off" or zero integer representations result in false.This method is NOT CONSISTENT with bool.TryParse but with UtilStr.ToBoolean. | |
static long | ToInt (string strsetting) |
Converts a string representation of an integer setting to an integer value. If the setting is not defined then 0 is returned. | |
static long | ToInt (string strsetting, long defaultvalue) |
Converts a string representation of an integer setting to an integer value. | |
static bool | IsInt (string str) |
Returns a boolean value indicating whether the specified string is a valid representation of an integer number. | |
static double | ToDouble (string strsetting) |
Converts a string representation of a double setting to an integer value. If the setting is not defined then 0 is returned. | |
static double | ToDouble (string strsetting, long defaultvalue) |
Converts a string representation of a double value to a number of type double. | |
static bool | IsDouble (string str) |
Returns a boolean value indicating whether the specified string is a valid representation of a number (of type double). | |
static string | Load (string filePath) |
Loads complete file contents into a stiring and returnes that string. | |
static void | Load (string filePath, ref string readString) |
Loads complete file contents into the specified stiring. | |
static void | Save (string str, string filePath, bool append) |
Saves the specified string to a specified file. If the specified file does not exists then it is created anew if possible. A boolean argument specifis whether to overwrite existing files or to append the string at the end of the file. | |
static void | Save (string str, string filePath) |
Saves the specified string to a specified file. If the file already exists then is content is overwritten. If the file does not yet exist then it is created anew. | |
static void | Append (string str, string filePath) |
Saves the specified string to a specified file. If the file already exists then string is appended at the end of the current file contents. If the file does not yet exist then it is created anew. | |
Properties | |
static int | MaxStringLength [get, set] |
Get or sets maximal length for generated strings (must be GREATER THAN 0). | |
Static Private Member Functions | |
static void | GetArguments (string commandLine, ref List< string > ret, ref List< string > aux) |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array. | |
Static Private Attributes | |
static Random | rndgen = null |
static int | _maxStringLength = 100 |
Various string operations, random strings, random characters, etc.
$A Igor xx;
static string IG::Lib::UtilStr::GetCommandLine | ( | string | CommandName, |
string[] | CommandArguments | ||
) | [inline, static] |
Assembles and returns the commandline string that corresponds to the specified command name and arguments.
CommandName | Command name. |
CommandArguments | Array of command arguments. |
static string IG::Lib::UtilStr::GetCommandLine | ( | string[] | commandNameAndArguments | ) | [inline, static] |
Assembles and returns the commandline string that corresponds to the specified command name and arguments.
commandNameAndArguments | Array containing command names (0-th element) and its arguments. |
static string [] IG::Lib::UtilStr::GetArgumentsArray | ( | string | commandLine | ) | [inline, static] |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.
commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally. |
static void IG::Lib::UtilStr::GetArguments | ( | string | commandLine, |
ref List< string > | ret | ||
) | [inline, static] |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.
commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally. |
ret | List in which the parsed arguments are stored. |
static void IG::Lib::UtilStr::GetArguments | ( | string | commandLine, |
ref List< string > | ret, | ||
ref List< string > | aux | ||
) | [inline, static, private] |
Parses a command line and extracts arguments from it. Arguments can be separated according to usual rules for command-line arguments: spaces are separators, there can be arbitraty number of spaces, and if we want an argument to contain spaces, we must enclose it in double quotes. Command line can also contain the command name followed by arguments. In this case it is treated in the same way, and command can be obtained simply as the first string in the returned array.
commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally. |
ret | List in which the parsed arguments are stored. |
aux | Auxiliary list for storing intermediate results. |
static char IG::Lib::UtilStr::RandomCharCapitalLetter | ( | ) | [inline, static] |
Returns a random character that is a capital letter (A-Z)
static char IG::Lib::UtilStr::RandomCharSmallLetter | ( | ) | [inline, static] |
Returns a random character that is a small letter (a-z)
static char IG::Lib::UtilStr::RandomCharNumeric | ( | ) | [inline, static] |
Returns a random numeric character (0-9)
static char IG::Lib::UtilStr::RandomChar | ( | CharType | typeflags | ) | [inline, static] |
Returns a random character whose type is specified by type flags. Type flags can be combined by bitwise operations.
typeflags | Flags specifying the permitted types of the returned character. |
static char IG::Lib::UtilStr::RandomChar | ( | ) | [inline, static] |
Returns a random character that is either a capital letter (A-Y) or a small letter (a-z). Type flags can be combined by bitwise operations.
static string IG::Lib::UtilStr::RandomString | ( | int | length, |
CharType | flags, | ||
bool | firstletter | ||
) | [inline, static] |
Returns a randomly generated string of a specified length whose characters are of specified type(result). It can also be specified that the first character is a letter.
length | Length of the string. |
flags | Flags that determine permitted types of characters contained in the string. |
firstletter | If true then first character of the generated string will be a letter. Warning: when the value is true, make sure that either capital or small letters are permitted character type. |
static string IG::Lib::UtilStr::RandomString | ( | int | length, |
CharType | flags | ||
) | [inline, static] |
Returns a randomly generated string of a specified length whose characters are of specified type(result).
length | Length of the string. It is not guaranteed that the first character is a letter. |
flags | Flags that determine permitted types of characters contained in the string. |
static string IG::Lib::UtilStr::RandomString | ( | int | length, |
bool | firstletter | ||
) | [inline, static] |
Returns a randomly generated string composed of alphanumeric characters. It can be specified that the first character is a letter.
length | Length of the string. |
firstletter | If true then first character of the generated string will be a letter. |
static string IG::Lib::UtilStr::RandomString | ( | int | length | ) | [inline, static] |
Returns a randomly generated string of a specified length containing alphanumeric characters. The first character is a letter.
length | Length of the string. |
static string IG::Lib::UtilStr::RandomString | ( | ) | [inline, static] |
Returns a randomly generated string of a random length containing alphanumeric characters. The first character is a letter. Length is between 1 and the value specified by the MaxStringLength property.
static bool IG::Lib::UtilStr::IsAscii | ( | char | ch | ) | [inline, static] |
Returns true if the specified character is an ASCII characters, and false otherwise. Characters that qualify: from 0 to 255.
ch | Character that is querried. |
static bool IG::Lib::UtilStr::IsAsciiLetter | ( | char | ch | ) | [inline, static] |
Returns true if the specified character is an ASCII letter, and false otherwise. Characters that qualify: from 'a' to 'z' and from 'A' to 'Z'.
ch | Character that is querried. |
static bool IG::Lib::UtilStr::IsAsciiDigit | ( | char | ch | ) | [inline, static] |
Returns true if the specified character is an ASCII digit, and false otherwise. Characters that qualify: from '0' to '9'.
ch | Character that is querried. |
static bool IG::Lib::UtilStr::IsAsciiLetterOrDigit | ( | char | ch | ) | [inline, static] |
Returns true if the specified character is either an ASCII letter or an ASCII digit, and false otherwise. Characters that qualify: from 'a' to 'z', from 'A' to 'Z' and from '0' to '9'.
ch | Character that is querried. |
static bool IG::Lib::UtilStr::IsVarName | ( | char[] | str | ) | [inline, static] |
Returns true if the string corresponding to the specified array of characters is a legal standard representation of a variable name, and false otherwise.
str | Array representation of the string that is queried. |
static bool IG::Lib::UtilStr::IsVariableName | ( | string | str | ) | [inline, static] |
Returns true if the specified string is a legal standard representation of a variable name, and false otherwise.
str | String that is queried. |
static bool IG::Lib::UtilStr::IsAsciiString | ( | char[] | str | ) | [inline, static] |
Returns true if the string corresponding to the specified array of characters is an ASCII string (i.e. it contains only ASCII characters - from 0 to 255), and false otherwise. True is returned for null or empty strings.
str | Array representation of the string that is queried. |
static bool IG::Lib::UtilStr::IsAsciiString | ( | string | str | ) | [inline, static] |
Returns true if the string specified string is an ASCII string (i.e. it contains only ASCII characters - from 0 to 255), and false otherwise.
str | String that is queried. |
static bool IG::Lib::UtilStr::ToBoolean | ( | string | strsetting | ) | [inline, static] |
Converts a string representation of a boolean setting to boolean. Strings "true", "yes" and "on" (regardless of capitalization) or non-zero integer representations result to true, "false", "no", "off" or zero integer representations result in false.
strsetting | String representation of the specific setting. |
InvalidDataException | if the string is not one of recognized representation of a boolean. |
static bool IG::Lib::UtilStr::IsBoolean | ( | string | str | ) | [inline, static] |
Returns a boolean value indicating whether the specified string can represent a boolean value. Strings "true", "yes" and "on" (regardless of capitalization) or non-zero integer representations result to true, "false", "no", "off" or zero integer representations result in false.This method is NOT CONSISTENT with bool.TryParse but with UtilStr.ToBoolean.
str | String that is checked if it can represent a boolean value. |
static long IG::Lib::UtilStr::ToInt | ( | string | strsetting | ) | [inline, static] |
Converts a string representation of an integer setting to an integer value. If the setting is not defined then 0 is returned.
strsetting | String representation of the specific setting. |
static long IG::Lib::UtilStr::ToInt | ( | string | strsetting, |
long | defaultvalue | ||
) | [inline, static] |
Converts a string representation of an integer setting to an integer value.
strsetting | String representation of the specific setting. |
defaultvalue | Default value returned in the case that the setting is not defined. |
static bool IG::Lib::UtilStr::IsInt | ( | string | str | ) | [inline, static] |
Returns a boolean value indicating whether the specified string is a valid representation of an integer number.
str | String that is checked. |
static double IG::Lib::UtilStr::ToDouble | ( | string | strsetting | ) | [inline, static] |
Converts a string representation of a double setting to an integer value. If the setting is not defined then 0 is returned.
strsetting | String representation of the value. |
static double IG::Lib::UtilStr::ToDouble | ( | string | strsetting, |
long | defaultvalue | ||
) | [inline, static] |
Converts a string representation of a double value to a number of type double.
strsetting | String representation of the value. |
defaultvalue | Default value returned in the case that the string is null or empty. |
static bool IG::Lib::UtilStr::IsDouble | ( | string | str | ) | [inline, static] |
Returns a boolean value indicating whether the specified string is a valid representation of a number (of type double).
str | String that is checked. |
static string IG::Lib::UtilStr::Load | ( | string | filePath | ) | [inline, static] |
Loads complete file contents into a stiring and returnes that string.
filePath | Path to the file that is red into a string. |
static void IG::Lib::UtilStr::Load | ( | string | filePath, |
ref string | readString | ||
) | [inline, static] |
Loads complete file contents into the specified stiring.
filePath | Path to the file that is red into a string. |
readString | String variable where file contents is stored. |
static void IG::Lib::UtilStr::Save | ( | string | str, |
string | filePath, | ||
bool | append | ||
) | [inline, static] |
Saves the specified string to a specified file. If the specified file does not exists then it is created anew if possible. A boolean argument specifis whether to overwrite existing files or to append the string at the end of the file.
str | String to be saved to a file. |
filePath | Path to the file where string is to be saved. |
append | If true then the string is appended at the end of the file in the case that the file already exists. If false then the file is overwritten in the case taht it already exists. |
static void IG::Lib::UtilStr::Save | ( | string | str, |
string | filePath | ||
) | [inline, static] |
Saves the specified string to a specified file. If the file already exists then is content is overwritten. If the file does not yet exist then it is created anew.
str | String to be written to a file. |
filePath | Path to the file where string is written. |
static void IG::Lib::UtilStr::Append | ( | string | str, |
string | filePath | ||
) | [inline, static] |
Saves the specified string to a specified file. If the file already exists then string is appended at the end of the current file contents. If the file does not yet exist then it is created anew.
str | String to be written to a file. |
filePath | Path to the file where string is written. |
Random IG::Lib::UtilStr::rndgen = null [static, private] |
int IG::Lib::UtilStr::_maxStringLength = 100 [static, private] |
int IG::Lib::UtilStr::MaxStringLength [static, get, set] |
Get or sets maximal length for generated strings (must be GREATER THAN 0).