CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
System::Buffers::StandardFormat Class Reference

Represents a standard format specifier with an optional precision. It wraps a format symbol (a single character, e.g. 'D', 'X', 'O', or '\0' for the default format) and an optional precision in the range [0, 99]. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type. More...

#include <standard_format.h>

Inherits System::Details::BoxableObjectBase.

Public Member Functions

 StandardFormat () noexcept
 Constructs a default StandardFormat that represents the default format. More...
 
 StandardFormat (char_t symbol)
 Constructs a StandardFormat with the specified format symbol and no precision. More...
 
 StandardFormat (char_t symbol, uint8_t precision)
 Constructs a StandardFormat with the specified format symbol and precision. More...
 
bool get_IsDefault () const noexcept
 Determines whether this instance represents the default format. More...
 
char_t get_Format () const noexcept
 Gets the standard format symbol. More...
 
uint8_t get_Precision () const noexcept
 Gets the precision (number of digits) for this format, or NoPrecision if none. More...
 
bool Equals (const StandardFormat &other) const noexcept
 Determines whether the current instance is equal to the specified one. More...
 
int32_t GetHashCode () const noexcept
 Returns a hash code for the current StandardFormat. More...
 
String ToString () const
 Returns a string representation of the current StandardFormat. Default format instances are represented as "default"; otherwise the representation is the format symbol optionally followed by the precision, e.g. "X", "X4", "O". More...
 

Static Public Attributes

static constexpr uint8_t NoPrecision = 0xFF
 The maximum precision value that can be specified. A precision of this value means "no explicit precision". More...
 
static constexpr char_t DefaultFormatSymbol = u'\0'
 The symbol used to represent the default format. An instance whose Format equals this value (and whose Precision equals NoPrecision) is considered default. More...
 
static constexpr uint8_t s_maxPrecision = 99
 The maximum allowed precision value (inclusive) for a non-default format. More...
 

Detailed Description

Represents a standard format specifier with an optional precision. It wraps a format symbol (a single character, e.g. 'D', 'X', 'O', or '\0' for the default format) and an optional precision in the range [0, 99]. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

Constructor & Destructor Documentation

◆ StandardFormat() [1/3]

System::Buffers::StandardFormat::StandardFormat ( )
inlinenoexcept

Constructs a default StandardFormat that represents the default format.

◆ StandardFormat() [2/3]

System::Buffers::StandardFormat::StandardFormat ( char_t  symbol)
explicit

Constructs a StandardFormat with the specified format symbol and no precision.

Parameters
symbolA single character that identifies a standard format specifier.

◆ StandardFormat() [3/3]

System::Buffers::StandardFormat::StandardFormat ( char_t  symbol,
uint8_t  precision 
)

Constructs a StandardFormat with the specified format symbol and precision.

Parameters
symbolA single character that identifies a standard format specifier.
precisionThe number of digits to use, or NoPrecision to indicate no precision.
Exceptions
ArgumentOutOfRangeExceptionif precision is neither NoPrecision nor in the range [0, 99].

Member Function Documentation

◆ Equals()

bool System::Buffers::StandardFormat::Equals ( const StandardFormat &  other) const
noexcept

Determines whether the current instance is equal to the specified one.

Parameters
otherThe StandardFormat to compare with the current one.
Returns
True if both instances have the same format symbol and precision; otherwise, false.

◆ get_Format()

char_t System::Buffers::StandardFormat::get_Format ( ) const
inlinenoexcept

Gets the standard format symbol.

Returns
A single character identifying the standard format specifier.

◆ get_IsDefault()

bool System::Buffers::StandardFormat::get_IsDefault ( ) const
inlinenoexcept

Determines whether this instance represents the default format.

Returns
True if the format symbol is the default symbol; otherwise, false.

◆ get_Precision()

uint8_t System::Buffers::StandardFormat::get_Precision ( ) const
inlinenoexcept

Gets the precision (number of digits) for this format, or NoPrecision if none.

Returns
The precision value.

◆ GetHashCode()

int32_t System::Buffers::StandardFormat::GetHashCode ( ) const
noexcept

Returns a hash code for the current StandardFormat.

Returns
An int32_t hash code derived from the format symbol and precision.

◆ ToString()

String System::Buffers::StandardFormat::ToString ( ) const

Returns a string representation of the current StandardFormat. Default format instances are represented as "default"; otherwise the representation is the format symbol optionally followed by the precision, e.g. "X", "X4", "O".

Returns
The string representation of this instance.

Member Data Documentation

◆ DefaultFormatSymbol

constexpr char_t System::Buffers::StandardFormat::DefaultFormatSymbol = u'\0'
staticconstexpr

The symbol used to represent the default format. An instance whose Format equals this value (and whose Precision equals NoPrecision) is considered default.

◆ NoPrecision

constexpr uint8_t System::Buffers::StandardFormat::NoPrecision = 0xFF
staticconstexpr

The maximum precision value that can be specified. A precision of this value means "no explicit precision".

Equivalent to byte.MaxValue in .NET.

◆ s_maxPrecision

constexpr uint8_t System::Buffers::StandardFormat::s_maxPrecision = 99
staticconstexpr

The maximum allowed precision value (inclusive) for a non-default format.