MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / value

Class value

lib/mathlib.h:51–91  ·  view source on GitHub ↗

@brief value class */

Source from the content-addressed store, hash-verified

49
50 /** @brief value class */
51 class value {
52 private:
53 bigint mIntValue{};
54 double mDoubleValue{};
55 enum class Type : std::uint8_t { INT, LONG, LONGLONG, FLOAT } mType;
56 bool mIsUnsigned{};
57
58 void promote(const value &v);
59
60 public:
61 /**
62 * @throws InternalError thrown on invalid value
63 */
64 explicit value(const std::string &s);
65 std::string str() const;
66 bool isInt() const {
67 return mType != Type::FLOAT;
68 }
69 bool isFloat() const {
70 return mType == Type::FLOAT;
71 }
72
73 double getDoubleValue() const {
74 return isFloat() ? mDoubleValue : static_cast<double>(mIntValue);
75 }
76
77 /**
78 * @throws InternalError thrown on invalid/unhandled calculation or division by zero
79 */
80 static value calc(char op, const value &v1, const value &v2);
81 int compare(const value &v) const;
82 value add(int v) const;
83 /**
84 * @throws InternalError thrown if operand is not an integer
85 */
86 value shiftLeft(const value &v) const;
87 /**
88 * @throws InternalError thrown if operand is not an integer
89 */
90 value shiftRight(const value &v) const;
91 };
92
93 static const int bigint_bits;
94

Callers 11

addMethod · 0.70
subtractMethod · 0.70
divideMethod · 0.70
multiplyMethod · 0.70
modMethod · 0.70
serializeRulesMethod · 0.70
serializeLocationsMethod · 0.70
serializeResultsMethod · 0.70
serializeRunsMethod · 0.70
serializeMethod · 0.70
loadAddonMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected