NDEVR
API Documentation

A unit that has two parts (Think feet, inches). More...

Inheritance diagram for TwoPartUnit:
[legend]
Collaboration diagram for TwoPartUnit:
[legend]

Public Member Functions

 TwoPartUnit (const StringView &name, const TranslatedString &translated_id, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 scale, fltp08 sub_unit)
 Constructs a TwoPartUnit with major and minor subdivisions.
virtual Unitclone (const StringView &name, const TranslatedString &translated_id) const override
 Creates a copy of this unit with a new name and display name.
virtual fltp08 epsilon (fltp08 value, uint01 direction) const override
 Returns the smallest meaningful difference for a value in this unit.
virtual fltp08 fromString (const StringView &unit_string, uint01 direction=X) const override
 Parses a two-part formatted string into a numeric value in this unit's space.
virtual StringView getNextPreferredSeparator (const StringView &string, uint01 direction) const override
 Returns the next preferred separator character for user input parsing.
void toString (String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
 Writes a formatted two-part display string into the given string.
Public Member Functions inherited from ScaledUnit
 ScaledUnit (StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
 Constructs a ScaledUnit with the given scale factor and abbreviation.
virtual const TranslatedStringabbreviation (uint01 direction=X) const override
 Returns the translated abbreviation for this unit.
virtual fltp08 convertFromString (const StringView &unit_string, uint01 direction=X) const override
 Converts a unit-formatted string to a program-space value.
virtual fltp08 convertFromUnit (const fltp08 &program_space, const uint01 direction=X) const override
 Converts a scalar from this unit back to program space by dividing by the scale.
virtual Ray< 3, fltp08convertFromUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from this unit back to program space by dividing by the scale.
virtual Vertex< 3, fltp08convertFromUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from this unit back to program space by dividing by the scale.
virtual String convertToString (const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
 Converts a program-space scalar to a formatted display string.
virtual fltp08 convertToUnit (const fltp08 &program_space, const uint01 direction=X) const override
 Converts a scalar from program space to this unit by multiplying by the scale.
virtual Ray< 3, fltp08convertToUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from program space to this unit by multiplying by the scale.
virtual Vertex< 3, fltp08convertToUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from program space to this unit by multiplying by the scale.
virtual Matrix< fltp08matrix () const override
 Returns the transformation matrix representing this unit's scale.
virtual const UnitsubUnit (uint01) const override
 Returns the sub-unit for the given axis direction.
Public Member Functions inherited from Unit
 Unit (StringView name, TranslatedString translated_id)
 Constructs a Unit with the given internal name and translated display name.
virtual ~Unit ()=default
 Virtual destructor.
virtual Unitclone () const
 Creates a deep copy of this unit.
template<class t_angle_type>
Angle< t_angle_type > convertAngleFromUnit (const fltp08 &unit_space, uint01 direction=X) const
 Converts a scalar value in this unit's space back to an Angle in program space.
template<class t_angle_type>
String convertToString (const Angle< t_angle_type > &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const
 Converts an angle value from program space to a formatted string in this unit.
template<class t_angle_type>
fltp08 convertToUnit (const Angle< t_angle_type > &program_space, uint01 direction=X) const
 Converts an angle value from program space to this unit's scalar representation.
bool operator== (const Unit &other) const
 Checks equality between two units by comparing their matrices and names.
virtual void toFormula (StringAllocatingView &unit_string, uint01 direction=X) const
 Writes the unit conversion as a formula into the given string.
String toString (const fltp08 &unit_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const
 Formats a value already in this unit's space into a display string.
virtual TranslatedString translatedAxisName (uint04 index) const
 Returns the translated axis name for a given axis index.
TranslatedString translatedName () const
 Returns the translated display name of this unit.

Public Attributes

const TranslatedString abr_major
 The abbreviation for the major part (e.g., feet symbol).
const TranslatedString abr_minor
 The abbreviation for the minor part (e.g., inches symbol).
uint04 max_decimal_digits
 The maximum number of decimal digits allowed for the minor part.
const fltp08 sub_unit
 The number of minor units per major unit (e.g., 12 inches per foot).
Public Attributes inherited from ScaledUnit
const TranslatedString core_abbreviation
 The translated abbreviation displayed for this unit.
const fltp08 scale
 The multiplicative scale factor used for conversion to this unit.
Public Attributes inherited from Unit
TranslatedString axis_abbreviations [4]
 Translated axis abbreviations for up to four axes.
TranslatedString axis_name_ids [4]
 Translated axis names for up to four axes.
const String name
 Internal identifier name for this unit.
const TranslatedString translated_id
 Translated display name for this unit.

Additional Inherited Members

Static Protected Member Functions inherited from Unit
static Buffer< StringViewOperatorSplit (const StringView &string)
 Splits a string by operator characters for formula parsing.

Detailed Description

A unit that has two parts (Think feet, inches).


Definition at line 647 of file UnitTypes.h.

Constructor & Destructor Documentation

◆ TwoPartUnit()

TwoPartUnit::TwoPartUnit ( const StringView & name,
const TranslatedString & translated_id,
const TranslatedString & abr_major,
const TranslatedString & abr_minor,
fltp08 scale,
fltp08 sub_unit )

Constructs a TwoPartUnit with major and minor subdivisions.

Parameters
[in]nameThe internal identifier for this unit.
[in]translated_idThe translated display name for this unit.
[in]abr_majorThe abbreviation for the major part (e.g., feet).
[in]abr_minorThe abbreviation for the minor part (e.g., inches).
[in]scaleThe multiplicative scale factor for the major part.
[in]sub_unitThe number of minor units per major unit.

References abr_major, abr_minor, Unit::name, ScaledUnit::scale, sub_unit, and Unit::translated_id.

Member Function Documentation

◆ clone()

virtual Unit * TwoPartUnit::clone ( const StringView & name,
const TranslatedString & translated_id ) const
nodiscardoverridevirtual

Creates a copy of this unit with a new name and display name.

Parameters
[in]nameThe internal identifier for the cloned unit.
[in]translated_idThe translated display name for the cloned unit.
Returns
A newly allocated clone of this unit.

Reimplemented from ScaledUnit.

References Unit::name, and Unit::translated_id.

◆ epsilon()

virtual fltp08 TwoPartUnit::epsilon ( fltp08 value,
uint01 direction ) const
nodiscardoverridevirtual

Returns the smallest meaningful difference for a value in this unit.

Parameters
[in]valueThe value to compute epsilon for.
[in]directionThe axis direction.
Returns
The epsilon value for the given input.

Reimplemented from Unit.

◆ fromString()

virtual fltp08 TwoPartUnit::fromString ( const StringView & unit_string,
uint01 direction = X ) const
nodiscardoverridevirtual

Parses a two-part formatted string into a numeric value in this unit's space.

Parameters
[in]unit_stringThe string to parse (e.g., "5' 6\"").
[in]directionThe axis direction for the conversion.
Returns
The parsed numeric value.

Reimplemented from ScaledUnit.

◆ getNextPreferredSeparator()

virtual StringView TwoPartUnit::getNextPreferredSeparator ( const StringView & string,
uint01 direction ) const
nodiscardoverridevirtual

Returns the next preferred separator character for user input parsing.

Parameters
[in]stringThe current input string being parsed.
[in]directionThe axis direction.
Returns
The next preferred separator as a string view.

Reimplemented from Unit.

◆ toString()

void TwoPartUnit::toString ( String & string,
const fltp08 & local_space,
bool add_comma,
uint04 min_decimals,
uint04 max_decimals,
uint04 min_digits,
bool include_abv = true,
uint01 direction = X ) const
overridevirtual

Writes a formatted two-part display string into the given string.

Parameters
[in]stringThe string to append the formatted value into.
[in]local_spaceThe value in this unit's space.
[in]add_commaWhether to insert comma separators for large numbers.
[in]min_decimalsThe minimum number of decimal places to display.
[in]max_decimalsThe maximum number of decimal places to display.
[in]min_digitsThe minimum number of integer digits to display.
[in]include_abvWhether to append the unit abbreviation.
[in]directionThe axis direction for the conversion.

Reimplemented from Unit.


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