NanoXLSX.Core 3.0.0-rc.3
Loading...
Searching...
No Matches
NanoXLSX.Utils.ParserUtils Class Reference

Class providing static methods to parse string values to specific types or to print object as language neutral string. More...

Static Public Member Functions

static bool StartsWith (string input, string value)
 Determines whether a string starts with a specific value.
static bool NotStartsWith (string input, string value)
 Determines whether a string does not start with a specific value.
static string ToUpper (string input)
 Transforms a string to upper case with null check and invariant culture.
static string ToLower (string input)
 Transforms a string to lower case with null check and invariant culture.
static string ToString (int input)
 Transforms an integer to an invariant sting.
static string ToString (float input)
 Transforms a float to an invariant sting.
static string ToString (byte input)
 Transforms a byte to an invariant sting.
static string ToString (sbyte input)
 Transforms a sbyte to an invariant sting.
static string ToString (double input)
 Transforms a double to an invariant sting.
static string ToString (decimal input)
 Transforms a decimal to an invariant sting.
static string ToString (uint input)
 Transforms a uint to an invariant sting.
static string ToString (long input)
 Transforms a long to an invariant sting.
static string ToString (ulong input)
 Transforms a ulong to an invariant sting.
static string ToString (short input)
 Transforms a short to an invariant sting.
static string ToString (ushort input)
 Transforms a ushort to an invariant sting.
static string NormalizeNewLines (string value)
 Normalizes all newlines of a string to CR+LF.
static float ParseFloat (string rawValue)
 Parses a float independent from the culture info of the host.
static int ParseInt (string rawValue)
 Parses an int independent from the culture info of the host.
static int ParseBinaryBool (String rawValue)
 Parses a bool as a binary number either based on an int (0/1) or a string expression (true/ false), independent of the culture info of the host.
static bool TryParseInt (string rawValue, out int parsedValue)
 Tries to parse an int independent of the culture info of the host.
static bool TryParseUint (string rawValue, out uint parsedValue)
 Tries to parse an unsigned int (uint) independent from the culture info of the host.
static bool TryParseLong (string rawValue, out long parsedValue)
 Tries to parse a long independent from the culture info of the host.
static bool TryParseUlong (string rawValue, out ulong parsedValue)
 Tries to parse an unsigned long (ulong) independent from the culture info of the host.
static bool TryParseFloat (string rawValue, out float parsedValue)
 Tries to parse a float (with any parsing style) independent from the culture info of the host.
static bool TryParseDecimal (string rawValue, out decimal parsedValue)
 Tries to parse a decimal (with float parsing style) independent from the culture info of the host.
static bool TryParseDouble (string rawValue, out double parsedValue)
 Tries to parse a double (with any parsing style) independent from the culture info of the host.

Static Public Attributes

const string NumericFormat = "G"
 Numeric format for ToString conversions. This format ensures that a numeric value is printed in a language neutral way.
static readonly CultureInfo InvariantCulture = CultureInfo.InvariantCulture
 Constant for number conversion. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific punctuations are used when converting numbers to strings, This is especially important for OOXML number values. See also: https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.invariantculture?view=net-5.0.

Detailed Description

Class providing static methods to parse string values to specific types or to print object as language neutral string.

Remarks
Methods in this class should only be used by the library components and not called by user code

Definition at line 18 of file ParserUtils.cs.

Member Function Documentation

◆ NormalizeNewLines()

string NanoXLSX.Utils.ParserUtils.NormalizeNewLines ( string value)
static

Normalizes all newlines of a string to CR+LF.

Parameters
valueInput value
Returns
Normalized value

Definition at line 206 of file ParserUtils.cs.

◆ NotStartsWith()

bool NanoXLSX.Utils.ParserUtils.NotStartsWith ( string input,
string value )
static

Determines whether a string does not start with a specific value.

Parameters
inputString to check
valueValue to be checked, whether it occurs not at the beginning of the input string
Returns
True if the input string does not starts with the specified value

Definition at line 66 of file ParserUtils.cs.

◆ ParseBinaryBool()

int NanoXLSX.Utils.ParserUtils.ParseBinaryBool ( String rawValue)
static

Parses a bool as a binary number either based on an int (0/1) or a string expression (true/ false), independent of the culture info of the host.

Parameters
rawValueRaw number or expression as string
Returns
Parsed bool as number (0 = false, 1 = true)

Definition at line 240 of file ParserUtils.cs.

◆ ParseFloat()

float NanoXLSX.Utils.ParserUtils.ParseFloat ( string rawValue)
static

Parses a float independent from the culture info of the host.

Parameters
rawValueRaw number as string
Returns
Parsed float

Definition at line 220 of file ParserUtils.cs.

◆ ParseInt()

int NanoXLSX.Utils.ParserUtils.ParseInt ( string rawValue)
static

Parses an int independent from the culture info of the host.

Parameters
rawValueRaw number as string
Returns
Parsed int

Definition at line 230 of file ParserUtils.cs.

◆ StartsWith()

bool NanoXLSX.Utils.ParserUtils.StartsWith ( string input,
string value )
static

Determines whether a string starts with a specific value.

Parameters
inputString to check
valueValue to be checked, whether it occurs at the beginning of the input string
Returns
True if the input string starts with the specified value

Definition at line 43 of file ParserUtils.cs.

◆ ToLower()

string NanoXLSX.Utils.ParserUtils.ToLower ( string input)
static

Transforms a string to lower case with null check and invariant culture.

Parameters
inputString to transform
Returns
Lower case string

Definition at line 86 of file ParserUtils.cs.

◆ ToString() [1/11]

string NanoXLSX.Utils.ParserUtils.ToString ( byte input)
static

Transforms a byte to an invariant sting.

Parameters
inputByte to transform
Returns
Byte as string

