Use emplace_back instead of push_back
Use 'nullptr'
Use function 'empty ()' instead of 'size () == 0'
Mark single-argument constructors as 'explicit'
Call static function correctly
- Remove unused includes
- Use '<..>' style consistently
- Strip any paths from include
- Replace deprecated C++ headers
- Sort includes according to LLVM rules
https://llvm.org/docs/CodingStandards.html#include-style
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
The Interval::dump() method will show if intervals are synthetic or not,
which can be useful when trying to determine why a comparison is
failing.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
This is particularly bad when called from the Database::modifyInterval
call, since the delete may fail, but then the addInterval will proceed.
Closes#319
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
If calling undo on an operation the removes many entries from the
datafiles, there would be many 0 length size files remaining in the data
directory. Now they will be removed if they are empty so they will not
longer need to be checked when parsing the database.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Ensure that the IntervalFactory can parse the string returned by
Interval::serialize before writing to database.
If a user attempts to add a non-parseable date, you will get an error like:
$ TZ="GMT" timew track 7h before 1970-01-01T00:00:00 test
Note: 'test' is a new tag.
Internal error. Failed encode / decode check.
Or if the user attempts to add a tag that is not supported:
$ timew start 1970-01-01T00:00:00 '\"TEST\"'
Note: '"\\"TEST\\""' is a new tag.
Internal error. Failed encode / decode check.
On #159, the serializer / deserializer should be able to handle the escaped
quotes, but it is another example where we do not want any entry written into
the database that cannot be properly parsed. This change will also add more
verbose debugging information if the :debug flag is passed, like:
$ timew start 1970-01-01T00:00:00 '\"TEST\"' :debug
CLI Parser
_original_args
timew start 1970-01-01T00:00:00 \"TEST\" :debug
_args
word basename='timew' raw='timew' BINARY
word canonical='start' raw='start' ORIGINAL CMD
date raw='1970-01-01T00:00:00' ORIGINAL FILTER
word raw='\"TEST\"' ORIGINAL FILTER TAG
word canonical=':debug' raw=':debug' ORIGINAL HINT FILTER
>> 2020-02.data: 0 intervals
>> 1970-01.data: 0 intervals
>> 1969-12.data: 0 intervals
>> Loaded 0 tracked intervals
Note: '"\\"TEST\\""' is a new tag.
>> Datafile::addInterval() failed.
>> Encode / decode check failed:
>> inc 19700101T060000Z # "\\"TEST\\""
>> is not equal to:
>> inc 19700101T060000Z # "TEST\\\"\"" \
Internal error. Failed encode / decode check.
>> Timer timew 0.002137 sec
Closes#290
Related to #159
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Not only does this eliminate the need to copy the stings to the caller, it will
also eliminate the need for any iterators over the entries in the Database from
having to hold a copy of the lines from the Datafile.
Related to #245.