LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral类 参考
LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral 的协作图:

Public 成员函数

 RationalLiteral (const std::string &text, std::size_t max_bytes, std::size_t max_scale)

Public 属性

std::int64_t exponent = 0
std::string fractional_digits
std::string integer_digits
bool negative = false
std::string repeating_digits

Private 成员函数

void read_digits (std::string &output)
std::int64_t read_exponent (std::size_t max_scale)
std::int64_t read_exponent_magnitude (std::size_t max_scale)
void read_repeating_digits (bool has_decimal_point)
bool read_sign ()

Private 属性

std::size_t pos_ = 0
const std::string & text_

详细描述

在文件 rational_parsing.cpp 第 8 行定义.

构造及析构函数说明

◆ RationalLiteral()

LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::RationalLiteral ( const std::string & text,
std::size_t max_bytes,
std::size_t max_scale )
inline

在文件 rational_parsing.cpp 第 16 行定义.

17 : text_(text) {
18 if (text.empty()) throw std::invalid_argument("Rational literal is empty");
19 if (text.size() > max_bytes) {
20 throw std::length_error("Rational literal exceeds safety limit");
21 }
23 if (pos_ == text.size()) {
24 throw std::invalid_argument("Rational literal has no digits");
25 }
27 const bool has_decimal_point = pos_ < text.size() && text[pos_] == '.';
28 if (has_decimal_point) {
29 ++pos_;
31 }
32 read_repeating_digits(has_decimal_point);
33 if (integer_digits.empty() && fractional_digits.empty()) {
34 throw std::invalid_argument("Rational literal has no digits");
35 }
36 exponent = read_exponent(max_scale);
37 if (pos_ != text.size()) {
38 throw std::invalid_argument("Invalid character in Rational literal");
39 }
40 if (integer_digits.empty()) integer_digits = "0";
41 }

引用了 exponent, fractional_digits, integer_digits, negative, pos_, read_digits(), read_exponent(), read_repeating_digits(), read_sign() , 以及 text_.

函数调用图:

成员函数说明

◆ read_digits()

void LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::read_digits ( std::string & output)
inlineprivate

在文件 rational_parsing.cpp 第 54 行定义.

54 {
55 while (pos_ < text_.size() &&
56 std::isdigit(static_cast<unsigned char>(text_[pos_]))) {
57 output.push_back(text_[pos_++]);
58 }
59 }

引用了 pos_ , 以及 text_.

被这些函数引用 RationalLiteral() , 以及 read_repeating_digits().

这是这个函数的调用关系图:

◆ read_exponent()

std::int64_t LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::read_exponent ( std::size_t max_scale)
inlineprivate

在文件 rational_parsing.cpp 第 74 行定义.

74 {
75 if (pos_ == text_.size() || (text_[pos_] != 'e' && text_[pos_] != 'E')) {
76 return 0;
77 }
78 ++pos_;
79 const bool exponent_negative = read_sign();
80 if (pos_ == text_.size() ||
81 !std::isdigit(static_cast<unsigned char>(text_[pos_]))) {
82 throw std::invalid_argument("Rational exponent has no digits");
83 }
84 const std::int64_t value = read_exponent_magnitude(max_scale);
85 return exponent_negative ? -value : value;
86 }
const std::string const ExprPtr & value

引用了 pos_, read_exponent_magnitude(), read_sign(), text_ , 以及 LMCAS::value.

被这些函数引用 RationalLiteral().

函数调用图:
这是这个函数的调用关系图:

◆ read_exponent_magnitude()

std::int64_t LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::read_exponent_magnitude ( std::size_t max_scale)
inlineprivate

在文件 rational_parsing.cpp 第 88 行定义.

88 {
89 std::int64_t value = 0;
90 while (pos_ < text_.size() &&
91 std::isdigit(static_cast<unsigned char>(text_[pos_]))) {
92 const int digit = text_[pos_++] - '0';
93 if (value > static_cast<std::int64_t>(max_scale / 10) ||
94 value * 10 + digit > static_cast<std::int64_t>(max_scale)) {
95 throw std::length_error("Rational exponent exceeds safety limit");
96 }
97 value = value * 10 + digit;
98 }
99 return value;
100 }

引用了 pos_, text_ , 以及 LMCAS::value.

被这些函数引用 read_exponent().

这是这个函数的调用关系图:

◆ read_repeating_digits()

void LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::read_repeating_digits ( bool has_decimal_point)
inlineprivate

在文件 rational_parsing.cpp 第 61 行定义.

61 {
62 if (pos_ == text_.size() || text_[pos_] != '(') return;
63 if (!has_decimal_point) {
64 throw std::invalid_argument("Repeating decimal section requires a decimal point");
65 }
66 ++pos_;
68 if (repeating_digits.empty() || pos_ >= text_.size() || text_[pos_] != ')') {
69 throw std::invalid_argument("Invalid repeating decimal section");
70 }
71 ++pos_;
72 }

引用了 pos_, read_digits(), repeating_digits , 以及 text_.

被这些函数引用 RationalLiteral().

函数调用图:
这是这个函数的调用关系图:

◆ read_sign()

bool LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::read_sign ( )
inlineprivate

在文件 rational_parsing.cpp 第 47 行定义.

47 {
48 if (pos_ == text_.size() || (text_[pos_] != '+' && text_[pos_] != '-')) {
49 return false;
50 }
51 return text_[pos_++] == '-';
52 }

引用了 pos_ , 以及 text_.

被这些函数引用 RationalLiteral() , 以及 read_exponent().

这是这个函数的调用关系图:

类成员变量说明

◆ exponent

std::int64_t LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::exponent = 0

在文件 rational_parsing.cpp 第 14 行定义.

被这些函数引用 RationalLiteral().

◆ fractional_digits

std::string LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::fractional_digits

在文件 rational_parsing.cpp 第 11 行定义.

被这些函数引用 RationalLiteral().

◆ integer_digits

std::string LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::integer_digits

在文件 rational_parsing.cpp 第 10 行定义.

被这些函数引用 RationalLiteral().

◆ negative

bool LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::negative = false

在文件 rational_parsing.cpp 第 13 行定义.

被这些函数引用 RationalLiteral().

◆ pos_

std::size_t LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::pos_ = 0
private

◆ repeating_digits

std::string LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::repeating_digits

在文件 rational_parsing.cpp 第 12 行定义.

被这些函数引用 read_repeating_digits().

◆ text_

const std::string& LMCAS::anonymous_namespace{rational_parsing.cpp}::RationalLiteral::text_
private

该类的文档由以下文件生成: