Added a "seq" sequence property for all items
This indicates the absolute parsing order of every transaction and posting. It is 0 for generated items.
This commit is contained in:
parent
c92a54b0ab
commit
b78e22d52b
3 changed files with 39 additions and 20 deletions
|
|
@ -296,6 +296,10 @@ namespace {
|
||||||
return item.pos ? long(item.pos->end_line) : 0L;
|
return item.pos ? long(item.pos->end_line) : 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_t get_seq(item_t& item) {
|
||||||
|
return item.pos ? long(item.pos->sequence) : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
value_t get_depth(item_t&) {
|
value_t get_depth(item_t&) {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
@ -416,6 +420,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
|
||||||
case 's':
|
case 's':
|
||||||
if (name == "status")
|
if (name == "status")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_status>);
|
return WRAP_FUNCTOR(get_wrapper<&get_status>);
|
||||||
|
else if (name == "seq")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_seq>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,10 @@ struct position_t
|
||||||
std::size_t beg_line;
|
std::size_t beg_line;
|
||||||
istream_pos_type end_pos;
|
istream_pos_type end_pos;
|
||||||
std::size_t end_line;
|
std::size_t end_line;
|
||||||
|
std::size_t sequence;
|
||||||
|
|
||||||
position_t() : beg_pos(0), beg_line(0), end_pos(0), end_line(0) {
|
position_t()
|
||||||
|
: beg_pos(0), beg_line(0), end_pos(0), end_line(0), sequence(0) {
|
||||||
TRACE_CTOR(position_t, "");
|
TRACE_CTOR(position_t, "");
|
||||||
}
|
}
|
||||||
position_t(const position_t& pos) {
|
position_t(const position_t& pos) {
|
||||||
|
|
@ -72,6 +74,7 @@ struct position_t
|
||||||
beg_line = pos.beg_line;
|
beg_line = pos.beg_line;
|
||||||
end_pos = pos.end_pos;
|
end_pos = pos.end_pos;
|
||||||
end_line = pos.end_line;
|
end_line = pos.end_line;
|
||||||
|
sequence = pos.sequence;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -89,6 +92,7 @@ private:
|
||||||
ar & beg_line;
|
ar & beg_line;
|
||||||
ar & end_pos;
|
ar & end_pos;
|
||||||
ar & end_line;
|
ar & end_line;
|
||||||
|
ar & sequence;
|
||||||
}
|
}
|
||||||
#endif // HAVE_BOOST_SERIALIZATION
|
#endif // HAVE_BOOST_SERIALIZATION
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ namespace {
|
||||||
istream_pos_type curr_pos;
|
istream_pos_type curr_pos;
|
||||||
std::size_t count;
|
std::size_t count;
|
||||||
std::size_t errors;
|
std::size_t errors;
|
||||||
|
std::size_t * global_sequence;
|
||||||
|
|
||||||
optional<date_t::year_type> current_year;
|
optional<date_t::year_type> current_year;
|
||||||
|
|
||||||
|
|
@ -87,6 +88,7 @@ namespace {
|
||||||
std::istream& _in,
|
std::istream& _in,
|
||||||
scope_t& _scope,
|
scope_t& _scope,
|
||||||
journal_t& _journal,
|
journal_t& _journal,
|
||||||
|
std::size_t * _global_sequence = NULL,
|
||||||
account_t * _master = NULL,
|
account_t * _master = NULL,
|
||||||
const path * _original_file = NULL,
|
const path * _original_file = NULL,
|
||||||
bool _strict = false,
|
bool _strict = false,
|
||||||
|
|
@ -213,6 +215,7 @@ instance_t::instance_t(std::list<state_t>& _state_stack,
|
||||||
std::istream& _in,
|
std::istream& _in,
|
||||||
scope_t& _scope,
|
scope_t& _scope,
|
||||||
journal_t& _journal,
|
journal_t& _journal,
|
||||||
|
std::size_t * _global_sequence,
|
||||||
account_t * _master,
|
account_t * _master,
|
||||||
const path * _original_file,
|
const path * _original_file,
|
||||||
bool _strict,
|
bool _strict,
|
||||||
|
|
@ -223,7 +226,8 @@ instance_t::instance_t(std::list<state_t>& _state_stack,
|
||||||
#endif
|
#endif
|
||||||
parent(_parent), in(_in), scope(_scope),
|
parent(_parent), in(_in), scope(_scope),
|
||||||
journal(_journal), master(_master),
|
journal(_journal), master(_master),
|
||||||
original_file(_original_file), strict(_strict)
|
original_file(_original_file), strict(_strict),
|
||||||
|
global_sequence(_global_sequence)
|
||||||
{
|
{
|
||||||
TRACE_CTOR(instance_t, "...");
|
TRACE_CTOR(instance_t, "...");
|
||||||
|
|
||||||
|
|
@ -452,6 +456,7 @@ void instance_t::clock_in_directive(char * line,
|
||||||
position.beg_line = linenum;
|
position.beg_line = linenum;
|
||||||
position.end_pos = curr_pos;
|
position.end_pos = curr_pos;
|
||||||
position.end_line = linenum;
|
position.end_line = linenum;
|
||||||
|
position.sequence = (*global_sequence)++;
|
||||||
|
|
||||||
time_xact_t event(position, parse_datetime(datetime, current_year),
|
time_xact_t event(position, parse_datetime(datetime, current_year),
|
||||||
p ? top_account()->find_account(p) : NULL,
|
p ? top_account()->find_account(p) : NULL,
|
||||||
|
|
@ -481,6 +486,7 @@ void instance_t::clock_out_directive(char * line,
|
||||||
position.beg_line = linenum;
|
position.beg_line = linenum;
|
||||||
position.end_pos = curr_pos;
|
position.end_pos = curr_pos;
|
||||||
position.end_line = linenum;
|
position.end_line = linenum;
|
||||||
|
position.sequence = (*global_sequence)++;
|
||||||
|
|
||||||
time_xact_t event(position, parse_datetime(datetime, current_year),
|
time_xact_t event(position, parse_datetime(datetime, current_year),
|
||||||
p ? top_account()->find_account(p) : NULL,
|
p ? top_account()->find_account(p) : NULL,
|
||||||
|
|
@ -555,7 +561,6 @@ void instance_t::option_directive(char * line)
|
||||||
void instance_t::automated_xact_directive(char * line)
|
void instance_t::automated_xact_directive(char * line)
|
||||||
{
|
{
|
||||||
istream_pos_type pos= line_beg_pos;
|
istream_pos_type pos= line_beg_pos;
|
||||||
std::size_t lnum = linenum;
|
|
||||||
|
|
||||||
bool reveal_context = true;
|
bool reveal_context = true;
|
||||||
|
|
||||||
|
|
@ -564,6 +569,11 @@ void instance_t::automated_xact_directive(char * line)
|
||||||
std::auto_ptr<auto_xact_t> ae
|
std::auto_ptr<auto_xact_t> ae
|
||||||
(new auto_xact_t(query_t(string(skip_ws(line + 1)),
|
(new auto_xact_t(query_t(string(skip_ws(line + 1)),
|
||||||
keep_details_t(true, true, true))));
|
keep_details_t(true, true, true))));
|
||||||
|
ae->pos = position_t();
|
||||||
|
ae->pos->pathname = pathname;
|
||||||
|
ae->pos->beg_pos = line_beg_pos;
|
||||||
|
ae->pos->beg_line = linenum;
|
||||||
|
ae->pos->sequence = (*global_sequence)++;
|
||||||
|
|
||||||
reveal_context = false;
|
reveal_context = false;
|
||||||
|
|
||||||
|
|
@ -573,10 +583,6 @@ void instance_t::automated_xact_directive(char * line)
|
||||||
journal.auto_xacts.push_back(ae.get());
|
journal.auto_xacts.push_back(ae.get());
|
||||||
|
|
||||||
ae->journal = &journal;
|
ae->journal = &journal;
|
||||||
ae->pos = position_t();
|
|
||||||
ae->pos->pathname = pathname;
|
|
||||||
ae->pos->beg_pos = pos;
|
|
||||||
ae->pos->beg_line = lnum;
|
|
||||||
ae->pos->end_pos = curr_pos;
|
ae->pos->end_pos = curr_pos;
|
||||||
ae->pos->end_line = linenum;
|
ae->pos->end_line = linenum;
|
||||||
|
|
||||||
|
|
@ -596,13 +602,17 @@ void instance_t::automated_xact_directive(char * line)
|
||||||
void instance_t::period_xact_directive(char * line)
|
void instance_t::period_xact_directive(char * line)
|
||||||
{
|
{
|
||||||
istream_pos_type pos = line_beg_pos;
|
istream_pos_type pos = line_beg_pos;
|
||||||
std::size_t lnum = linenum;
|
|
||||||
|
|
||||||
bool reveal_context = true;
|
bool reveal_context = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::auto_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1)));
|
std::auto_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1)));
|
||||||
|
pe->pos = position_t();
|
||||||
|
pe->pos->pathname = pathname;
|
||||||
|
pe->pos->beg_pos = line_beg_pos;
|
||||||
|
pe->pos->beg_line = linenum;
|
||||||
|
pe->pos->sequence = (*global_sequence)++;
|
||||||
|
|
||||||
reveal_context = false;
|
reveal_context = false;
|
||||||
|
|
||||||
|
|
@ -614,10 +624,6 @@ void instance_t::period_xact_directive(char * line)
|
||||||
journal.extend_xact(pe.get());
|
journal.extend_xact(pe.get());
|
||||||
journal.period_xacts.push_back(pe.get());
|
journal.period_xacts.push_back(pe.get());
|
||||||
|
|
||||||
pe->pos = position_t();
|
|
||||||
pe->pos->pathname = pathname;
|
|
||||||
pe->pos->beg_pos = pos;
|
|
||||||
pe->pos->beg_line = lnum;
|
|
||||||
pe->pos->end_pos = curr_pos;
|
pe->pos->end_pos = curr_pos;
|
||||||
pe->pos->end_line = linenum;
|
pe->pos->end_line = linenum;
|
||||||
|
|
||||||
|
|
@ -694,7 +700,7 @@ void instance_t::include_directive(char * line)
|
||||||
#if defined(TIMELOG_SUPPORT)
|
#if defined(TIMELOG_SUPPORT)
|
||||||
timelog,
|
timelog,
|
||||||
#endif
|
#endif
|
||||||
stream, scope, journal, master,
|
stream, scope, journal, global_sequence, master,
|
||||||
&filename, strict, this);
|
&filename, strict, this);
|
||||||
instance.parse();
|
instance.parse();
|
||||||
|
|
||||||
|
|
@ -880,6 +886,7 @@ post_t * instance_t::parse_post(char * line,
|
||||||
post->pos->pathname = pathname;
|
post->pos->pathname = pathname;
|
||||||
post->pos->beg_pos = line_beg_pos;
|
post->pos->beg_pos = line_beg_pos;
|
||||||
post->pos->beg_line = linenum;
|
post->pos->beg_line = linenum;
|
||||||
|
post->pos->sequence = (*global_sequence)++;
|
||||||
|
|
||||||
char buf[MAX_LINE + 1];
|
char buf[MAX_LINE + 1];
|
||||||
std::strcpy(buf, line);
|
std::strcpy(buf, line);
|
||||||
|
|
@ -1229,6 +1236,7 @@ xact_t * instance_t::parse_xact(char * line,
|
||||||
xact->pos->pathname = pathname;
|
xact->pos->pathname = pathname;
|
||||||
xact->pos->beg_pos = line_beg_pos;
|
xact->pos->beg_pos = line_beg_pos;
|
||||||
xact->pos->beg_line = linenum;
|
xact->pos->beg_line = linenum;
|
||||||
|
xact->pos->sequence = (*global_sequence)++;
|
||||||
|
|
||||||
bool reveal_context = true;
|
bool reveal_context = true;
|
||||||
|
|
||||||
|
|
@ -1378,11 +1386,12 @@ std::size_t journal_t::parse(std::istream& in,
|
||||||
time_log_t timelog(*this);
|
time_log_t timelog(*this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::size_t parsing_sequence = 1;
|
||||||
instance_t parsing_instance(state_stack,
|
instance_t parsing_instance(state_stack,
|
||||||
#if defined(TIMELOG_SUPPORT)
|
#if defined(TIMELOG_SUPPORT)
|
||||||
timelog,
|
timelog,
|
||||||
#endif
|
#endif
|
||||||
in, scope, *this, master,
|
in, scope, *this, &parsing_sequence, master,
|
||||||
original_file, strict);
|
original_file, strict);
|
||||||
parsing_instance.parse();
|
parsing_instance.parse();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue