diff options
author | John Wiegley <johnw@newartisans.com> | 2007-05-13 09:27:26 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:49 -0400 |
commit | 9044bf168ab0d8d6df03034898b1e5a4cb1559e8 (patch) | |
tree | cc5233bf5394f72b1b2cb7aa866cd8b67ff9d346 | |
parent | 994fb346993ddee2eaa4fb57eba2575636012b1a (diff) | |
download | fork-ledger-9044bf168ab0d8d6df03034898b1e5a4cb1559e8.tar.gz fork-ledger-9044bf168ab0d8d6df03034898b1e5a4cb1559e8.tar.bz2 fork-ledger-9044bf168ab0d8d6df03034898b1e5a4cb1559e8.zip |
*** no comment ***
-rw-r--r-- | src/amount.cc | 2 | ||||
-rw-r--r-- | src/amount.h | 5 | ||||
-rw-r--r-- | src/balance.cc | 2 | ||||
-rw-r--r-- | src/balance.h | 7 | ||||
-rw-r--r-- | src/balpair.h | 9 | ||||
-rw-r--r-- | src/builder.h | 3 | ||||
-rw-r--r-- | src/commodity.cc | 8 | ||||
-rw-r--r-- | src/commodity.h | 20 | ||||
-rw-r--r-- | src/gnucash.h | 2 | ||||
-rw-r--r-- | src/journal.h | 10 | ||||
-rw-r--r-- | src/ofx.h | 2 | ||||
-rw-r--r-- | src/parser.h | 2 | ||||
-rw-r--r-- | src/py_journal.cc | 3 | ||||
-rw-r--r-- | src/qif.h | 2 | ||||
-rw-r--r-- | src/quotes.cc | 4 | ||||
-rw-r--r-- | src/session.cc | 6 | ||||
-rw-r--r-- | src/session.h | 4 | ||||
-rw-r--r-- | src/textual.h | 2 | ||||
-rw-r--r-- | src/value.h | 7 | ||||
-rw-r--r-- | src/xml.h | 2 |
20 files changed, 46 insertions, 56 deletions
diff --git a/src/amount.cc b/src/amount.cc index 7f418ac3..187200c3 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -659,7 +659,7 @@ optional<amount_t> amount_t::value(const optional<moment_t>& moment) const } else { throw_(amount_error, "Cannot determine value of an uninitialized amount"); } - return optional<amount_t>(); + return none; } diff --git a/src/amount.h b/src/amount.h index 10659f1f..c11f539b 100644 --- a/src/amount.h +++ b/src/amount.h @@ -359,8 +359,7 @@ public: } amount_t& in_place_unreduce(); - optional<amount_t> value(const optional<moment_t>& moment = - optional<moment_t>()) const; + optional<amount_t> value(const optional<moment_t>& moment = none) const; /** * Truth tests. An amount may be truth test in several ways: @@ -502,7 +501,7 @@ public: * annotate_commodity(amount_t price, [moment_t date, string tag]) * sets the annotations for the current amount's commodity. Only * the price argument is required, although it can be passed as - * `optional<amount_t>()' if no price is desired. + * `none' if no price is desired. * * commodity_annotated() returns true if an amount's commodity has * any annotation details associated with it. diff --git a/src/balance.cc b/src/balance.cc index 6952b123..80ddd2e4 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -135,7 +135,7 @@ balance_t::amount(const optional<const commodity_t&>& commodity) const if (i != amounts.end()) return (*i).second; } - return optional<amount_t>(); + return none; } optional<balance_t> diff --git a/src/balance.h b/src/balance.h index 627c3ac6..e1fa9883 100644 --- a/src/balance.h +++ b/src/balance.h @@ -179,10 +179,9 @@ public: return true; } - optional<amount_t> amount(const optional<const commodity_t&>& commodity = - optional<const commodity_t&>()) const; - optional<balance_t> value(const optional<moment_t>& moment = - optional<moment_t>()) const; + optional<amount_t> + amount(const optional<const commodity_t&>& commodity = none) const; + optional<balance_t> value(const optional<moment_t>& moment = none) const; balance_t strip_annotations(const bool keep_price = amount_t::keep_price, diff --git a/src/balpair.h b/src/balpair.h index 358b74f4..c406394e 100644 --- a/src/balpair.h +++ b/src/balpair.h @@ -157,12 +157,11 @@ public: return temp; } - optional<amount_t> amount(const optional<const commodity_t&>& commodity = - optional<const commodity_t&>()) const { + optional<amount_t> + amount(const optional<const commodity_t&>& commodity = none) const { return quantity.amount(commodity); } - optional<balance_t> value(const optional<moment_t>& moment = - optional<moment_t>()) const { + optional<balance_t> value(const optional<moment_t>& moment = none) const { return quantity.value(moment); } @@ -179,7 +178,7 @@ public: } balance_pair_t& add(const amount_t& amt, - const optional<amount_t>& a_cost = optional<amount_t>()) { + const optional<amount_t>& a_cost = none) { if (a_cost && ! cost) cost = quantity; quantity += amt; diff --git a/src/builder.h b/src/builder.h index 00adf483..b5577ac1 100644 --- a/src/builder.h +++ b/src/builder.h @@ -26,8 +26,7 @@ class builder_t virtual void appendText(const string& text) = 0; - virtual node_t * endNode(const optional<string>& name = - optional<string>()) = 0; + virtual node_t * endNode(const optional<string>& name = none) = 0; virtual node_t * endNode(const nameid_t name_id) = 0; }; diff --git a/src/commodity.cc b/src/commodity.cc index 66c4a04c..b4302d67 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -99,7 +99,7 @@ optional<amount_t> commodity_t::value(const optional<moment_t>& moment) age = (*i).first; price = (*i).second; } else { - age = optional<moment_t>(); + age = none; } } else { price = (*i).second; @@ -307,9 +307,9 @@ annotated_commodity_t::strip_annotations(const bool _keep_price, { new_comm = parent().find_or_create (referent(), - annotation_t(_keep_price ? details.price : optional<amount_t>(), - _keep_date ? details.date : optional<moment_t>(), - _keep_tag ? details.tag : optional<string>())); + annotation_t(_keep_price ? details.price : none, + _keep_date ? details.date : none, + _keep_tag ? details.tag : none)); } else { new_comm = parent().find_or_create(base_symbol()); } diff --git a/src/commodity.h b/src/commodity.h index a5a13aeb..dbd6233f 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -148,14 +148,14 @@ public: optional<string> name() const { return base->name; } - void set_name(const optional<string>& arg = optional<string>()) { + void set_name(const optional<string>& arg = none) { base->name = arg; } optional<string> note() const { return base->note; } - void set_note(const optional<string>& arg = optional<string>()) { + void set_note(const optional<string>& arg = none) { base->note = arg; } @@ -169,14 +169,14 @@ public: optional<amount_t> smaller() const { return base->smaller; } - void set_smaller(const optional<amount_t>& arg = optional<amount_t>()) { + void set_smaller(const optional<amount_t>& arg = none) { base->smaller = arg; } optional<amount_t> larger() const { return base->larger; } - void set_larger(const optional<amount_t>& arg = optional<amount_t>()) { + void set_larger(const optional<amount_t>& arg = none) { base->larger = arg; } @@ -187,8 +187,7 @@ public: void add_price(const moment_t& date, const amount_t& price); bool remove_price(const moment_t& date); - optional<amount_t> value(const optional<moment_t>& moment = - optional<moment_t>()); + optional<amount_t> value(const optional<moment_t>& moment = none); static void parse_symbol(std::istream& in, string& symbol); static string parse_symbol(std::istream& in) { @@ -220,9 +219,9 @@ struct annotation_t : public equality_comparable<annotation_t> optional<string> tag; explicit annotation_t - (const optional<amount_t>& _price = optional<amount_t>(), - const optional<moment_t>& _date = optional<moment_t>(), - const optional<string>& _tag = optional<string>()) + (const optional<amount_t>& _price = none, + const optional<moment_t>& _date = none, + const optional<string>& _tag = none) : price(_price), date(_date), tag(_tag) {} operator bool() const { @@ -354,8 +353,7 @@ public: (commodity_t& commodity, const optional<moment_t>& date, const optional<moment_t>& moment, - const optional<moment_t>& last), - first_initialized<optional<amount_t> > > get_quote; + const optional<moment_t>& last)> get_quote; explicit commodity_pool_t(); diff --git a/src/gnucash.h b/src/gnucash.h index 087f18a3..ce46eec7 100644 --- a/src/gnucash.h +++ b/src/gnucash.h @@ -93,7 +93,7 @@ struct gnucash_parser_t : public parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); amount_t convert_number(const string& number, int * precision = NULL); }; diff --git a/src/journal.h b/src/journal.h index 04bb1d5d..51f13f42 100644 --- a/src/journal.h +++ b/src/journal.h @@ -94,10 +94,10 @@ class transaction_t : public supports_flags<> data(NULL) { TRACE_CTOR(transaction_t, "account_t *"); } - explicit transaction_t(account_t * _account, - const amount_t& _amount, - unsigned int _flags = TRANSACTION_NORMAL, - const optional<string> _note = optional<string>()) + explicit transaction_t(account_t * _account, + const amount_t& _amount, + unsigned int _flags = TRANSACTION_NORMAL, + const optional<string> _note = none) : supports_flags<>(_flags), entry(NULL), state(UNCLEARED), @@ -345,7 +345,7 @@ class account_t account_t(account_t * _parent = NULL, const string& _name = "", - const optional<string> _note = optional<string>()) + const optional<string> _note = none) : parent(_parent), name(_name), note(_note), depth(parent ? parent->depth + 1 : 0), data(NULL), ident(0) { TRACE_CTOR(account_t, "account_t *, const string&, const string&"); @@ -44,7 +44,7 @@ class ofx_parser_t : public parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); }; } // namespace ledger diff --git a/src/parser.h b/src/parser.h index fe1fe38b..8e9ccd4a 100644 --- a/src/parser.h +++ b/src/parser.h @@ -49,7 +49,7 @@ class parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()) = 0; + const optional<path>& original = none) = 0; }; DECLARE_EXCEPTION(parse_error); diff --git a/src/py_journal.cc b/src/py_journal.cc index 4c3f0fa3..e7cd600a 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -291,8 +291,7 @@ void export_journal() ; class_< account_t > - ("Account", - init<optional<account_t *, string, string> >() + ("Account", init<optional<account_t *, string, string> >() [with_custodian_and_ward<1, 2>()]) .def(self == self) .def(self != self) @@ -44,7 +44,7 @@ class qif_parser_t : public parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); }; } // namespace ledger diff --git a/src/quotes.cc b/src/quotes.cc index d5dbd4fe..07417800 100644 --- a/src/quotes.cc +++ b/src/quotes.cc @@ -60,7 +60,7 @@ quotes_by_script::operator()(commodity_t& commodity, (last && (now - *last) < pricing_leeway) || (moment && date && *moment > *date && (*moment - *date) <= pricing_leeway)) - return optional<amount_t>(); + return none; DEBUG_("downloading quote for symbol " << commodity.symbol()); @@ -111,7 +111,7 @@ quotes_by_script::operator()(commodity_t& commodity, "Failed to download price for '" << commodity.symbol() << "' (command: \"getquote " << commodity.base_symbol() << "\")"); } - return optional<amount_t>(); + return none; } } // namespace ledger diff --git a/src/session.cc b/src/session.cc index 3cd4e169..41591018 100644 --- a/src/session.cc +++ b/src/session.cc @@ -93,8 +93,7 @@ unsigned int session_t::read_journal(const path& pathname, journal->sources.push_back(pathname); if (! exists(pathname)) - throw filesystem_error(BOOST_CURRENT_FUNCTION, pathname, - "Cannot read file"); + throw_(std::logic_error, "Cannot read file" << pathname); ifstream stream(pathname); return read_journal(stream, journal, master, @@ -107,8 +106,7 @@ void session_t::read_init() return; if (! exists(*init_file)) - throw filesystem_error(BOOST_CURRENT_FUNCTION, *init_file, - "Cannot read init file"); + throw_(std::logic_error, "Cannot read init file" << *init_file); ifstream init(*init_file); diff --git a/src/session.h b/src/session.h index 8b72ae42..4027bc95 100644 --- a/src/session.h +++ b/src/session.h @@ -151,12 +151,12 @@ class session_t : public xml::xpath_t::scope_t unsigned int read_journal(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); unsigned int read_journal(const path& pathname, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); void read_init(); diff --git a/src/textual.h b/src/textual.h index 58f0f7a4..e569c81d 100644 --- a/src/textual.h +++ b/src/textual.h @@ -44,7 +44,7 @@ class textual_parser_t : public parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); }; #if 0 diff --git a/src/value.h b/src/value.h index 917f732f..f001a4aa 100644 --- a/src/value.h +++ b/src/value.h @@ -299,7 +299,7 @@ class value_t bool operator<(const value_t& val) const; //bool operator>(const value_t& val) const; - string label(optional<type_t> the_type = optional<type_t>()) const { + string label(optional<type_t> the_type = none) const { switch (the_type ? *the_type : type) { case VOID: return "an uninitialized value"; @@ -362,9 +362,8 @@ class value_t const bool keep_tag = amount_t::keep_tag) const; value_t& add(const amount_t& amount, - const optional<amount_t>& cost = optional<amount_t>()); - value_t value(const optional<moment_t>& moment = - optional<moment_t>()) const; + const optional<amount_t>& cost = none); + value_t value(const optional<moment_t>& moment = none) const; void in_place_reduce(); value_t reduce() const { @@ -300,7 +300,7 @@ class xml_parser_t : public parser_t virtual unsigned int parse(std::istream& in, journal_t * journal, account_t * master = NULL, - const optional<path>& original = optional<path>()); + const optional<path>& original = none); }; DECLARE_EXCEPTION(parse_error); |