Rhino C++ API  8.5
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ON_LengthValue Class Reference

#include <opennurbs_string_value.h>

Public Types

enum  StringFormat : unsigned char {
  StringFormat::ExactDecimal = 0, StringFormat::ExactProperFraction = 1, StringFormat::ExactImproperFraction = 2, StringFormat::CleanDecimal = 3,
  StringFormat::CleanProperFraction = 4, StringFormat::CleanImproperFraction = 5
}
 Formatting to apply when creating a length value from a double. More...
 

Public Member Functions

 ON_LengthValue ()=default
 
 ON_LengthValue (const ON_LengthValue &)=default
 
 ~ON_LengthValue ()=default
 
const ON_LengthValue ChangeLength (double length_value) const
 
const ON_SHA1_Hash ContentHash () const
 
ON::AngleUnitSystem ContextAngleUnitSystem () const
 
unsigned int ContextLocaleId () const
 
bool IsSet () const
 
bool IsUnset () const
 
double Length (const class ON_UnitSystem &context_unit_system) const
 
double Length (ON::LengthUnitSystem context_unit_system) const
 
const ON_wStringLengthAsString () const
 
const wchar_t * LengthAsStringPointer () const
 
ON_LengthValue::StringFormat LengthStringFormat () const
 
const ON_ParseSettings LengthStringParseSettings () const
 
const class ON_UnitSystemLengthUnitSystem () const
 
ON_LengthValueoperator= (const ON_LengthValue &)=default
 
bool Read (class ON_BinaryArchive &archive)
 
const ON_LengthValue RemoveUnitSystem () const
 
bool Write (class ON_BinaryArchive &archive) const
 

Static Public Member Functions

static int Compare (const ON_LengthValue &lhs, const ON_LengthValue &rhs)
 
static ON_LengthValue Create (double length_value, const class ON_LengthUnitName &length_unit_system, ON_LengthValue::StringFormat string_format)
 
static ON_LengthValue Create (double length_value, const class ON_UnitSystem &length_unit_system, unsigned int locale_id, ON_LengthValue::StringFormat string_format)
 
static ON_LengthValue Create (double length_value, const ON::LengthUnitSystem length_unit_system, unsigned int locale_id, ON_LengthValue::StringFormat string_format)
 
static ON_LengthValue CreateFromString (ON_ParseSettings parse_settings, const wchar_t *string)
 
static ON_LengthValue CreateFromSubString (ON_ParseSettings parse_settings, const wchar_t *string, int string_count, const wchar_t **string_end)
 
static ON_LengthValue::StringFormat LengthStringFormatFromUnsigned (unsigned int string_format_as_unsigned)
 

Static Public Attributes

static const ON_LengthValue Unset
 
static const ON_LengthValue Zero
 

Member Enumeration Documentation

◆ StringFormat

enum ON_LengthValue::StringFormat : unsigned char
strong

Formatting to apply when creating a length value from a double.

Enumerator
ExactDecimal 

summary>Use exact decimal string.

summary>If possible, use exact integer-fraction format (1.125 becomes 1-1/8).

ExactProperFraction 

summary>If possible, use exact fraction format (1.125 becomes 9/8).

ExactImproperFraction 

summary>The value may be adjusted slightly to improve clarity (1.124999... becomes 1.125).

CleanDecimal 

summary>The value may be adjusted slightly to improve clarity (1.124999... becomes 1-1/8).

CleanProperFraction 

summary>The value may be adjusted slightly to improve clarity (1.124999... becomes 9/8).

CleanImproperFraction 

Constructor & Destructor Documentation

◆ ON_LengthValue() [1/2]

ON_LengthValue::ON_LengthValue ( )
default

◆ ~ON_LengthValue()

ON_LengthValue::~ON_LengthValue ( )
default

◆ ON_LengthValue() [2/2]

ON_LengthValue::ON_LengthValue ( const ON_LengthValue )
default

Member Function Documentation

◆ ChangeLength()

const ON_LengthValue ON_LengthValue::ChangeLength ( double  length_value) const

Parameters: length_value - [in] New length. Returns: A ON_LengthValue with the new length and other settings copied from this.

◆ Compare()

static int ON_LengthValue::Compare ( const ON_LengthValue lhs,
const ON_LengthValue rhs 
)
static

◆ ContentHash()

const ON_SHA1_Hash ON_LengthValue::ContentHash ( ) const

◆ ContextAngleUnitSystem()

ON::AngleUnitSystem ON_LengthValue::ContextAngleUnitSystem ( ) const

Returns: Angle unit system used to parse input strings.

◆ ContextLocaleId()

unsigned int ON_LengthValue::ContextLocaleId ( ) const

Returns: Locale used to parse input strings and create unit names.

◆ Create() [1/3]

static ON_LengthValue ON_LengthValue::Create ( double  length_value,
const class ON_LengthUnitName length_unit_system,
ON_LengthValue::StringFormat  string_format 
)
static

◆ Create() [2/3]

static ON_LengthValue ON_LengthValue::Create ( double  length_value,
const class ON_UnitSystem length_unit_system,
unsigned int  locale_id,
ON_LengthValue::StringFormat  string_format 
)
static

Parameters: length_value - [in] length_unit_system - [in] bUseFractionsInString - [in] If bUseFractions is true and length_value can be represented as a common fraction, then the string form will contain a fraction rather than a decimal. locale_id - [in] locale id for the string length unit system 0 will select ON_Locale::CurrentCulture. string_format - [in] Determines the format of the string representation Returns: Length in the specified length unit system Remarks: If you don't like the automatically created string value, then format the string yourself and use ON_LengthValue::CreateFromString().

◆ Create() [3/3]

static ON_LengthValue ON_LengthValue::Create ( double  length_value,
const ON::LengthUnitSystem  length_unit_system,
unsigned int  locale_id,
ON_LengthValue::StringFormat  string_format 
)
static

Parameters: length_value - [in] length_unit_system - [in] bUseFractionsInString - [in] If bUseFractions is true and length_value can be represented as a common fraction, then the string form will contain a fraction rather than a decimal. locale_id - [in] locale id for the string length unit system bool Returns: Length in the specified length unit system Remarks: If you don't like the automatically created string value, then format the string yourself and use ON_LengthValue::CreateFromString().

◆ CreateFromString()

static ON_LengthValue ON_LengthValue::CreateFromString ( ON_ParseSettings  parse_settings,
const wchar_t *  string 
)
static

Description: Create an ON_LengthValue by parsing a string. Parameters: parse_settings - [in] Pass ON_ParseSettings(context_length_unit_system,context_angle_unit_system,context_locale_id) string - [in] null terminated string to parse. Returns: If the string is valid, the exact length value is returned. If the string is not valid or parsing ends before the string's null terminator, the ON_LengthValue::Unset is returned. Remarks: If the entire string is not parsed, that is an error condition. Use CreateFromSubString() to permit parsing a portion of the string.

◆ CreateFromSubString()

static ON_LengthValue ON_LengthValue::CreateFromSubString ( ON_ParseSettings  parse_settings,
const wchar_t *  string,
int  string_count,
const wchar_t **  string_end 
)
static

Description: Create an ON_LengthValue by parsing a string. Parameters: parse_settings - [in] Pass ON_ParseSettings(context_length_unit_system,context_angle_unit_system,context_locale_id) string - [in] null terminated string to parse. string_count - [in] string[] and string_count specify the string to parse. If string_count >= 0, it specifies the maximum number of elements in string[] that may be parsed. If string_count = -1, then the string must contain a character that terminates length parsing. string_end - [out] If string_end is not nullptr, then *string_end points to the first element in the string that was not parsed. Returns: If the string is valid, the exact length value is returned. If the string is not valid or parsing ends before the string's null terminator, the ON_LengthValue::Unset is returned. Remarks: If the entire string is not parsed, that is an error condition. Use CreateFromSubString() to permit parsing a portion of the string.

◆ IsSet()

bool ON_LengthValue::IsSet ( ) const

◆ IsUnset()

bool ON_LengthValue::IsUnset ( ) const

◆ Length() [1/2]

double ON_LengthValue::Length ( const class ON_UnitSystem context_unit_system) const

Parameters: context_unit_system - [in] length unit system for the returned value. Pass ON_UnitSystem::None to ignore the length unit system and get the value save in this class. Returns: Length in the specified length unit system

◆ Length() [2/2]

double ON_LengthValue::Length ( ON::LengthUnitSystem  context_unit_system) const

Parameters: context_unit_system - [in] length unit system for the returned value. Pass ON::LengthUnitSystem::None to ignore the length unit system and get the value save in this class. Returns: Length in the specified length unit system

◆ LengthAsString()

const ON_wString& ON_LengthValue::LengthAsString ( ) const

Returns: The length as a string. Remarks: If ON_LengthValue::CreateFromString() or ON_LengthValue::CreateFromSubString() were used to create this ON_LengthValue, a copy of that string is returned.

◆ LengthAsStringPointer()

const wchar_t* ON_LengthValue::LengthAsStringPointer ( ) const

◆ LengthStringFormat()

ON_LengthValue::StringFormat ON_LengthValue::LengthStringFormat ( ) const

Returns: Format processing applied to input values.

◆ LengthStringFormatFromUnsigned()

static ON_LengthValue::StringFormat ON_LengthValue::LengthStringFormatFromUnsigned ( unsigned int  string_format_as_unsigned)
static

◆ LengthStringParseSettings()

const ON_ParseSettings ON_LengthValue::LengthStringParseSettings ( ) const

◆ LengthUnitSystem()

const class ON_UnitSystem& ON_LengthValue::LengthUnitSystem ( ) const

Returns: Length unit system for this class.

◆ operator=()

ON_LengthValue& ON_LengthValue::operator= ( const ON_LengthValue )
default

◆ Read()

bool ON_LengthValue::Read ( class ON_BinaryArchive archive)

◆ RemoveUnitSystem()

const ON_LengthValue ON_LengthValue::RemoveUnitSystem ( ) const

Returns: A ON_LengthValue with the same length value and unit system = None.

◆ Write()

bool ON_LengthValue::Write ( class ON_BinaryArchive archive) const

Member Data Documentation

◆ Unset

const ON_LengthValue ON_LengthValue::Unset
static

◆ Zero

const ON_LengthValue ON_LengthValue::Zero
static