NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
hexadecimal结构体 参考

十六进制数值包装类 更多...

#include <hexadecimal.hpp>

类 hexadecimal 继承关系图:
[图例]

Public 类型

using value_type = int64_t
 值类型
using base = ipackage
 基类类型
Public 类型 继承自 ipackage< hexadecimal, int64_t >
using package_type
 包装类型

Public 成员函数

constexpr hexadecimal (const int16_t value) noexcept
 从16位有符号整数构造
constexpr hexadecimal (const int32_t value) noexcept
 从32位有符号整数构造
constexpr hexadecimal (const uint16_t value) noexcept
 从16位无符号整数构造
constexpr hexadecimal (const uint32_t value) noexcept
 从32位无符号整数构造
constexpr hexadecimal (const uint64_t value) noexcept
 从64位无符号整数构造
NEFORCE_CONSTEXPR20 hexadecimal (const string_view view)
 从字符串视图构造
NEFORCE_CONSTEXPR20 hexadecimal (const char *str)
 从C风格字符串构造
NEFORCE_CONSTEXPR20 hexadecimal (const string &str)
 从字符串对象构造
NEFORCE_NODISCARD constexpr operator bool () const noexcept
 转换为bool操作符
NEFORCE_NODISCARD constexpr bool get_bit (const size_t position) const
 获取指定位的值
constexpr hexadecimalset_bit (const size_t position, const bool bit_value_=true)
 设置指定位的值
constexpr hexadecimalflip_bit (const size_t position)
 翻转指定位
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string () const
 转换为字符串
Public 成员函数 继承自 iobject< hexadecimal >
NEFORCE_CONSTEXPR20 bool try_parse (const string_view str) noexcept
 尝试从字符串解析对象
Public 成员函数 继承自 istringify< hexadecimal >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string () const
 转换为字符串
Public 成员函数 继承自 ipackage< hexadecimal, int64_t >
NEFORCE_NODISCARD constexpr operator package_type () const noexcept
 类型转换操作符
NEFORCE_NODISCARD constexpr package_type value () const noexcept
 获取数值
NEFORCE_NODISCARD constexpr int64_t to_int64 () const noexcept
 转换为64位整数
NEFORCE_NODISCARD constexpr size_t to_hash () const noexcept
 计算哈希值
constexpr void swap (hexadecimal &other) noexcept
 交换内容
NEFORCE_NODISCARD constexpr bool operator== (const hexadecimal &other) const noexcept
 相等比较操作符
NEFORCE_NODISCARD constexpr bool operator< (const hexadecimal &other) const noexcept
 小于比较操作符
constexpr hexadecimaloperator+= (const hexadecimal &other) noexcept
 加法赋值操作符
constexpr hexadecimaloperator-= (const hexadecimal &other) noexcept
 减法赋值操作符
constexpr hexadecimaloperator*= (const hexadecimal &other) noexcept
 乘法赋值操作符
constexpr hexadecimaloperator/= (const hexadecimal &other)
 除法赋值操作符
constexpr hexadecimaloperator%= (const hexadecimal &other)
 取模赋值操作符
NEFORCE_NODISCARD constexpr hexadecimal operator- () const noexcept
 一元负号操作符
constexpr hexadecimaloperator++ () noexcept
 前置递增操作符
constexpr hexadecimaloperator-- () noexcept
 前置递减操作符
constexpr hexadecimal operator~ () const noexcept
 按位取反操作符
constexpr hexadecimaloperator&= (const hexadecimal &other) noexcept
 按位与赋值操作符
constexpr hexadecimaloperator|= (const hexadecimal &other) noexcept
 按位或赋值操作符
constexpr hexadecimaloperator^= (const hexadecimal &other) noexcept
 按位异或赋值操作符
constexpr hexadecimaloperator<<= (const uint32_t shift)
 左移赋值操作符
constexpr hexadecimaloperator>>= (const uint32_t shift)
 右移赋值操作符
Public 成员函数 继承自 icomparable< hexadecimal >
NEFORCE_NODISCARD constexpr bool operator== (const hexadecimal &rhs) const noexcept(noexcept(derived()==rhs))
 相等比较运算符
NEFORCE_NODISCARD constexpr bool operator!= (const hexadecimal &rhs) const noexcept(noexcept(!(*this==rhs)))
 不等比较运算符
NEFORCE_NODISCARD constexpr bool operator< (const hexadecimal &rhs) const noexcept(noexcept(derived()< rhs))
 小于比较运算符
NEFORCE_NODISCARD constexpr bool operator> (const hexadecimal &rhs) const noexcept(noexcept(rhs< derived()))
 大于比较运算符
NEFORCE_NODISCARD constexpr bool operator<= (const hexadecimal &rhs) const noexcept(noexcept(!(derived() > rhs)))
 小于等于比较运算符
NEFORCE_NODISCARD constexpr bool operator>= (const hexadecimal &rhs) const noexcept(noexcept(!(derived()< rhs)))
 大于等于比较运算符
Public 成员函数 继承自 ihashable< hexadecimal >
NEFORCE_NODISCARD constexpr size_t to_hash () const noexcept(noexcept(derived().to_hash()))
 获取对象的哈希值
Public 成员函数 继承自 iarithmetic< hexadecimal >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator+ (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator+=(other)))
 加法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator- (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator-=(other)))
 减法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator* (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator*=(other)))
 乘法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator/ (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator/=(other)))
 除法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator% (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator%=(other)))
 取模运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator+= (const hexadecimal &other) noexcept(noexcept(derived().operator+=(other)))
 加法赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator-= (const hexadecimal &other) noexcept(noexcept(derived().operator-=(other)))
 减法赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator*= (const hexadecimal &other) noexcept(noexcept(derived().operator*=(other)))
 乘法赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator/= (const hexadecimal &other)
 除法赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator%= (const hexadecimal &other)
 取模赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator++ () noexcept(noexcept(derived().operator++()))
 前置自增运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator-- () noexcept(noexcept(derived().operator--()))
 前置自减运算符
Public 成员函数 继承自 ibinary< hexadecimal >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator& (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator&=(other)))
 按位与运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator| (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator|=(other)))
 按位或运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator^ (const hexadecimal &other) const noexcept(noexcept(const_cast< hexadecimal & >(derived()).operator^=(other)))
 按位异或运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator~ () const noexcept(noexcept(derived().operator~()))
 按位取反运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator<< (const uint32_t shift) const
 左移运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 hexadecimal operator>> (const uint32_t shift) const
 右移运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator&= (const hexadecimal &other) noexcept(noexcept(derived().operator&=(other)))
 按位与赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator|= (const hexadecimal &other) noexcept(noexcept(derived().operator|=(other)))
 按位或赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator^= (const hexadecimal &other) noexcept(noexcept(derived().operator^=(other)))
 按位异或赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator<<= (const uint32_t shift)
 左移赋值运算符
NEFORCE_CONSTEXPR14 hexadecimaloperator>>= (const uint32_t shift)
 右移赋值运算符

静态 Public 成员函数

static constexpr byte_t xdigit_value (const char c) noexcept
 将十六进制字符转换为对应的数值
static NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 hexadecimal parse (const string_view str)
 从字符串解析十六进制值
静态 Public 成员函数 继承自 iobject< hexadecimal >
static NEFORCE_NODISCARD constexpr hexadecimal parse (const string_view str)
 从字符串解析对象
静态 Public 成员函数 继承自 ipackage< hexadecimal, int64_t >
static NEFORCE_NODISCARD constexpr size_t bytes () noexcept
 获取类型字节大小
static NEFORCE_NODISCARD constexpr size_t bits () noexcept
 获取类型位大小

额外继承的成员函数

Protected 成员函数 继承自 ipackage< hexadecimal, int64_t >
NEFORCE_CONSTEXPR20 ~ipackage ()=default
 受保护的析构函数
Protected 属性 继承自 ipackage< hexadecimal, int64_t >
package_type value_
 存储的数值

详细描述

十六进制数值包装类

提供十六进制数值的包装,支持从字符串解析、位操作、格式化等功能。 内部使用int64_t存储,支持64位以内的十六进制值。

在文件 hexadecimal.hpp29 行定义.

构造及析构函数说明

◆ hexadecimal() [1/8]

hexadecimal::hexadecimal ( const int16_t value)
inlineexplicitconstexprnoexcept

从16位有符号整数构造

参数
value整数值

在文件 hexadecimal.hpp131 行定义.

引用了 ipackage< hexadecimal, int64_t >::value().

被这些函数引用 flip_bit(), hexadecimal(), hexadecimal(), parse() , 以及 set_bit().

◆ hexadecimal() [2/8]

hexadecimal::hexadecimal ( const int32_t value)
inlineexplicitconstexprnoexcept

从32位有符号整数构造

参数
value整数值

在文件 hexadecimal.hpp138 行定义.

引用了 ipackage< hexadecimal, int64_t >::value().

◆ hexadecimal() [3/8]

hexadecimal::hexadecimal ( const uint16_t value)
inlineexplicitconstexprnoexcept

从16位无符号整数构造

参数
value整数值

在文件 hexadecimal.hpp145 行定义.

引用了 ipackage< hexadecimal, int64_t >::value().

◆ hexadecimal() [4/8]

hexadecimal::hexadecimal ( const uint32_t value)
inlineexplicitconstexprnoexcept

从32位无符号整数构造

参数
value整数值

在文件 hexadecimal.hpp152 行定义.

引用了 ipackage< hexadecimal, int64_t >::value().

◆ hexadecimal() [5/8]

hexadecimal::hexadecimal ( const uint64_t value)
inlineexplicitconstexprnoexcept

从64位无符号整数构造

参数
value整数值

在文件 hexadecimal.hpp159 行定义.

引用了 ipackage< hexadecimal, int64_t >::value().

◆ hexadecimal() [6/8]

NEFORCE_CONSTEXPR20 hexadecimal::hexadecimal ( const string_view view)
inlineexplicit

从字符串视图构造

参数
view十六进制字符串视图
异常
value_exception解析失败时抛出

在文件 hexadecimal.hpp167 行定义.

◆ hexadecimal() [7/8]

NEFORCE_CONSTEXPR20 hexadecimal::hexadecimal ( const char * str)
inlineexplicit

从C风格字符串构造

参数
str十六进制字符串
异常
value_exception解析失败时抛出

在文件 hexadecimal.hpp175 行定义.

引用了 hexadecimal().

◆ hexadecimal() [8/8]

NEFORCE_CONSTEXPR20 hexadecimal::hexadecimal ( const string & str)
inlineexplicit

从字符串对象构造

参数
str十六进制字符串
异常
value_exception解析失败时抛出

在文件 hexadecimal.hpp183 行定义.

引用了 hexadecimal().

成员函数说明

◆ flip_bit()

hexadecimal & hexadecimal::flip_bit ( const size_t position)
inlineconstexpr

翻转指定位

参数
position位位置(0-63)
返回
自身引用
异常
value_exception位置超出范围时抛出

在文件 hexadecimal.hpp247 行定义.

引用了 hexadecimal() , 以及 ipackage< hexadecimal, int64_t >::value_.

◆ get_bit()

NEFORCE_NODISCARD constexpr bool hexadecimal::get_bit ( const size_t position) const
inlineconstexpr

获取指定位的值

参数
position位位置(0-63)
返回
该位的值(0或1)
异常
value_exception位置超出范围时抛出

在文件 hexadecimal.hpp215 行定义.

引用了 ipackage< hexadecimal, int64_t >::value_.

◆ operator bool()

NEFORCE_NODISCARD constexpr hexadecimal::operator bool ( ) const
inlineexplicitconstexprnoexcept

转换为bool操作符

返回
值是否非零

在文件 hexadecimal.hpp207 行定义.

引用了 ipackage< hexadecimal, int64_t >::value_.

◆ parse()

NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 hexadecimal hexadecimal::parse ( const string_view str)
inlinestatic

从字符串解析十六进制值

参数
str要解析的字符串
返回
解析得到的十六进制对象
异常
value_exception解析失败时抛出

在文件 hexadecimal.hpp267 行定义.

引用了 hexadecimal().

被这些函数引用 color::parse().

◆ set_bit()

hexadecimal & hexadecimal::set_bit ( const size_t position,
const bool bit_value_ = true )
inlineconstexpr

设置指定位的值

参数
position位位置(0-63)
bit_value_要设置的值(true为1,false为0)
返回
自身引用
异常
value_exception位置超出范围时抛出

在文件 hexadecimal.hpp229 行定义.

引用了 hexadecimal() , 以及 ipackage< hexadecimal, int64_t >::value_.

◆ to_string()

NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string hexadecimal::to_string ( ) const

转换为字符串

返回
十六进制格式的字符串(带0x前缀)

◆ xdigit_value()

constexpr byte_t hexadecimal::xdigit_value ( const char c)
inlinestaticconstexprnoexcept

将十六进制字符转换为对应的数值

参数
c十六进制字符(0-9, a-f, A-F)
返回
对应的数值(0-15),当字符无效时返回invalid_xdigit

在文件 hexadecimal.hpp42 行定义.


该结构体的文档由以下文件生成: