summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-31 04:17:40 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-31 04:17:40 -0400
commit97a9b42b2c5ef908e0c47ecfd39771a79f8fa8a2 (patch)
tree8eadb82cc54e66353e05309fe42c2900b93628bf /src/item.cc
parenta2cb549b1dff9024e3f700203e424e496b25fd91 (diff)
parenta0a980b9f4ebf1493682ecf1eb745bf52649aac5 (diff)
downloadfork-ledger-97a9b42b2c5ef908e0c47ecfd39771a79f8fa8a2.tar.gz
fork-ledger-97a9b42b2c5ef908e0c47ecfd39771a79f8fa8a2.tar.bz2
fork-ledger-97a9b42b2c5ef908e0c47ecfd39771a79f8fa8a2.zip
Merge branch 'next'
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/item.cc b/src/item.cc
index 631423a9..debda7a3 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -32,6 +32,7 @@
#include <system.hh>
#include "item.h"
+#include "interactive.h"
namespace ledger {
@@ -210,15 +211,31 @@ namespace {
return item.has_tag(args[0].as_string());
else if (args[0].is_mask())
return item.has_tag(args[0].as_mask());
- } else {
- return item.has_tag(args[0].to_mask(), args[1].to_mask());
+ else
+ throw_(std::logic_error,
+ _("Expected string 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());
+ else
+ throw_(std::logic_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::logic_error, _("Too few arguments to function"));
+ }
+ else {
+ throw_(std::logic_error, _("Too many arguments to function"));
}
return false;
}
- value_t get_tag(call_scope_t& args) {
- item_t& item(find_scope<item_t>(args));
- if (optional<string> value = item.get_tag(args[0].as_string()))
+ value_t get_tag(call_scope_t& scope) {
+ in_context_t<item_t> env(scope, "s");
+ if (optional<string> value = env->get_tag(env.get<string>(0)))
return string_value(*value);
return false;
}