summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-03-04 04:29:10 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-03-04 04:29:10 -0400
commit2d63c9364af57c732003afc7adddeb8ce62a1988 (patch)
tree8b5ac531fdebe6e25c77b6fefc41b3d0bfec58a9
parentdcac3064670e6b4f4b8759d9adf54e8569ec4786 (diff)
downloadfork-ledger-2d63c9364af57c732003afc7adddeb8ce62a1988.tar.gz
fork-ledger-2d63c9364af57c732003afc7adddeb8ce62a1988.tar.bz2
fork-ledger-2d63c9364af57c732003afc7adddeb8ce62a1988.zip
Changed many assert() calls to VERIFY()
-rw-r--r--src/amount.cc12
-rw-r--r--src/op.h4
-rw-r--r--src/textual.cc4
-rw-r--r--src/timelog.cc2
-rw-r--r--src/unistring.h2
-rw-r--r--src/value.cc3
-rw-r--r--src/value.h74
-rw-r--r--src/xact.cc2
8 files changed, 49 insertions, 54 deletions
diff --git a/src/amount.cc b/src/amount.cc
index f6b3edfb..3a1fd0ad 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -129,7 +129,7 @@ void amount_t::shutdown()
void amount_t::_copy(const amount_t& amt)
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (quantity != amt.quantity) {
if (quantity)
@@ -231,7 +231,7 @@ amount_t& amount_t::operator=(const amount_t& amt)
int amount_t::compare(const amount_t& amt) const
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (! quantity || ! amt.quantity) {
if (quantity)
@@ -266,7 +266,7 @@ bool amount_t::operator==(const amount_t& amt) const
amount_t& amount_t::operator+=(const amount_t& amt)
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (! quantity || ! amt.quantity) {
if (quantity)
@@ -297,7 +297,7 @@ amount_t& amount_t::operator+=(const amount_t& amt)
amount_t& amount_t::operator-=(const amount_t& amt)
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (! quantity || ! amt.quantity) {
if (quantity)
@@ -328,7 +328,7 @@ amount_t& amount_t::operator-=(const amount_t& amt)
amount_t& amount_t::operator*=(const amount_t& amt)
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (! quantity || ! amt.quantity) {
if (quantity)
@@ -359,7 +359,7 @@ amount_t& amount_t::operator*=(const amount_t& amt)
amount_t& amount_t::operator/=(const amount_t& amt)
{
- assert(amt.valid());
+ VERIFY(amt.valid());
if (! quantity || ! amt.quantity) {
if (quantity)
diff --git a/src/op.h b/src/op.h
index 2960c297..1f9af185 100644
--- a/src/op.h
+++ b/src/op.h
@@ -148,14 +148,14 @@ public:
value_t& as_value_lval() {
assert(is_value());
value_t& val(boost::get<value_t>(data));
- assert(val.valid());
+ VERIFY(val.valid());
return val;
}
const value_t& as_value() const {
return const_cast<op_t *>(this)->as_value_lval();
}
void set_value(const value_t& val) {
- assert(val.valid());
+ VERIFY(val.valid());
data = val;
}
diff --git a/src/textual.cc b/src/textual.cc
index 20dbda96..bb30309c 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -430,7 +430,7 @@ void instance_t::clock_out_directive(char * line,
void instance_t::default_commodity_directive(char * line)
{
amount_t amt(skip_ws(line + 1));
- assert(amt.valid());
+ VERIFY(amt.valid());
amount_t::current_pool->default_commodity = &amt.commodity();
amt.commodity().add_flags(COMMODITY_KNOWN);
}
@@ -494,7 +494,7 @@ void instance_t::price_xact_directive(char * line)
string symbol;
parse_symbol(symbol_and_price, symbol);
amount_t price(symbol_and_price);
- assert(price.valid());
+ VERIFY(price.valid());
if (commodity_t * commodity =
amount_t::current_pool->find_or_create(symbol)) {
diff --git a/src/timelog.cc b/src/timelog.cc
index 3fe4a6d1..68e1ab79 100644
--- a/src/timelog.cc
+++ b/src/timelog.cc
@@ -89,7 +89,7 @@ namespace {
std::sprintf(buf, "%lds", long((when - event.checkin).total_seconds()));
amount_t amt;
amt.parse(buf);
- assert(amt.valid());
+ VERIFY(amt.valid());
post_t * post = new post_t(event.account, amt, POST_VIRTUAL);
post->set_state(item_t::CLEARED);
diff --git a/src/unistring.h b/src/unistring.h
index cadf82fe..74f17181 100644
--- a/src/unistring.h
+++ b/src/unistring.h
@@ -70,7 +70,7 @@ public:
const char * p = input.c_str();
std::size_t len = input.length();
- assert(utf8::is_valid(p, p + len));
+ VERIFY(utf8::is_valid(p, p + len));
utf8::utf8to32(p, p + len, std::back_inserter(utf32chars));
}
~unistring() {
diff --git a/src/value.cc b/src/value.cc
index 87c7ecd1..c47a4f6e 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -120,21 +120,18 @@ value_t::operator bool() const
void value_t::set_type(type_t new_type)
{
- assert(new_type >= VOID && new_type <= POINTER);
if (new_type == VOID) {
#if BOOST_VERSION >= 103700
storage.reset();
#else
storage = intrusive_ptr<storage_t>();
#endif
- assert(is_null());
} else {
if (! storage || storage->refc > 1)
storage = new storage_t;
else
storage->destroy();
storage->type = new_type;
- assert(is_type(new_type));
}
}
diff --git a/src/value.h b/src/value.h
index 35d7f6a8..bd25c7a7 100644
--- a/src/value.h
+++ b/src/value.h
@@ -166,7 +166,7 @@ private:
*/
~storage_t() {
TRACE_DTOR(value_t::storage_t);
- assert(refc == 0);
+ VERIFY(refc == 0);
destroy();
}
@@ -190,13 +190,13 @@ private:
void acquire() const {
DEBUG("value.storage.refcount",
"Acquiring " << this << ", refc now " << refc + 1);
- assert(refc >= 0);
+ VERIFY(refc >= 0);
refc++;
}
void release() const {
DEBUG("value.storage.refcount",
"Releasing " << this << ", refc now " << refc - 1);
- assert(refc > 0);
+ VERIFY(refc > 0);
if (--refc == 0)
checked_delete(this);
}
@@ -235,7 +235,7 @@ private:
* subsequently be modified.
*/
void _dup() {
- assert(storage);
+ VERIFY(storage);
if (storage->refc > 1)
storage = new storage_t(*storage.get());
}
@@ -462,18 +462,16 @@ public:
bool is_zero() const;
bool is_null() const {
if (! storage) {
- assert(is_type(VOID));
+ VERIFY(is_type(VOID));
return true;
} else {
- assert(! is_type(VOID));
+ VERIFY(! is_type(VOID));
return false;
}
}
type_t type() const {
- type_t result = storage ? storage->type : VOID;
- assert(result >= VOID && result <= POINTER);
- return result;
+ return storage ? storage->type : VOID;
}
bool is_type(type_t _type) const {
return type() == _type;
@@ -516,12 +514,12 @@ public:
return is_type(BOOLEAN);
}
bool& as_boolean_lval() {
- assert(is_boolean());
+ VERIFY(is_boolean());
_dup();
return boost::get<bool>(storage->data);
}
const bool& as_boolean() const {
- assert(is_boolean());
+ VERIFY(is_boolean());
return boost::get<bool>(storage->data);
}
void set_boolean(const bool val) {
@@ -533,12 +531,12 @@ public:
return is_type(DATETIME);
}
datetime_t& as_datetime_lval() {
- assert(is_datetime());
+ VERIFY(is_datetime());
_dup();
return boost::get<datetime_t>(storage->data);
}
const datetime_t& as_datetime() const {
- assert(is_datetime());
+ VERIFY(is_datetime());
return boost::get<datetime_t>(storage->data);
}
void set_datetime(const datetime_t& val) {
@@ -550,12 +548,12 @@ public:
return is_type(DATE);
}
date_t& as_date_lval() {
- assert(is_date());
+ VERIFY(is_date());
_dup();
return boost::get<date_t>(storage->data);
}
const date_t& as_date() const {
- assert(is_date());
+ VERIFY(is_date());
return boost::get<date_t>(storage->data);
}
void set_date(const date_t& val) {
@@ -567,12 +565,12 @@ public:
return is_type(INTEGER);
}
long& as_long_lval() {
- assert(is_long());
+ VERIFY(is_long());
_dup();
return boost::get<long>(storage->data);
}
const long& as_long() const {
- assert(is_long());
+ VERIFY(is_long());
return boost::get<long>(storage->data);
}
void set_long(const long val) {
@@ -584,16 +582,16 @@ public:
return is_type(AMOUNT);
}
amount_t& as_amount_lval() {
- assert(is_amount());
+ VERIFY(is_amount());
_dup();
return boost::get<amount_t>(storage->data);
}
const amount_t& as_amount() const {
- assert(is_amount());
+ VERIFY(is_amount());
return boost::get<amount_t>(storage->data);
}
void set_amount(const amount_t& val) {
- assert(val.valid());
+ VERIFY(val.valid());
set_type(AMOUNT);
storage->data = val;
}
@@ -602,16 +600,16 @@ public:
return is_type(BALANCE);
}
balance_t& as_balance_lval() {
- assert(is_balance());
+ VERIFY(is_balance());
_dup();
return *boost::get<balance_t *>(storage->data);
}
const balance_t& as_balance() const {
- assert(is_balance());
+ VERIFY(is_balance());
return *boost::get<balance_t *>(storage->data);
}
void set_balance(const balance_t& val) {
- assert(val.valid());
+ VERIFY(val.valid());
set_type(BALANCE);
storage->data = new balance_t(val);
}
@@ -620,12 +618,12 @@ public:
return is_type(STRING);
}
string& as_string_lval() {
- assert(is_string());
+ VERIFY(is_string());
_dup();
return boost::get<string>(storage->data);
}
const string& as_string() const {
- assert(is_string());
+ VERIFY(is_string());
return boost::get<string>(storage->data);
}
void set_string(const string& val = "") {
@@ -641,13 +639,13 @@ public:
return is_type(MASK);
}
mask_t& as_mask_lval() {
- assert(is_mask());
+ VERIFY(is_mask());
_dup();
VERIFY(boost::get<mask_t>(storage->data).valid());
return boost::get<mask_t>(storage->data);
}
const mask_t& as_mask() const {
- assert(is_mask());
+ VERIFY(is_mask());
VERIFY(boost::get<mask_t>(storage->data).valid());
return boost::get<mask_t>(storage->data);
}
@@ -664,12 +662,12 @@ public:
return is_type(SEQUENCE);
}
sequence_t& as_sequence_lval() {
- assert(is_sequence());
+ VERIFY(is_sequence());
_dup();
return *boost::get<sequence_t *>(storage->data);
}
const sequence_t& as_sequence() const {
- assert(is_sequence());
+ VERIFY(is_sequence());
return *boost::get<sequence_t *>(storage->data);
}
void set_sequence(const sequence_t& val) {
@@ -689,7 +687,7 @@ public:
return is_type(POINTER);
}
boost::any& as_any_pointer_lval() {
- assert(is_pointer());
+ VERIFY(is_pointer());
_dup();
return boost::get<boost::any>(storage->data);
}
@@ -702,7 +700,7 @@ public:
return *as_pointer_lval<T>();
}
const boost::any& as_any_pointer() const {
- assert(is_pointer());
+ VERIFY(is_pointer());
return boost::get<boost::any>(storage->data);
}
template <typename T>
@@ -785,7 +783,7 @@ public:
* Collection-style access methods for SEQUENCE values.
*/
value_t& operator[](const int index) {
- assert(! is_null());
+ VERIFY(! is_null());
if (is_sequence())
return as_sequence_lval()[index];
else if (index == 0)
@@ -796,7 +794,7 @@ public:
return null;
}
const value_t& operator[](const int index) const {
- assert(! is_null());
+ VERIFY(! is_null());
if (is_sequence())
return as_sequence()[index];
else if (index == 0)
@@ -818,7 +816,7 @@ public:
}
void pop_back() {
- assert(! is_null());
+ VERIFY(! is_null());
if (! is_sequence()) {
#if BOOST_VERSION >= 103700
@@ -845,24 +843,24 @@ public:
}
sequence_t::iterator begin() {
- assert(is_sequence());
+ VERIFY(is_sequence());
return as_sequence_lval().begin();
}
sequence_t::iterator end() {
- assert(is_sequence());
+ VERIFY(is_sequence());
// This special hack is because we never used end() in a context which
// needs us to call _dup().
return boost::get<sequence_t *>(storage->data)->end();
}
sequence_t::const_iterator begin() const {
- assert(is_sequence());
+ VERIFY(is_sequence());
return as_sequence().begin();
}
sequence_t::const_iterator end() const {
- assert(is_sequence());
+ VERIFY(is_sequence());
return as_sequence().end();
}
diff --git a/src/xact.cc b/src/xact.cc
index 8b834f53..5013ec15 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -112,7 +112,7 @@ bool xact_base_t::finalize()
null_post = post;
}
}
- assert(balance.valid());
+ VERIFY(balance.valid());
#if defined(DEBUG_ON)
DEBUG("xact.finalize", "initial balance = " << balance);