42 : string_value(other.string_value), number_value(other.number_value), interval_value(other.interval_value), boolean_value(other.boolean_value), value_type(other.value_type) {}
61 : string_value(string_value), value_type(
STRING) {}
64 : number_value(number_value), value_type(
NUMBER) {}
67 : interval_value(interval_value), value_type(
INTERVAL) {}
70 : boolean_value(boolean_value), value_type(
BOOLEAN) {}
100 throw std::runtime_error(
"Value is not a string");
107 throw std::runtime_error(
"Value is not a number");
114 throw std::runtime_error(
"Value is not an interval");
121 throw std::runtime_error(
"Value is not a boolean");
168std::shared_ptr<Value>
newValue(
const std::string &string_value) {
169 return std::make_shared<Value>(string_value);
173 return std::make_shared<Value>(number_value);
177 return std::make_shared<Value>(interval_value);
180std::shared_ptr<Value>
newValue(
const bool &boolean_value) {
181 return std::make_shared<Value>(boolean_value);
185 return std::make_shared<Value>(value_type);
188std::shared_ptr<Value>
newValue(
const int &integer_value) {
189 return std::make_shared<Value>(
Number(integer_value));
192std::shared_ptr<Value>
newValue(
const double &double_value) {
193 return std::make_shared<Value>(
Number(double_value));
196std::shared_ptr<Value>
newValue(
const float &float_value) {
197 return std::make_shared<Value>(
Number(
static_cast<double>(float_value)));
200std::shared_ptr<Value>
newValue(
const long &long_value) {
201 return std::make_shared<Value>(
Number(
static_cast<int>(long_value)));
204std::shared_ptr<Value>
newValue(
const short &short_value) {
205 return std::make_shared<Value>(
Number(
static_cast<int>(short_value)));
208std::shared_ptr<Value>
newValue(
const char &char_value) {
209 return std::make_shared<Value>(
Number(
static_cast<int>(char_value)));
236 throw std::runtime_error(
"Cannot compare values of different types");
249 throw std::runtime_error(
"Cannot compare values of this type");
254 return (*
this < other) || (*
this == other);
274 throw std::runtime_error(
"Cannot add values of these types");
287 throw std::runtime_error(
"Cannot subtract values of these types");
300 throw std::runtime_error(
"Cannot multiply values of these types");
313 throw std::runtime_error(
"Cannot divide values of these types");
326 throw std::runtime_error(
"Cannot perform modulo on values of these types");
338 throw std::runtime_error(
"Cannot compute sine of this type");
349 throw std::runtime_error(
"Cannot compute cosine of this type");
360 throw std::runtime_error(
"Cannot compute tangent of this type");
371 throw std::runtime_error(
"Cannot compute square root of this type");
382 throw std::runtime_error(
"Cannot compute exponential of this type");
393 throw std::runtime_error(
"Cannot compute natural logarithm of this type");
404 throw std::runtime_error(
"Cannot compute absolute value of this type");
420 throw std::runtime_error(
"Cannot compute power with these types");
427 throw std::runtime_error(
"Logical AND requires boolean operands");
434 throw std::runtime_error(
"Logical OR requires boolean operands");
441 throw std::runtime_error(
"Logical NOT requires a boolean operand");
448 *
this = *
this + other;
453 *
this = *
this - other;
458 *
this = *
this * other;
463 *
this = *
this / other;
468 *
this = *
this % other;
475 throw std::runtime_error(
"Bitwise XOR requires number operands");
477 throw std::runtime_error(
478 "Bitwise XOR operation not implemented for Number class");
483 throw std::runtime_error(
"Bitwise AND requires number operands");
485 throw std::runtime_error(
486 "Bitwise AND operation not implemented for Number class");
491 throw std::runtime_error(
"Bitwise OR requires number operands");
493 throw std::runtime_error(
494 "Bitwise OR operation not implemented for Number class");
499 throw std::runtime_error(
"Left shift requires number operands");
501 throw std::runtime_error(
502 "Left shift operation not implemented for Number class");
507 throw std::runtime_error(
"Right shift requires number operands");
509 throw std::runtime_error(
510 "Right shift operation not implemented for Number class");
516 throw std::runtime_error(
"Increment requires a number or interval");
529 throw std::runtime_error(
"Decrement requires a number or interval");
555 throw std::runtime_error(
556 "Bitwise NOT operation not implemented for Number class");
562 throw std::runtime_error(
"Bitwise NOT requires a number or interval");
574 throw std::runtime_error(
"Negation requires a number or interval");
586 throw std::runtime_error(
"Cannot compute safe square root of this type");
597 throw std::runtime_error(
"Cannot compute base-10 logarithm of this type");
608 throw std::runtime_error(
"Cannot compute base-2 logarithm of this type");
617 throw std::runtime_error(
618 "Logarithm with custom base not implemented for intervals");
628 throw std::runtime_error(
"Ceiling function not implemented for intervals");
630 throw std::runtime_error(
"Cannot compute ceiling of this type");
640 throw std::runtime_error(
"Floor function not implemented for intervals");
642 throw std::runtime_error(
"Cannot compute floor of this type");
652 throw std::runtime_error(
"Round function not implemented for intervals");
654 throw std::runtime_error(
"Cannot round this type");
666 throw std::runtime_error(
"Cannot compute cotangent of this type");
677 throw std::runtime_error(
"Cannot compute secant of this type");
688 throw std::runtime_error(
"Cannot compute cosecant of this type");
700 throw std::runtime_error(
"Cannot compute arcsine of this type");
711 throw std::runtime_error(
"Cannot compute arccosine of this type");
722 throw std::runtime_error(
"Cannot compute arctangent of this type");
733 throw std::runtime_error(
"Cannot compute arccotangent of this type");
744 throw std::runtime_error(
"Cannot compute arcsecant of this type");
755 throw std::runtime_error(
"Cannot compute arccosecant of this type");
764 throw std::runtime_error(
"atan2 not implemented for intervals");
776 throw std::runtime_error(
"Cannot compute hyperbolic sine of this type");
787 throw std::runtime_error(
"Cannot compute hyperbolic cosine of this type");
798 throw std::runtime_error(
"Cannot compute hyperbolic tangent of this type");
809 throw std::runtime_error(
810 "Cannot compute hyperbolic cotangent of this type");
821 throw std::runtime_error(
"Cannot compute hyperbolic secant of this type");
832 throw std::runtime_error(
"Cannot compute hyperbolic cosecant of this type");
844 throw std::runtime_error(
845 "Cannot compute inverse hyperbolic sine of this type");
856 throw std::runtime_error(
857 "Cannot compute inverse hyperbolic cosine of this type");
868 throw std::runtime_error(
869 "Cannot compute inverse hyperbolic tangent of this type");
880 throw std::runtime_error(
881 "Cannot compute inverse hyperbolic cotangent of this type");
892 throw std::runtime_error(
893 "Cannot compute inverse hyperbolic secant of this type");
904 throw std::runtime_error(
905 "Cannot compute inverse hyperbolic cosecant of this type");
915 throw std::runtime_error(
"String concatenation requires string operands");
923 for (
int i = 0; i < count; i++) {
926 return Value(result);
929 throw std::runtime_error(
"String repeat requires a string and a number");
936 std::sort(result.begin(), result.end());
937 return Value(result);
940 throw std::runtime_error(
"Sort operation requires a string");
951 if (startPos < 0 || startPos >=
static_cast<int>(
string_value.length())) {
952 throw std::out_of_range(
"String substring start position out of range");
958 throw std::runtime_error(
959 "Substring operation requires a string and two numbers");
968 while ((pos = result.find(old.
string_value, pos)) != std::string::npos) {
972 return Value(result);
975 throw std::runtime_error(
"Replace operation requires three strings");
981 throw std::runtime_error(
"String split not implemented");
986 throw std::runtime_error(
"String join not implemented");
992 std::reverse(result.begin(), result.end());
993 return Value(result);
996 throw std::runtime_error(
"Reverse operation requires a string");
1004 if (result.find(c) == std::string::npos) {
1008 return Value(result);
1011 throw std::runtime_error(
"Unique operation requires a string");
1019 result.erase(result.begin(),
1020 std::find_if(result.begin(), result.end(), [](
int ch) { return !std::isspace(ch); }));
1022 result.erase(std::find_if(result.rbegin(), result.rend(), [](
int ch) { return !std::isspace(ch); })
1025 return Value(result);
1028 throw std::runtime_error(
"Trim operation requires a string");
1035 result.erase(result.begin(),
1036 std::find_if(result.begin(), result.end(), [](
int ch) { return !std::isspace(ch); }));
1037 return Value(result);
1040 throw std::runtime_error(
"Left trim operation requires a string");
1047 result.erase(std::find_if(result.rbegin(), result.rend(), [](
int ch) { return !std::isspace(ch); })
1050 return Value(result);
1053 throw std::runtime_error(
"Right trim operation requires a string");
1060 std::transform(result.begin(), result.end(), result.begin(), [](
unsigned char c) { return std::tolower(c); });
1061 return Value(result);
1064 throw std::runtime_error(
"toLower operation requires a string");
1071 std::transform(result.begin(), result.end(), result.begin(), [](
unsigned char c) { return std::toupper(c); });
1072 return Value(result);
1075 throw std::runtime_error(
"toUpper operation requires a string");
1085 catch (
const std::exception &e) {
1086 throw std::runtime_error(
"Cannot convert string to number: " +
1087 std::string(e.what()));
1097 throw std::runtime_error(
"Cannot convert this type to number");
1112 throw std::runtime_error(
"Cannot convert this type to boolean");
1117 throw std::runtime_error(
"Conversion to bit-vector not implemented");
1121 throw std::runtime_error(
"Conversion to floating-point not implemented");
1125 throw std::runtime_error(
"Conversion to array not implemented");
1134 throw std::runtime_error(
"Bitwise XOR requires number operands");
1136 throw std::runtime_error(
1137 "Bitwise XOR operation not implemented for Number class");
1143 throw std::runtime_error(
"Bitwise AND requires number operands");
1145 throw std::runtime_error(
1146 "Bitwise AND operation not implemented for Number class");
1152 throw std::runtime_error(
"Bitwise OR requires number operands");
1154 throw std::runtime_error(
1155 "Bitwise OR operation not implemented for Number class");
1161 throw std::runtime_error(
"Left shift requires number operands");
1163 throw std::runtime_error(
1164 "Left shift operation not implemented for Number class");
1170 throw std::runtime_error(
"Right shift requires number operands");
1172 throw std::runtime_error(
1173 "Right shift operation not implemented for Number class");
Interval mod(const Number &value) const
std::string toString() const
Interval pow(const Number &exp) const
Interval safeSqrt() const
Number pow(const Number &exp) const
std::string toString() const
HighPrecisionInteger toInteger() const
static Number atan2(const Number &y, const Number &x)
Number log(const Number &base) const
Value operator*(const Value &other) const
Value & operator<<=(const Value &other)
void setValue(const std::string &string_value)
Value pow(const Value &other) const
bool operator==(const Value &other) const
Interval getIntervalValue() const
Value log(const Value &other) const
Value split(const Value &delimiter) const
Value operator-(const Value &other) const
Value operator&(const Value &other) const
Value substr(const Value &start, const Value &end) const
Value join(const Value &delimiter) const
bool operator>(const Value &other) const
bool operator<(const Value &other) const
Value operator/(const Value &other) const
Value & operator-=(const Value &other)
ValueType getType() const
std::string toString() const
Value atan2(const Value &other) const
bool getBooleanValue() const
Value & operator+=(const Value &other)
std::string getStringValue() const
Value operator<<(const Value &other) const
Value & operator|=(const Value &other)
Value & operator>>=(const Value &other)
Value & operator=(const Value &other)
Number getNumberValue() const
bool operator<=(const Value &other) const
bool operator||(const Value &other) const
Value concatStr(const Value &other) const
Value & operator*=(const Value &other)
Value repeatStr(const Value &other) const
Value operator>>(const Value &other) const
Value operator%(const Value &other) const
Value operator+(const Value &other) const
bool operator>=(const Value &other) const
Value & operator&=(const Value &other)
Value operator^(const Value &other) const
Value & operator^=(const Value &other)
Value & operator%=(const Value &other)
Value & operator/=(const Value &other)
Value operator|(const Value &other) const
bool operator&&(const Value &other) const
bool operator!=(const Value &other) const
Value replace(const Value &old, const Value &newVal) const
std::shared_ptr< Value > newValue(const std::string &string_value)