some fixes to value_t in python; still more work to go
This commit is contained in:
parent
6126d48e27
commit
a4c5380a7f
3 changed files with 29 additions and 3 deletions
|
|
@ -8,8 +8,11 @@ print x
|
||||||
y = Amount ("$1000.45")
|
y = Amount ("$1000.45")
|
||||||
print x + y
|
print x + y
|
||||||
|
|
||||||
z = Value ("$1000.45")
|
y = Amount ("$1000.45")
|
||||||
print y + z
|
print x * y
|
||||||
|
|
||||||
z += x
|
z = Value ("$1000.45")
|
||||||
|
#print z + Value(y)
|
||||||
|
|
||||||
|
z += Value(x)
|
||||||
print z
|
print z
|
||||||
|
|
|
||||||
2
value.cc
2
value.cc
|
|
@ -557,6 +557,8 @@ void export_value()
|
||||||
.def(init<balance_pair_t>())
|
.def(init<balance_pair_t>())
|
||||||
.def(init<balance_t>())
|
.def(init<balance_t>())
|
||||||
.def(init<amount_t>())
|
.def(init<amount_t>())
|
||||||
|
.def(init<std::string>())
|
||||||
|
.def(init<double>())
|
||||||
.def(init<unsigned int>())
|
.def(init<unsigned int>())
|
||||||
.def(init<bool>())
|
.def(init<bool>())
|
||||||
|
|
||||||
|
|
|
||||||
21
value.h
21
value.h
|
|
@ -46,6 +46,18 @@ class value_t
|
||||||
*((unsigned int *) data) = value;
|
*((unsigned int *) data) = value;
|
||||||
type = INTEGER;
|
type = INTEGER;
|
||||||
}
|
}
|
||||||
|
value_t(const double value) {
|
||||||
|
new((amount_t *) data) amount_t(value);
|
||||||
|
type = AMOUNT;
|
||||||
|
}
|
||||||
|
value_t(const std::string& value) {
|
||||||
|
new((amount_t *) data) amount_t(value);
|
||||||
|
type = AMOUNT;
|
||||||
|
}
|
||||||
|
value_t(const char * value) {
|
||||||
|
new((amount_t *) data) amount_t(value);
|
||||||
|
type = AMOUNT;
|
||||||
|
}
|
||||||
value_t(const amount_t& value) {
|
value_t(const amount_t& value) {
|
||||||
new((amount_t *)data) amount_t(value);
|
new((amount_t *)data) amount_t(value);
|
||||||
type = AMOUNT;
|
type = AMOUNT;
|
||||||
|
|
@ -80,6 +92,15 @@ class value_t
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
value_t& operator=(const double value) {
|
||||||
|
return *this = amount_t(value);
|
||||||
|
}
|
||||||
|
value_t& operator=(const std::string& value) {
|
||||||
|
return *this = amount_t(value);
|
||||||
|
}
|
||||||
|
value_t& operator=(const char * value) {
|
||||||
|
return *this = amount_t(value);
|
||||||
|
}
|
||||||
value_t& operator=(const amount_t& value) {
|
value_t& operator=(const amount_t& value) {
|
||||||
if ((amount_t *) data != &value) {
|
if ((amount_t *) data != &value) {
|
||||||
if (! value) {
|
if (! value) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue