OpenTAP 9.27
API Reference
Public Member Functions | Public Attributes | List of all members
OpenTap.NumberFormatter Class Reference

Parser / back parser for numbers and sequences of numbers. More...

Public Member Functions

 NumberFormatter (CultureInfo culture)
 
 NumberFormatter (CultureInfo culture, UnitAttribute unit)
 Creates a number parser based on a UnitAttribute. More...
 
ICombinedNumberSequence< double > Parse (string value)
 Parses a string to a sequence of doubles. supports ranges, sequences, units and prefixes. More...
 
string FormatNumber (object value)
 Parses a number back to a string. More...
 
object ParseNumber (string str, Type t)
 Parses a single number from a string. More...
 
bool TryParseNumber (string str, Type t, out object val)
 Try to parse a single number from a string. More...
 
string FormatRange (IEnumerable values)
 Parses a sequence of numbers back into a string. More...
 

Public Attributes

string Format = ""
 Argument to string.Format.
 
string Unit = ""
 Unit of the numbers (e.g. 'Hz').
 
bool UsePrefix = false
 Boolean setting. When true, parse number into prefixes. For example, '10000 Hz' becomes '10 kHz'.
 
double PreScaling = 1.0
 Pre-scales numbers before converting.
 
bool UseRanges = true
 Boolean setting. When true, numbers are parsed back into ranges. When false, separate values as used as their raw representation.
 
bool IsCompact = false
 Print using compact representation.
 

Detailed Description

Parser / back parser for numbers and sequences of numbers.

Constructor & Destructor Documentation

◆ NumberFormatter() [1/2]

OpenTap.NumberFormatter.NumberFormatter ( CultureInfo  culture)
inline

Parameters
cultureThe culture used to parse/write numbers.

◆ NumberFormatter() [2/2]

OpenTap.NumberFormatter.NumberFormatter ( CultureInfo  culture,
UnitAttribute  unit 
)
inline

Creates a number parser based on a UnitAttribute.

Parameters
culture
unit

Member Function Documentation

◆ FormatNumber()

string OpenTap.NumberFormatter.FormatNumber ( object  value)
inline

Parses a number back to a string.

Parameters
value
Returns

◆ FormatRange()

string OpenTap.NumberFormatter.FormatRange ( IEnumerable  values)
inline

Parses a sequence of numbers back into a string.

Parameters
values
Returns

◆ Parse()

ICombinedNumberSequence< double > OpenTap.NumberFormatter.Parse ( string  value)
inline

Parses a string to a sequence of doubles. supports ranges, sequences, units and prefixes.

Parameters
value
Returns

◆ ParseNumber()

object OpenTap.NumberFormatter.ParseNumber ( string  str,
Type  t 
)
inline

Parses a single number from a string.

Parameters
str
t
Returns

◆ TryParseNumber()

bool OpenTap.NumberFormatter.TryParseNumber ( string  str,
Type  t,
out object  val 
)
inline

Try to parse a single number from a string.

Parameters
strthe string to parse.
tthe return type of value. must be numeric.
valresulting value. Null if parsing failed.
Returns

OpenTAP 9.27 API built Wed Nov 27 2024 13:14:46