Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum class eOperandType
- {
- Int8,
- Int16,
- Int32,
- Float,
- Double,
- None,
- };
- class IOperand
- {
- public:
- [[nodiscard]] virtual int getPrecision() const = 0;
- // Precision of the type of the instance
- [[nodiscard]] virtual eOperandType getType() const = 0;
- // Type of the instance
- virtual IOperand const* operator+(const IOperand& rhs) const = 0;
- // Sum
- virtual IOperand const* operator-(const IOperand& rhs) const = 0;
- // Difference
- virtual IOperand const* operator*(const IOperand& rhs) const = 0;
- // Product
- virtual IOperand const* operator/(const IOperand& rhs) const = 0;
- // Quotient
- virtual IOperand const* operator%(const IOperand& rhs) const = 0;
- // Modulo
- [[nodiscard]] virtual std::string const & toString() const = 0;
- // String representation of the instance
- virtual ~IOperand() = default;
- };
- /////////////////////////////////////////
- class OInt8 : public IOperand
- {
- public:
- explicit OInt8(int8_t val);
- explicit OInt8(const std::string &raw);
- [[nodiscard]] int getPrecision() const override ;
- [[nodiscard]] eOperandType getType() const override;
- IOperand const* operator+(const IOperand& rhs) const override;
- IOperand const* operator-(const IOperand& rhs) const override;
- IOperand const* operator*(const IOperand& rhs) const override;
- IOperand const* operator/(const IOperand& rhs) const override;
- IOperand const* operator%(const IOperand& rhs) const override;
- [[nodiscard]] std::string const & toString() const override;
- private:
- int8_t value_;
- std::string raw_;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement