summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-11 16:03:50 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-11 17:02:25 -0400
commitdea2aed0b509734ec4e1cd163ac2a4f013000da2 (patch)
tree7908da76c67ae5172882306a319bf26df81b73b4 /src/item.cc
parentd580079df892c30d023b3211d6c4611c17b11f8f (diff)
downloadfork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.gz
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.bz2
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.zip
Untabified all source files
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/item.cc b/src/item.cc
index 6a948ae4..8a056e6c 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -58,15 +58,15 @@ bool item_t::has_tag(const string& tag) const
}
bool item_t::has_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {
if (tag_mask.match(data.first)) {
- if (! value_mask)
- return true;
- else if (data.second.first)
- return value_mask->match(*data.second.first);
+ if (! value_mask)
+ return true;
+ else if (data.second.first)
+ return value_mask->match(*data.second.first);
}
}
}
@@ -88,14 +88,14 @@ optional<string> item_t::get_tag(const string& tag) const
}
optional<string> item_t::get_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {
if (tag_mask.match(data.first) &&
- (! value_mask ||
- (data.second.first && value_mask->match(*data.second.first))))
- return data.second.first;
+ (! value_mask ||
+ (data.second.first && value_mask->match(*data.second.first))))
+ return data.second.first;
}
}
return none;
@@ -103,8 +103,8 @@ optional<string> item_t::get_tag(const mask_t& tag_mask,
item_t::string_map::iterator
item_t::set_tag(const string& tag,
- const optional<string>& value,
- const bool overwrite_existing)
+ const optional<string>& value,
+ const bool overwrite_existing)
{
assert(! tag.empty());
@@ -112,7 +112,7 @@ item_t::set_tag(const string& tag,
metadata = string_map();
DEBUG("item.meta", "Setting tag '" << tag << "' to value '"
- << (value ? *value : string("<none>")) << "'");
+ << (value ? *value : string("<none>")) << "'");
optional<string> data = value;
if (data && data->empty())
@@ -132,22 +132,22 @@ item_t::set_tag(const string& tag,
}
void item_t::parse_tags(const char * p, bool overwrite_existing,
- optional<date_t::year_type> current_year)
+ optional<date_t::year_type> current_year)
{
if (const char * b = std::strchr(p, '[')) {
if (*(b + 1) != '\0' &&
- (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
+ (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
if (const char * e = std::strchr(p, ']')) {
- char buf[256];
- std::strncpy(buf, b + 1, e - b - 1);
- buf[e - b - 1] = '\0';
-
- if (char * p = std::strchr(buf, '=')) {
- *p++ = '\0';
- _date_eff = parse_date(p, current_year);
- }
- if (buf[0])
- _date = parse_date(buf, current_year);
+ char buf[256];
+ std::strncpy(buf, b + 1, e - b - 1);
+ buf[e - b - 1] = '\0';
+
+ if (char * p = std::strchr(buf, '=')) {
+ *p++ = '\0';
+ _date_eff = parse_date(p, current_year);
+ }
+ if (buf[0])
+ _date = parse_date(buf, current_year);
}
}
}
@@ -166,16 +166,16 @@ void item_t::parse_tags(const char * p, bool overwrite_existing,
const string::size_type len = std::strlen(q);
if (! tag.empty()) {
string_map::iterator i = set_tag(tag, string(p + (q - buf.get())),
- overwrite_existing);
+ overwrite_existing);
(*i).second.second = true;
break;
}
else if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
for (char * r = std::strtok(q + 1, ":");
- r;
- r = std::strtok(NULL, ":")) {
- string_map::iterator i = set_tag(r, none, overwrite_existing);
- (*i).second.second = true;
+ r;
+ r = std::strtok(NULL, ":")) {
+ string_map::iterator i = set_tag(r, none, overwrite_existing);
+ (*i).second.second = true;
}
}
else if (q[len - 1] == ':') { // a metadata setting
@@ -185,7 +185,7 @@ void item_t::parse_tags(const char * p, bool overwrite_existing,
}
void item_t::append_note(const char * p, bool overwrite_existing,
- optional<date_t::year_type> current_year)
+ optional<date_t::year_type> current_year)
{
if (note) {
*note += '\n';
@@ -235,21 +235,21 @@ namespace {
if (args.size() == 1) {
if (args[0].is_string())
- return item.has_tag(args[0].as_string());
+ return item.has_tag(args[0].as_string());
else if (args[0].is_mask())
- return item.has_tag(args[0].as_mask());
+ return item.has_tag(args[0].as_mask());
else
- throw_(std::runtime_error,
- _("Expected string or mask for argument 1, but received %1")
- << args[0].label());
+ throw_(std::runtime_error,
+ _("Expected string or mask for argument 1, but received %1")
+ << args[0].label());
}
else if (args.size() == 2) {
if (args[0].is_mask() && args[1].is_mask())
- return item.has_tag(args[0].to_mask(), args[1].to_mask());
+ return item.has_tag(args[0].to_mask(), args[1].to_mask());
else
- throw_(std::runtime_error,
- _("Expected masks for arguments 1 and 2, but received %1 and %2")
- << args[0].label() << args[1].label());
+ throw_(std::runtime_error,
+ _("Expected masks for arguments 1 and 2, but received %1 and %2")
+ << args[0].label() << args[1].label());
}
else if (args.size() == 0) {
throw_(std::runtime_error, _("Too few arguments to function"));
@@ -267,21 +267,21 @@ namespace {
if (args.size() == 1) {
if (args[0].is_string())
- str = item.get_tag(args[0].as_string());
+ str = item.get_tag(args[0].as_string());
else if (args[0].is_mask())
- str = item.get_tag(args[0].as_mask());
+ str = item.get_tag(args[0].as_mask());
else
- throw_(std::runtime_error,
- _("Expected string or mask for argument 1, but received %1")
- << args[0].label());
+ throw_(std::runtime_error,
+ _("Expected string or mask for argument 1, but received %1")
+ << args[0].label());
}
else if (args.size() == 2) {
if (args[0].is_mask() && args[1].is_mask())
- str = item.get_tag(args[0].to_mask(), args[1].to_mask());
+ str = item.get_tag(args[0].to_mask(), args[1].to_mask());
else
- throw_(std::runtime_error,
- _("Expected masks for arguments 1 and 2, but received %1 and %2")
- << args[0].label() << args[1].label());
+ throw_(std::runtime_error,
+ _("Expected masks for arguments 1 and 2, but received %1 and %2")
+ << args[0].label() << args[1].label());
}
else if (args.size() == 0) {
throw_(std::runtime_error, _("Too few arguments to function"));
@@ -355,13 +355,13 @@ value_t get_comment(item_t& item)
bool need_separator = false;
for (const char * p = item.note->c_str(); *p; p++) {
if (*p == '\n') {
- need_separator = true;
+ need_separator = true;
} else {
- if (need_separator) {
- buf << "\n ;";
- need_separator = false;
- }
- buf << *p;
+ if (need_separator) {
+ buf << "\n ;";
+ need_separator = false;
+ }
+ buf << *p;
}
}
return string_value(buf.str());
@@ -369,7 +369,7 @@ value_t get_comment(item_t& item)
}
expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return NULL;
@@ -502,7 +502,7 @@ bool item_t::valid() const
void print_item(std::ostream& out, const item_t& item, const string& prefix)
{
out << source_context(item.pos->pathname, item.pos->beg_pos,
- item.pos->end_pos, prefix);
+ item.pos->end_pos, prefix);
}
string item_context(const item_t& item, const string& desc)
@@ -528,7 +528,7 @@ string item_context(const item_t& item, const string& desc)
if (item.pos->beg_line != item.pos->end_line)
out << _(", lines ") << item.pos->beg_line << "-"
- << item.pos->end_line << ":\n";
+ << item.pos->end_line << ":\n";
else
out << _(", line ") << item.pos->beg_line << ":\n";