Contains methods to work with the unsigned 8-bit integer. More...

#include "byte.h"

Static Public Member Functions

static ASPOSECPP_SHARED_API uint8_t Parse (const String &value)
 Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer. More...
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, const SharedPtr< IFormatProvider > &provider)
 Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information. More...
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, const SharedPtr< Globalization::CultureInfo > &culture)
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, const SharedPtr< Globalization::NumberFormatInfo > &nfi)
 
static uint8_t Parse (const String &value, std::nullptr_t)
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, Globalization::NumberStyles styles, const SharedPtr< IFormatProvider > &provider)
 Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information and number style. More...
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, Globalization::NumberStyles styles, const SharedPtr< Globalization::CultureInfo > &culture)
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, Globalization::NumberStyles styles, const SharedPtr< Globalization::NumberFormatInfo > &nfi)
 
static ASPOSECPP_SHARED_API uint8_t Parse (const String &value, Globalization::NumberStyles styles, std::nullptr_t=nullptr)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &value, uint8_t &result)
 Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer. More...
 
static ASPOSECPP_SHARED_API bool TryParse (const String &value, Globalization::NumberStyles styles, const SharedPtr< IFormatProvider > &provider, uint8_t &result)
 Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information and number style. More...
 
static ASPOSECPP_SHARED_API bool TryParse (const String &value, Globalization::NumberStyles styles, const SharedPtr< Globalization::CultureInfo > &culture, uint8_t &result)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &value, Globalization::NumberStyles styles, const SharedPtr< Globalization::NumberFormatInfo > &nfi, uint8_t &result)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &value, Globalization::NumberStyles styles, std::nullptr_t, uint8_t &result)
 

Static Public Attributes

static ASPOSECPP_SHARED_API constexpr uint8_t MinValue = 0
 Smallest possible value. More...
 
static ASPOSECPP_SHARED_API constexpr uint8_t MaxValue = (std::numeric_limits<uint8_t>::max)()
 Largest possible value. More...
 

Detailed Description

Contains methods to work with the unsigned 8-bit integer.

#include <system/byte.h>
using namespace System;
int main()
{
auto b1 = Byte::Parse(u"123");
std::cout << static_cast<uint32_t>(b1) << std::endl;
try
{
auto b2 = Byte::Parse(u"345");
std::cout << static_cast<uint32_t>(b2) << std::endl;
}
catch (const OverflowException &ex)
{
std::cerr << ex.what() << std::endl;
}
uint8_t b3 = 0;
if (Byte::TryParse(u"10", b3))
{
std::cout << static_cast<uint32_t>(b3) << std::endl;
}
else
{
std::cerr << "Something went wrong." << std::endl;
}
return 0;
}
/*
This code example produces the following output:
123
System::OverflowException: Value was either too large or too small for an UInt8
10
*/

Member Function Documentation

◆ Parse() [1/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value)
static

Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer.

Parameters
valueThe string to convert.
Returns
The 8-bit unsigned integer equal to the number represented by the specified string.

◆ Parse() [2/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
const SharedPtr< IFormatProvider > &  provider 
)
static

Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information.

Parameters
valueThe string to convert.
providerA pointer to an object that contains the string format information.
Returns
The 8-bit unsigned integer equal to the number represented by the specified string.

◆ Parse() [3/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
const SharedPtr< Globalization::CultureInfo > &  culture 
)
static

◆ Parse() [4/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
const SharedPtr< Globalization::NumberFormatInfo > &  nfi 
)
static

◆ Parse() [5/9]

static uint8_t System::Byte::Parse ( const String value,
std::nullptr_t   
)
inlinestatic

◆ Parse() [6/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< IFormatProvider > &  provider 
)
static

Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information and number style.

Parameters
valueThe string to convert.
stylesA bitwise combination of values of NumberStyles enum that specifies the permitted style of the string representation of a number.
providerA pointer to an object that contains the string format information.
Returns
The 8-bit unsigned integer equal to the number represented by the specified string.

◆ Parse() [7/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< Globalization::CultureInfo > &  culture 
)
static

◆ Parse() [8/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< Globalization::NumberFormatInfo > &  nfi 
)
static

◆ Parse() [9/9]

static ASPOSECPP_SHARED_API uint8_t System::Byte::Parse ( const String value,
Globalization::NumberStyles  styles,
std::nullptr_t  = nullptr 
)
static

◆ TryParse() [1/5]

static ASPOSECPP_SHARED_API bool System::Byte::TryParse ( const String value,
uint8_t &  result 
)
static

Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer.

Parameters
valueThe string to convert.
resultThe reference to a 8-bit unsigned integer variable where the result of the conversion is put.
Returns
True if the conversion succeeded, otherwise - false.

◆ TryParse() [2/5]

static ASPOSECPP_SHARED_API bool System::Byte::TryParse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< IFormatProvider > &  provider,
uint8_t &  result 
)
static

Converts the specified string containing the string representation of a number to the equivalent 8-bit unsigned integer using the provided formatting information and number style.

Parameters
valueThe string to convert.
stylesA bitwise combination of values of NumberStyles enum that specifies the permitted style of the string representation of a number.
providerA pointer to an object that contains the string format information.
resultThe reference to a 8-bit unsigned integer variable where the result of the conversion is put.
Returns
True if the conversion succeeded, otherwise - false.

◆ TryParse() [3/5]

static ASPOSECPP_SHARED_API bool System::Byte::TryParse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< Globalization::CultureInfo > &  culture,
uint8_t &  result 
)
static

◆ TryParse() [4/5]

static ASPOSECPP_SHARED_API bool System::Byte::TryParse ( const String value,
Globalization::NumberStyles  styles,
const SharedPtr< Globalization::NumberFormatInfo > &  nfi,
uint8_t &  result 
)
static

◆ TryParse() [5/5]

static ASPOSECPP_SHARED_API bool System::Byte::TryParse ( const String value,
Globalization::NumberStyles  styles,
std::nullptr_t  ,
uint8_t &  result 
)
static

Member Data Documentation

◆ MaxValue

ASPOSECPP_SHARED_API constexpr uint8_t System::Byte::MaxValue = (std::numeric_limits<uint8_t>::max)()
static

Largest possible value.

◆ MinValue

ASPOSECPP_SHARED_API constexpr uint8_t System::Byte::MinValue = 0
static

Smallest possible value.