1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#ifndef INCLUDED_VARIABLE_
#define INCLUDED_VARIABLE_
#include <ostream>
#include <memory>
#include <compare>
#include "../varbase/varbase.h"
class Variable: private std::unique_ptr<VarBase>
{
friend std::ostream &operator<<(std::ostream &out, Variable const &var);
friend bool operator==(Variable const &lhs, Variable const &rhs);
friend std::strong_ordering operator<=>(Variable const &lhs,
Variable const &rhs);
public:
Variable(VarBase *ptr = 0);
Variable(Variable const &other);
Variable(Variable &&tmp);
Variable &operator=(Variable const &other);
Variable &operator=(Variable &&tmp) = default;
Variable &operator=(int value); // 1.cc
Variable &operator=(std::string const &str); // 2.cc
Variable &operator=(std::string &&tmp); // 3.cc
Variable &operator=(std::vector<std::string> &&tmp); // 4.cc
bool isTrue() const; // Int, String, List
bool isString() const; // Int, String, List
int value() const;
int &valueRef();
// force the interpretation as int
int forcedInt() const; // (used by d_reg when run() ends
std::string const &str() const;
std::vector<std::string> const &list() const;
Variable &operator+=(Variable const &rhs); // Int, String, List
Variable &operator-=(Variable const &rhs); // Int, List
std::string to_string() const; // convert an argument to
// a string
void swap(Variable &other);
};
#include "forcedint.f"
#include "isstring.f"
#include "istrue.f"
#include "list.f"
#include "str.f"
#include "tostring.f"
#include "value.f"
#include "valueref.f"
#include "opaddis.f"
#include "opequal.f"
#include "opinsert.f"
#include "opspaceship.f"
#include "opsubis.f"
#endif
|