#![cfg(not(feature = "format"))]
use crate::error::Error;
use crate::format_builder::NumberFormatBuilder;
use crate::format_flags as flags;
#[doc(hidden)]
pub struct NumberFormat<const FORMAT: u128>;
impl<const FORMAT: u128> NumberFormat<FORMAT> {
pub const fn new() -> Self {
Self {}
}
pub const fn is_valid(&self) -> bool {
self.error().is_success()
}
pub const fn error(&self) -> Error {
let valid_flags = flags::REQUIRED_EXPONENT_DIGITS | flags::REQUIRED_MANTISSA_DIGITS;
if !flags::is_valid_radix(self.mantissa_radix()) {
Error::InvalidMantissaRadix
} else if !flags::is_valid_radix(self.exponent_base()) {
Error::InvalidExponentBase
} else if !flags::is_valid_radix(self.exponent_radix()) {
Error::InvalidExponentRadix
} else if !flags::is_valid_digit_separator(FORMAT) {
Error::InvalidDigitSeparator
} else if !flags::is_valid_base_prefix(FORMAT) {
Error::InvalidBasePrefix
} else if !flags::is_valid_base_suffix(FORMAT) {
Error::InvalidBaseSuffix
} else if !flags::is_valid_punctuation(FORMAT) {
Error::InvalidPunctuation
} else if self.flags() != valid_flags {
Error::InvalidFlags
} else {
Error::Success
}
}
pub const REQUIRED_INTEGER_DIGITS: bool = false;
#[inline(always)]
pub const fn required_integer_digits(&self) -> bool {
Self::REQUIRED_INTEGER_DIGITS
}
pub const REQUIRED_FRACTION_DIGITS: bool = false;
#[inline(always)]
pub const fn required_fraction_digits(&self) -> bool {
Self::REQUIRED_FRACTION_DIGITS
}
pub const REQUIRED_EXPONENT_DIGITS: bool = true;
#[inline(always)]
pub const fn required_exponent_digits(&self) -> bool {
Self::REQUIRED_EXPONENT_DIGITS
}
pub const REQUIRED_MANTISSA_DIGITS: bool = true;
#[inline(always)]
pub const fn required_mantissa_digits(&self) -> bool {
Self::REQUIRED_MANTISSA_DIGITS
}
pub const REQUIRED_DIGITS: bool = true;
#[inline(always)]
pub const fn required_digits(&self) -> bool {
Self::REQUIRED_DIGITS
}
pub const NO_POSITIVE_MANTISSA_SIGN: bool = false;
#[inline(always)]
pub const fn no_positive_mantissa_sign(&self) -> bool {
Self::NO_POSITIVE_MANTISSA_SIGN
}
pub const REQUIRED_MANTISSA_SIGN: bool = false;
#[inline(always)]
pub const fn required_mantissa_sign(&self) -> bool {
Self::REQUIRED_MANTISSA_SIGN
}
pub const NO_EXPONENT_NOTATION: bool = false;
#[inline(always)]
pub const fn no_exponent_notation(&self) -> bool {
Self::NO_EXPONENT_NOTATION
}
pub const NO_POSITIVE_EXPONENT_SIGN: bool = false;
#[inline(always)]
pub const fn no_positive_exponent_sign(&self) -> bool {
Self::NO_POSITIVE_EXPONENT_SIGN
}
pub const REQUIRED_EXPONENT_SIGN: bool = false;
#[inline(always)]
pub const fn required_exponent_sign(&self) -> bool {
Self::REQUIRED_EXPONENT_SIGN
}
pub const NO_EXPONENT_WITHOUT_FRACTION: bool = false;
#[inline(always)]
pub const fn no_exponent_without_fraction(&self) -> bool {
Self::NO_EXPONENT_WITHOUT_FRACTION
}
pub const NO_SPECIAL: bool = false;
#[inline(always)]
pub const fn no_special(&self) -> bool {
Self::NO_SPECIAL
}
pub const CASE_SENSITIVE_SPECIAL: bool = false;
#[inline(always)]
pub const fn case_sensitive_special(&self) -> bool {
Self::CASE_SENSITIVE_SPECIAL
}
pub const NO_INTEGER_LEADING_ZEROS: bool = false;
#[inline(always)]
pub const fn no_integer_leading_zeros(&self) -> bool {
Self::NO_INTEGER_LEADING_ZEROS
}
pub const NO_FLOAT_LEADING_ZEROS: bool = false;
#[inline(always)]
pub const fn no_float_leading_zeros(&self) -> bool {
Self::NO_FLOAT_LEADING_ZEROS
}
pub const REQUIRED_EXPONENT_NOTATION: bool = false;
#[inline(always)]
pub const fn required_exponent_notation(&self) -> bool {
Self::REQUIRED_EXPONENT_NOTATION
}
pub const CASE_SENSITIVE_EXPONENT: bool = false;
#[inline(always)]
pub const fn case_sensitive_exponent(&self) -> bool {
Self::CASE_SENSITIVE_EXPONENT
}
pub const CASE_SENSITIVE_BASE_PREFIX: bool = false;
#[inline(always)]
pub const fn case_sensitive_base_prefix(&self) -> bool {
Self::CASE_SENSITIVE_BASE_PREFIX
}
pub const CASE_SENSITIVE_BASE_SUFFIX: bool = false;
#[inline(always)]
pub const fn case_sensitive_base_suffix(&self) -> bool {
Self::CASE_SENSITIVE_BASE_SUFFIX
}
pub const INTEGER_INTERNAL_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn integer_internal_digit_separator(&self) -> bool {
Self::INTEGER_INTERNAL_DIGIT_SEPARATOR
}
pub const FRACTION_INTERNAL_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn fraction_internal_digit_separator(&self) -> bool {
Self::FRACTION_INTERNAL_DIGIT_SEPARATOR
}
pub const EXPONENT_INTERNAL_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn exponent_internal_digit_separator(&self) -> bool {
Self::EXPONENT_INTERNAL_DIGIT_SEPARATOR
}
pub const INTERNAL_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn internal_digit_separator(&self) -> bool {
Self::INTERNAL_DIGIT_SEPARATOR
}
pub const INTEGER_LEADING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn integer_leading_digit_separator(&self) -> bool {
Self::INTEGER_LEADING_DIGIT_SEPARATOR
}
pub const FRACTION_LEADING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn fraction_leading_digit_separator(&self) -> bool {
Self::FRACTION_LEADING_DIGIT_SEPARATOR
}
pub const EXPONENT_LEADING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn exponent_leading_digit_separator(&self) -> bool {
Self::EXPONENT_LEADING_DIGIT_SEPARATOR
}
pub const LEADING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn leading_digit_separator(&self) -> bool {
Self::LEADING_DIGIT_SEPARATOR
}
pub const INTEGER_TRAILING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn integer_trailing_digit_separator(&self) -> bool {
Self::INTEGER_TRAILING_DIGIT_SEPARATOR
}
pub const FRACTION_TRAILING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn fraction_trailing_digit_separator(&self) -> bool {
Self::FRACTION_TRAILING_DIGIT_SEPARATOR
}
pub const EXPONENT_TRAILING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn exponent_trailing_digit_separator(&self) -> bool {
Self::EXPONENT_TRAILING_DIGIT_SEPARATOR
}
pub const TRAILING_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn trailing_digit_separator(&self) -> bool {
Self::TRAILING_DIGIT_SEPARATOR
}
pub const INTEGER_CONSECUTIVE_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn integer_consecutive_digit_separator(&self) -> bool {
Self::INTEGER_CONSECUTIVE_DIGIT_SEPARATOR
}
pub const FRACTION_CONSECUTIVE_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn fraction_consecutive_digit_separator(&self) -> bool {
Self::FRACTION_CONSECUTIVE_DIGIT_SEPARATOR
}
pub const EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn exponent_consecutive_digit_separator(&self) -> bool {
Self::EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR
}
pub const CONSECUTIVE_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn consecutive_digit_separator(&self) -> bool {
Self::CONSECUTIVE_DIGIT_SEPARATOR
}
pub const SPECIAL_DIGIT_SEPARATOR: bool = false;
#[inline(always)]
pub const fn special_digit_separator(&self) -> bool {
Self::SPECIAL_DIGIT_SEPARATOR
}
pub const DIGIT_SEPARATOR: u8 = 0;
#[inline(always)]
pub const fn digit_separator(&self) -> u8 {
Self::DIGIT_SEPARATOR
}
pub const BASE_PREFIX: u8 = 0;
#[inline(always)]
pub const fn base_prefix(&self) -> u8 {
Self::BASE_PREFIX
}
pub const BASE_SUFFIX: u8 = 0;
#[inline(always)]
pub const fn base_suffix(&self) -> u8 {
Self::BASE_SUFFIX
}
pub const MANTISSA_RADIX: u32 = flags::mantissa_radix(FORMAT);
#[inline(always)]
pub const fn mantissa_radix(&self) -> u32 {
Self::MANTISSA_RADIX
}
pub const RADIX: u32 = Self::MANTISSA_RADIX;
#[inline(always)]
pub const fn radix(&self) -> u32 {
Self::RADIX
}
pub const EXPONENT_BASE: u32 = flags::exponent_base(FORMAT);
#[inline(always)]
pub const fn exponent_base(&self) -> u32 {
Self::EXPONENT_BASE
}
pub const EXPONENT_RADIX: u32 = flags::exponent_radix(FORMAT);
#[inline(always)]
pub const fn exponent_radix(&self) -> u32 {
Self::EXPONENT_RADIX
}
#[inline(always)]
pub const fn flags(&self) -> u128 {
FORMAT & flags::FLAG_MASK
}
#[inline(always)]
pub const fn interface_flags(&self) -> u128 {
FORMAT & flags::INTERFACE_FLAG_MASK
}
#[inline(always)]
pub const fn digit_separator_flags(&self) -> u128 {
FORMAT & flags::DIGIT_SEPARATOR_FLAG_MASK
}
#[inline(always)]
pub const fn exponent_flags(&self) -> u128 {
FORMAT & flags::EXPONENT_FLAG_MASK
}
#[inline(always)]
pub const fn integer_digit_separator_flags(&self) -> u128 {
FORMAT & flags::INTEGER_DIGIT_SEPARATOR_FLAG_MASK
}
#[inline(always)]
pub const fn fraction_digit_separator_flags(&self) -> u128 {
FORMAT & flags::FRACTION_DIGIT_SEPARATOR_FLAG_MASK
}
#[inline(always)]
pub const fn exponent_digit_separator_flags(&self) -> u128 {
FORMAT & flags::EXPONENT_DIGIT_SEPARATOR_FLAG_MASK
}
#[inline]
pub const fn builder() -> NumberFormatBuilder {
NumberFormatBuilder::new()
}
#[inline]
pub const fn rebuild() -> NumberFormatBuilder {
NumberFormatBuilder::rebuild(FORMAT)
}
}