Definition at line 116 of file ParserUtils.cs.

◆ ToString() [2/11]

string NanoXLSX.Utils.ParserUtils.ToString ( decimal input)
static

Transforms a decimal to an invariant sting.

Parameters
inputDecimal to transform
Returns
Decimal as string

Definition at line 146 of file ParserUtils.cs.

◆ ToString() [3/11]

string NanoXLSX.Utils.ParserUtils.ToString ( double input)
static

Transforms a double to an invariant sting.

Parameters
inputDouble to transform
Returns
Double as string

Definition at line 136 of file ParserUtils.cs.

◆ ToString() [4/11]

string NanoXLSX.Utils.ParserUtils.ToString ( float input)
static

Transforms a float to an invariant sting.

Parameters
inputFloat to transform
Returns
Float as string

Definition at line 106 of file ParserUtils.cs.

◆ ToString() [5/11]

string NanoXLSX.Utils.ParserUtils.ToString ( int input)
static

Transforms an integer to an invariant sting.

Parameters
inputInteger to transform
Returns
Integer as string

Definition at line 96 of file ParserUtils.cs.

◆ ToString() [6/11]

string NanoXLSX.Utils.ParserUtils.ToString ( long input)
static

Transforms a long to an invariant sting.

Parameters
inputLong to transform
Returns
Long as string

Definition at line 166 of file ParserUtils.cs.

◆ ToString() [7/11]

string NanoXLSX.Utils.ParserUtils.ToString ( sbyte input)
static

Transforms a sbyte to an invariant sting.

Parameters
inputSbyte to transform
Returns
Byte as string

Definition at line 126 of file ParserUtils.cs.

◆ ToString() [8/11]

string NanoXLSX.Utils.ParserUtils.ToString ( short input)
static

Transforms a short to an invariant sting.

Parameters
inputShort to transform
Returns
Short as string

Definition at line 186 of file ParserUtils.cs.

◆ ToString() [9/11]

string NanoXLSX.Utils.ParserUtils.ToString ( uint input)
static

Transforms a uint to an invariant sting.

Parameters
inputUint to transform
Returns
Uint as string

Definition at line 156 of file ParserUtils.cs.

◆ ToString() [10/11]

string NanoXLSX.Utils.ParserUtils.ToString ( ulong input)
static

Transforms a ulong to an invariant sting.

Parameters
inputUlong to transform
Returns
Ulong as string

Definition at line 176 of file ParserUtils.cs.

◆ ToString() [11/11]

string NanoXLSX.Utils.ParserUtils.ToString ( ushort input)
static

Transforms a ushort to an invariant sting.

Parameters
inputUshort to transform
Returns
Ushort as string

Definition at line 196 of file ParserUtils.cs.

◆ ToUpper()

string NanoXLSX.Utils.ParserUtils.ToUpper ( string input)
static

Transforms a string to upper case with null check and invariant culture.

Parameters
inputString to transform
Returns
Upper case string

Definition at line 76 of file ParserUtils.cs.

◆ TryParseDecimal()

bool NanoXLSX.Utils.ParserUtils.TryParseDecimal ( string rawValue,
out decimal parsedValue )
static

Tries to parse a decimal (with float parsing style) independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed decimal
Returns
True, if the parsing was successful

Definition at line 330 of file ParserUtils.cs.

◆ TryParseDouble()

bool NanoXLSX.Utils.ParserUtils.TryParseDouble ( string rawValue,
out double parsedValue )
static

Tries to parse a double (with any parsing style) independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed double
Returns
True, if the parsing was successful

Definition at line 341 of file ParserUtils.cs.

◆ TryParseFloat()

bool NanoXLSX.Utils.ParserUtils.TryParseFloat ( string rawValue,
out float parsedValue )
static

Tries to parse a float (with any parsing style) independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed float
Returns
True, if the parsing was successful

Definition at line 319 of file ParserUtils.cs.

◆ TryParseInt()

bool NanoXLSX.Utils.ParserUtils.TryParseInt ( string rawValue,
out int parsedValue )
static

Tries to parse an int independent of the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed int
Returns
True, if the parsing was successful

Definition at line 275 of file ParserUtils.cs.

◆ TryParseLong()

bool NanoXLSX.Utils.ParserUtils.TryParseLong ( string rawValue,
out long parsedValue )
static

Tries to parse a long independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed long
Returns
True, if the parsing was successful

Definition at line 297 of file ParserUtils.cs.

◆ TryParseUint()

bool NanoXLSX.Utils.ParserUtils.TryParseUint ( string rawValue,
out uint parsedValue )
static

Tries to parse an unsigned int (uint) independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed uint
Returns
True, if the parsing was successful

Definition at line 286 of file ParserUtils.cs.

◆ TryParseUlong()

bool NanoXLSX.Utils.ParserUtils.TryParseUlong ( string rawValue,
out ulong parsedValue )
static

Tries to parse an unsigned long (ulong) independent from the culture info of the host.

Parameters
rawValueRaw number as string
parsedValueParsed ulong
Returns
True, if the parsing was successful

Definition at line 308 of file ParserUtils.cs.

Member Data Documentation

◆ InvariantCulture

readonly CultureInfo NanoXLSX.Utils.ParserUtils.InvariantCulture = CultureInfo.InvariantCulture
static

Constant for number conversion. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific punctuations are used when converting numbers to strings, This is especially important for OOXML number values. See also: https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.invariantculture?view=net-5.0.

Definition at line 33 of file ParserUtils.cs.

◆ NumericFormat

const string NanoXLSX.Utils.ParserUtils.NumericFormat = "G"
static

Numeric format for ToString conversions. This format ensures that a numeric value is printed in a language neutral way.

Definition at line 25 of file ParserUtils.cs.


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