*** no comment ***

This commit is contained in:
John Wiegley 2007-05-13 09:27:26 +00:00
parent 994fb34699
commit 9044bf168a
20 changed files with 46 additions and 56 deletions

View file

@ -659,7 +659,7 @@ optional<amount_t> amount_t::value(const optional<moment_t>& moment) const
} else { } else {
throw_(amount_error, "Cannot determine value of an uninitialized amount"); throw_(amount_error, "Cannot determine value of an uninitialized amount");
} }
return optional<amount_t>(); return none;
} }

View file

@ -359,8 +359,7 @@ public:
} }
amount_t& in_place_unreduce(); amount_t& in_place_unreduce();
optional<amount_t> value(const optional<moment_t>& moment = optional<amount_t> value(const optional<moment_t>& moment = none) const;
optional<moment_t>()) const;
/** /**
* Truth tests. An amount may be truth test in several ways: * 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]) * annotate_commodity(amount_t price, [moment_t date, string tag])
* sets the annotations for the current amount's commodity. Only * sets the annotations for the current amount's commodity. Only
* the price argument is required, although it can be passed as * 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 * commodity_annotated() returns true if an amount's commodity has
* any annotation details associated with it. * any annotation details associated with it.

View file

@ -135,7 +135,7 @@ balance_t::amount(const optional<const commodity_t&>& commodity) const
if (i != amounts.end()) if (i != amounts.end())
return (*i).second; return (*i).second;
} }
return optional<amount_t>(); return none;
} }
optional<balance_t> optional<balance_t>

View file

@ -179,10 +179,9 @@ public:
return true; return true;
} }
optional<amount_t> amount(const optional<const commodity_t&>& commodity = optional<amount_t>
optional<const commodity_t&>()) const; amount(const optional<const commodity_t&>& commodity = none) const;
optional<balance_t> value(const optional<moment_t>& moment = optional<balance_t> value(const optional<moment_t>& moment = none) const;
optional<moment_t>()) const;
balance_t balance_t
strip_annotations(const bool keep_price = amount_t::keep_price, strip_annotations(const bool keep_price = amount_t::keep_price,

View file

@ -157,12 +157,11 @@ public:
return temp; return temp;
} }
optional<amount_t> amount(const optional<const commodity_t&>& commodity = optional<amount_t>
optional<const commodity_t&>()) const { amount(const optional<const commodity_t&>& commodity = none) const {
return quantity.amount(commodity); return quantity.amount(commodity);
} }
optional<balance_t> value(const optional<moment_t>& moment = optional<balance_t> value(const optional<moment_t>& moment = none) const {
optional<moment_t>()) const {
return quantity.value(moment); return quantity.value(moment);
} }
@ -179,7 +178,7 @@ public:
} }
balance_pair_t& add(const amount_t& amt, 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) if (a_cost && ! cost)
cost = quantity; cost = quantity;
quantity += amt; quantity += amt;

View file

@ -26,8 +26,7 @@ class builder_t
virtual void appendText(const string& text) = 0; virtual void appendText(const string& text) = 0;
virtual node_t * endNode(const optional<string>& name = virtual node_t * endNode(const optional<string>& name = none) = 0;
optional<string>()) = 0;
virtual node_t * endNode(const nameid_t name_id) = 0; virtual node_t * endNode(const nameid_t name_id) = 0;
}; };

View file

@ -99,7 +99,7 @@ optional<amount_t> commodity_t::value(const optional<moment_t>& moment)
age = (*i).first; age = (*i).first;
price = (*i).second; price = (*i).second;
} else { } else {
age = optional<moment_t>(); age = none;
} }
} else { } else {
price = (*i).second; price = (*i).second;
@ -307,9 +307,9 @@ annotated_commodity_t::strip_annotations(const bool _keep_price,
{ {
new_comm = parent().find_or_create new_comm = parent().find_or_create
(referent(), (referent(),
annotation_t(_keep_price ? details.price : optional<amount_t>(), annotation_t(_keep_price ? details.price : none,
_keep_date ? details.date : optional<moment_t>(), _keep_date ? details.date : none,
_keep_tag ? details.tag : optional<string>())); _keep_tag ? details.tag : none));
} else { } else {
new_comm = parent().find_or_create(base_symbol()); new_comm = parent().find_or_create(base_symbol());
} }

View file

@ -148,14 +148,14 @@ public:
optional<string> name() const { optional<string> name() const {
return base->name; return base->name;
} }
void set_name(const optional<string>& arg = optional<string>()) { void set_name(const optional<string>& arg = none) {
base->name = arg; base->name = arg;
} }
optional<string> note() const { optional<string> note() const {
return base->note; return base->note;
} }
void set_note(const optional<string>& arg = optional<string>()) { void set_note(const optional<string>& arg = none) {
base->note = arg; base->note = arg;
} }
@ -169,14 +169,14 @@ public:
optional<amount_t> smaller() const { optional<amount_t> smaller() const {
return base->smaller; 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; base->smaller = arg;
} }
optional<amount_t> larger() const { optional<amount_t> larger() const {
return base->larger; 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; base->larger = arg;
} }
@ -187,8 +187,7 @@ public:
void add_price(const moment_t& date, const amount_t& price); void add_price(const moment_t& date, const amount_t& price);
bool remove_price(const moment_t& date); bool remove_price(const moment_t& date);
optional<amount_t> value(const optional<moment_t>& moment = optional<amount_t> value(const optional<moment_t>& moment = none);
optional<moment_t>());
static void parse_symbol(std::istream& in, string& symbol); static void parse_symbol(std::istream& in, string& symbol);
static string parse_symbol(std::istream& in) { static string parse_symbol(std::istream& in) {
@ -220,9 +219,9 @@ struct annotation_t : public equality_comparable<annotation_t>
optional<string> tag; optional<string> tag;
explicit annotation_t explicit annotation_t
(const optional<amount_t>& _price = optional<amount_t>(), (const optional<amount_t>& _price = none,
const optional<moment_t>& _date = optional<moment_t>(), const optional<moment_t>& _date = none,
const optional<string>& _tag = optional<string>()) const optional<string>& _tag = none)
: price(_price), date(_date), tag(_tag) {} : price(_price), date(_date), tag(_tag) {}
operator bool() const { operator bool() const {
@ -354,8 +353,7 @@ public:
(commodity_t& commodity, (commodity_t& commodity,
const optional<moment_t>& date, const optional<moment_t>& date,
const optional<moment_t>& moment, const optional<moment_t>& moment,
const optional<moment_t>& last), const optional<moment_t>& last)> get_quote;
first_initialized<optional<amount_t> > > get_quote;
explicit commodity_pool_t(); explicit commodity_pool_t();

View file

@ -93,7 +93,7 @@ struct gnucash_parser_t : public parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, 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); amount_t convert_number(const string& number, int * precision = NULL);
}; };

View file

@ -94,10 +94,10 @@ class transaction_t : public supports_flags<>
data(NULL) { data(NULL) {
TRACE_CTOR(transaction_t, "account_t *"); TRACE_CTOR(transaction_t, "account_t *");
} }
explicit transaction_t(account_t * _account, explicit transaction_t(account_t * _account,
const amount_t& _amount, const amount_t& _amount,
unsigned int _flags = TRANSACTION_NORMAL, unsigned int _flags = TRANSACTION_NORMAL,
const optional<string> _note = optional<string>()) const optional<string> _note = none)
: supports_flags<>(_flags), : supports_flags<>(_flags),
entry(NULL), entry(NULL),
state(UNCLEARED), state(UNCLEARED),
@ -345,7 +345,7 @@ class account_t
account_t(account_t * _parent = NULL, account_t(account_t * _parent = NULL,
const string& _name = "", const string& _name = "",
const optional<string> _note = optional<string>()) const optional<string> _note = none)
: parent(_parent), name(_name), note(_note), : parent(_parent), name(_name), note(_note),
depth(parent ? parent->depth + 1 : 0), data(NULL), ident(0) { depth(parent ? parent->depth + 1 : 0), data(NULL), ident(0) {
TRACE_CTOR(account_t, "account_t *, const string&, const string&"); TRACE_CTOR(account_t, "account_t *, const string&, const string&");

View file

@ -44,7 +44,7 @@ class ofx_parser_t : public parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
}; };
} // namespace ledger } // namespace ledger

View file

@ -49,7 +49,7 @@ class parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()) = 0; const optional<path>& original = none) = 0;
}; };
DECLARE_EXCEPTION(parse_error); DECLARE_EXCEPTION(parse_error);

View file

@ -291,8 +291,7 @@ void export_journal()
; ;
class_< account_t > class_< account_t >
("Account", ("Account", init<optional<account_t *, string, string> >()
init<optional<account_t *, string, string> >()
[with_custodian_and_ward<1, 2>()]) [with_custodian_and_ward<1, 2>()])
.def(self == self) .def(self == self)
.def(self != self) .def(self != self)

View file

@ -44,7 +44,7 @@ class qif_parser_t : public parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
}; };
} // namespace ledger } // namespace ledger

View file

@ -60,7 +60,7 @@ quotes_by_script::operator()(commodity_t& commodity,
(last && (now - *last) < pricing_leeway) || (last && (now - *last) < pricing_leeway) ||
(moment && date && *moment > *date && (moment && date && *moment > *date &&
(*moment - *date) <= pricing_leeway)) (*moment - *date) <= pricing_leeway))
return optional<amount_t>(); return none;
DEBUG_("downloading quote for symbol " << commodity.symbol()); 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() << "Failed to download price for '" << commodity.symbol() <<
"' (command: \"getquote " << commodity.base_symbol() << "\")"); "' (command: \"getquote " << commodity.base_symbol() << "\")");
} }
return optional<amount_t>(); return none;
} }
} // namespace ledger } // namespace ledger

View file

@ -93,8 +93,7 @@ unsigned int session_t::read_journal(const path& pathname,
journal->sources.push_back(pathname); journal->sources.push_back(pathname);
if (! exists(pathname)) if (! exists(pathname))
throw filesystem_error(BOOST_CURRENT_FUNCTION, pathname, throw_(std::logic_error, "Cannot read file" << pathname);
"Cannot read file");
ifstream stream(pathname); ifstream stream(pathname);
return read_journal(stream, journal, master, return read_journal(stream, journal, master,
@ -107,8 +106,7 @@ void session_t::read_init()
return; return;
if (! exists(*init_file)) if (! exists(*init_file))
throw filesystem_error(BOOST_CURRENT_FUNCTION, *init_file, throw_(std::logic_error, "Cannot read init file" << *init_file);
"Cannot read init file");
ifstream init(*init_file); ifstream init(*init_file);

View file

@ -151,12 +151,12 @@ class session_t : public xml::xpath_t::scope_t
unsigned int read_journal(std::istream& in, unsigned int read_journal(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
unsigned int read_journal(const path& pathname, unsigned int read_journal(const path& pathname,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
void read_init(); void read_init();

View file

@ -44,7 +44,7 @@ class textual_parser_t : public parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
}; };
#if 0 #if 0

View file

@ -299,7 +299,7 @@ class value_t
bool operator<(const value_t& val) const; bool operator<(const value_t& val) const;
//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) { switch (the_type ? *the_type : type) {
case VOID: case VOID:
return "an uninitialized value"; return "an uninitialized value";
@ -362,9 +362,8 @@ class value_t
const bool keep_tag = amount_t::keep_tag) const; const bool keep_tag = amount_t::keep_tag) const;
value_t& add(const amount_t& amount, value_t& add(const amount_t& amount,
const optional<amount_t>& cost = optional<amount_t>()); const optional<amount_t>& cost = none);
value_t value(const optional<moment_t>& moment = value_t value(const optional<moment_t>& moment = none) const;
optional<moment_t>()) const;
void in_place_reduce(); void in_place_reduce();
value_t reduce() const { value_t reduce() const {

View file

@ -300,7 +300,7 @@ class xml_parser_t : public parser_t
virtual unsigned int parse(std::istream& in, virtual unsigned int parse(std::istream& in,
journal_t * journal, journal_t * journal,
account_t * master = NULL, account_t * master = NULL,
const optional<path>& original = optional<path>()); const optional<path>& original = none);
}; };
DECLARE_EXCEPTION(parse_error); DECLARE_EXCEPTION(parse_error);