| 1 |
#ifndef INCLUDED_INT_ |
| 2 |
#define INCLUDED_INT_ |
| 3 |
|
| 4 |
#include <ostream> |
| 5 |
|
| 6 |
#include <bobcat/a2x> |
| 7 |
|
| 8 |
#include "../base/base.h" |
| 9 |
|
| 10 |
class Int: public Base |
| 11 |
{ |
| 12 |
int d_value; |
| 13 |
|
| 14 |
public: |
| 15 |
Int(char const *text); |
| 16 |
Int(int v); |
| 17 |
int value() const; // directly access the value |
| 18 |
private: |
| 19 |
virtual Base *ownClone() const; |
| 20 |
virtual std::ostream &insert(std::ostream &os) const; |
| 21 |
}; |
| 22 |
|
| 23 |
inline Int::Int(char const *txt) |
| 24 |
: |
| 25 |
d_value(FBB::A2x(txt)) |
| 26 |
{} |
| 27 |
|
| 28 |
inline Int::Int(int v) |
| 29 |
: |
| 30 |
d_value(v) |
| 31 |
{} |
| 32 |
|
| 33 |
inline Base *Int::ownClone() const |
| 34 |
{ |
| 35 |
return new Int(*this); |
| 36 |
} |
| 37 |
|
| 38 |
inline int Int::value() const |
| 39 |
{ |
| 40 |
return d_value; |
| 41 |
} |
| 42 |
|
| 43 |
inline std::ostream &Int::insert(std::ostream &out) const |
| 44 |
{ |
| 45 |
return out << d_value; |
| 46 |
} |
| 47 |
|
| 48 |
#endif |