![]() |
rego-cpp 1.0.0
A C++ implementation of the Rego language and runtime
|
Big Integer implemention based on strings. More...
#include <rego.hh>
Public Member Functions | |
| BigInt () | |
| Default constructor, initializes to zero. | |
| BigInt (const Location &value) | |
| Constructs a BigInt from a Location representing a arbitrary precision integer string. | |
| BigInt (std::int64_t value) | |
| Constructs a BigInt from a 64-bit integer. | |
| BigInt (std::size_t value) | |
| Constructs a BigInt from a size_t integer. | |
| const Location & | loc () const |
| Gets the Location representing the integer string. | |
| std::optional< std::int64_t > | to_int () const |
| Attempts to convert the BigInt to a 64-bit integer. | |
| std::optional< std::size_t > | to_size () const |
| Attempts to convert the BigInt to a size_t integer. | |
| bool | is_negative () const |
| Checks if the BigInt is negative. | |
| bool | is_zero () const |
| Checks if the BigInt is zero. | |
| BigInt | increment () const |
| Increments the BigInt by one. | |
| BigInt | decrement () const |
| Decrements the BigInt by one. | |
| BigInt | abs () const |
| Gets the absolute value of the BigInt. | |
| BigInt | negate () const |
| Negates the BigInt. | |
Static Public Member Functions | |
| static bool | is_int (const Location &loc) |
| Checks if a Location represents a valid integer string. | |
Friends | |
| BigInt | operator+ (const BigInt &lhs, const BigInt &rhs) |
| Adds two BigInts. | |
| BigInt | operator- (const BigInt &lhs, const BigInt &rhs) |
| Subtracts two BigInts. | |
| BigInt | operator* (const BigInt &lhs, const BigInt &rhs) |
| Multiplies two BigInts. | |
| BigInt | operator/ (const BigInt &lhs, const BigInt &rhs) |
| Divides two BigInts. | |
| BigInt | operator% (const BigInt &lhs, const BigInt &rhs) |
| Computes the remainder of dividing two BigInts. | |
| bool | operator> (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for greater-than. | |
| bool | operator< (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for less-than. | |
| bool | operator<= (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for less-than-or-equal. | |
| bool | operator>= (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for greater-than-or-equal. | |
| bool | operator== (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for equality. | |
| bool | operator!= (const BigInt &lhs, const BigInt &rhs) |
| Compares two BigInts for inequality. | |
| std::ostream & | operator<< (std::ostream &os, const BigInt &value) |
| Outputs a BigInt to a stream. | |
Big Integer implemention based on strings.
using strings. In most circumstances this would be considerably slower than other approaches, but given the way in which Trieste nodes store their content as Location objects into a source document, and given how this class operates over those Locations, it is actually quite efficient when compared to parsing and serializing the Location into a vector of unsigned longs.
| rego::BigInt::BigInt | ( | const Location & | value | ) |
Constructs a BigInt from a Location representing a arbitrary precision integer string.
| value | The Location to construct from. |
| rego::BigInt::BigInt | ( | std::int64_t | value | ) |
Constructs a BigInt from a 64-bit integer.
| value | The 64-bit integer to construct from. |
| rego::BigInt::BigInt | ( | std::size_t | value | ) |
Constructs a BigInt from a size_t integer.
| value | The size_t integer to construct from. |
| BigInt rego::BigInt::abs | ( | ) | const |
| BigInt rego::BigInt::decrement | ( | ) | const |
| BigInt rego::BigInt::increment | ( | ) | const |
|
static |
Checks if a Location represents a valid integer string.
| loc | The Location to check. |
| bool rego::BigInt::is_negative | ( | ) | const |
| bool rego::BigInt::is_zero | ( | ) | const |
| const Location & rego::BigInt::loc | ( | ) | const |
Gets the Location representing the integer string.
| BigInt rego::BigInt::negate | ( | ) | const |
| std::optional< std::int64_t > rego::BigInt::to_int | ( | ) | const |
| std::optional< std::size_t > rego::BigInt::to_size | ( | ) | const |
Compares two BigInts for inequality.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Computes the remainder of dividing two BigInts.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Multiplies two BigInts.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Adds two BigInts.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Subtracts two BigInts.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Divides two BigInts.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Compares two BigInts for less-than.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
|
friend |
Compares two BigInts for less-than-or-equal.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Compares two BigInts for equality.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Compares two BigInts for greater-than.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |
Compares two BigInts for greater-than-or-equal.
| lhs | The left-hand side operand. |
| rhs | The right-hand side operand. |