| IGLib 1.4 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Member Functions | Properties | Static Private Member Functions | Static Private Attributes

# IG::Lib::UtilStr Class Reference

Various string operations, random strings, random characters, etc. More...

Inheritance diagram for IG::Lib::UtilStr:
[legend]
Collaboration diagram for IG::Lib::UtilStr:
[legend]

List of all members.

## 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

## Detailed Description

Various string operations, random strings, random characters, etc.

$A Igor xx;

## Member Function Documentation

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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  commandLine | Command line that is split to individual arguments. Command line can also contain a command, which is treated equally.

Returns:
  An array of arguments.

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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  typeflags | Flags specifying the permitted types of the returned character.

Returns:
  The randomly generated 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.

Returns:
  The randomly generated character.

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.

Parameters:

  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.

Returns:
  The generated random string.

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

Parameters:

  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.

Returns:
  The generated random 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.

Parameters:

  length | Length of the string.
  firstletter | If true then first character of the generated string will be a letter.

Returns:
  The generated random string.

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.

Parameters:

  length | Length of the string.

Returns:
  The generated random 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.

Returns:
  The generated random string.

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.

Parameters:

  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'.

Parameters:

  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'.

Parameters:

  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'.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  strsetting | String representation of the specific setting.

Exceptions:

  InvalidDataException | if the string is not one of recognized representation of a boolean.

Returns:
  Boolean value corresponding to the setting.

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.

Parameters:

  str | String that is checked if it can represent a boolean value.

Returns:

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.

Parameters:

  strsetting | String representation of the specific setting.

Returns:
  Long integer value corresponding to the 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.

Parameters:

  strsetting | String representation of the specific setting.
  defaultvalue | Default value returned in the case that the setting is not defined.

Returns:
  Long integer value corresponding to the setting.

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.

Parameters:

  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.

Parameters:

  strsetting | String representation of the value.

Returns:
  Long integer value corresponding to the setting.

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.

Parameters:

  strsetting | String representation of the value.
  defaultvalue | Default value returned in the case that the string is null or empty.

Returns:
  Long integer value corresponding to the setting.

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

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  str | String to be written to a file.
  filePath | Path to the file where string is written.

## Member Data Documentation

Random IG::Lib::UtilStr::rndgen = null`[static, private]`

int IG::Lib::UtilStr::_maxStringLength = 100`[static, private]`

## Property Documentation

int IG::Lib::UtilStr::MaxStringLength`[static, get, set]`

Get or sets maximal length for generated strings (must be GREATER THAN 0).

The documentation for this class was generated from the following file:

- UtilString.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events