Commit graph

63 commits

Author SHA1 Message Date
Thomas Lauf
7b4a234f03 Unify coding style
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2023-12-23 22:38:31 +01:00
Thomas Lauf
6d79ea4a6d Update copyright statements
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2023-09-18 12:33:17 +02:00
Thomas Lauf
9299fd3e39 Apply Clang-Tidy
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
2023-06-17 14:19:02 +02:00
Thomas Lauf
2535c2c399 Cleanup includes
- 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>
2023-06-17 14:19:02 +02:00
Shaun Ruffell
939491d060 Dump intervals in serialization check
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>
2021-05-16 12:43:49 +02:00
Tomas Babej
e5870380a4
doc: Update copyright to 2021 2021-01-02 02:52:39 -05:00
Shaun Ruffell
7481dab8d0 Datafile: Throw exception if Datafile::deleteInterval fails
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>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
b0efdbc9ee Datafile: Remove empty files
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>
2020-08-10 22:24:52 +02:00
Thomas Lauf
ad58309159 Update Copyright
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-04-19 12:41:23 +02:00
Shaun Ruffell
c1f3d8be72 Check serialization before writing to database
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>
2020-03-04 07:44:05 +01:00
Shaun Ruffell
4b3a907cbb Use AtomicFile for data, tags, undo, and config files
Now changes accross all of these files either happen all together or not
at all.

Related to issue #155
2020-02-23 19:03:40 +01:00
Shaun Ruffell
ea3bbd0e85 Datafile: allLines() can return const reference instead of copy.
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.
2020-01-17 17:48:57 +01:00
Thomas Lauf
d64017a7a6 Update copyright dates
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-10-18 10:59:16 +02:00
Thomas Lauf
9dd106116c Let Interval inherit from Range
- Remove 1 level of indirection
- Remove public field Interval::range (instead use interval directly)
2018-09-19 06:32:56 +02:00
Thomas Lauf
f640eb4bc5 Remove splitting of intervals in storage files
- intervals are stored within the datafile which contains the starting date
- convert segmentContains to startsWithin and unify it
- Closes #174
2018-09-18 21:06:33 +02:00
Janik Rabe
4325ffa136 Handle zero-width intervals correctly
Fixes #101
Fixes #165
Closes #164
2018-09-18 21:04:09 +02:00
Simon Ruderich
2271bd9eea Use https:// link for opensource.org 2018-03-16 23:11:08 +01:00
Paul Beckingham
c0086ec150 Datafile: sort lines in ascending order before writes 2016-07-04 10:48:57 -04:00
Paul Beckingham
c35f40781c Datafile: Improved debug message wording 2016-06-10 22:02:13 -04:00
Paul Beckingham
11315e4f56 Datafile: Added debug output 2016-05-26 23:32:23 -04:00
Paul Beckingham
d601a77c42 Datafile: Added assert to ::deleteInterval to confirm redundancy 2016-04-29 18:22:36 -04:00
Paul Beckingham
32e066a388 Datafile: Added assert to ::addInterval to confirm redundancy 2016-04-29 18:22:25 -04:00
Paul Beckingham
db3c3fb14c Datafile: Removed exclusions 2016-04-27 18:05:37 -04:00
Paul Beckingham
24bb8ade7a libshared: Accomodated new argument order for Datetime 2016-04-24 08:37:48 -04:00
Paul Beckingham
49715320ef Cleanup: Replaced "\n" with '\n' 2016-04-23 13:30:54 -04:00
Paul Beckingham
63a6255412 Interval: Now has pubic ::range, which has public ::start, ::end 2016-04-23 10:35:06 -04:00
Paul Beckingham
4176bf23d4 Range: Renamed Daterange to Range 2016-04-23 08:52:16 -04:00
Paul Beckingham
b1b8f018a6 Datafile: Clarified responsibilities in comment. More work needed 2016-04-23 08:32:19 -04:00
Paul Beckingham
779e0ce239 Datafile: Exclusions inserted when not found in data 2016-04-17 10:10:57 -04:00
Paul Beckingham
13da904da0 Datafile: Converted from a Datetime pair to a Daterange 2016-04-17 09:35:45 -04:00
Paul Beckingham
61499bd974 Datafile: Added exclusions into _lines, ready to commit 2016-04-17 09:03:56 -04:00
Paul Beckingham
9e2ed873ae Datafile: Removed bool result from ::deleteInterval 2016-04-17 09:02:04 -04:00
Paul Beckingham
365b1eb2ff Datafile: Removed bool result from ::addInterval 2016-04-17 08:52:37 -04:00
Paul Beckingham
3764c60f90 Datafile: Fixed range rejection 2016-04-17 08:45:30 -04:00
Paul Beckingham
981ef3126d Consider intervals with trivial end dates 2016-04-11 17:13:14 -04:00
Paul Beckingham
9e4162ecd4 Datafile: Typo 2016-04-11 17:12:48 -04:00
Paul Beckingham
91f6600909 Datafile: Refactored data I/O 2016-04-11 08:23:30 -04:00
Paul Beckingham
01301dc647 Datafile: Added full ::dump details 2016-04-10 16:57:48 -04:00
Paul Beckingham
a65f4c3fd2 Datafile: Exclusions now provided at a vector 2016-04-10 16:56:31 -04:00
Paul Beckingham
0796e0c522 Datafile: Fixed Datetime::daysInMonth call with args in the wrong order 2016-04-06 21:29:51 -04:00
Paul Beckingham
1a0cc1a049 Datafile: Interval identity is based on start time 2016-04-05 00:37:22 -04:00
Paul Beckingham
b41b56c00c Datafile: Removed compiler warning 2016-04-03 12:45:38 -04:00
Paul Beckingham
6fc25a3de1 Datafile: Removed unused ::getAllIntervalsSince 2016-03-22 00:22:47 -04:00
Paul Beckingham
10d5ad2816 Datafile: Proagates errors when unable to write to file 2016-03-22 00:10:23 -04:00
Paul Beckingham
9a513ea1b2 Datafile: Handles modified intervals 2016-03-22 00:09:59 -04:00
Paul Beckingham
3e16f52621 Datafile: Implemented ::getIntervalsSince 2016-03-21 23:46:58 -04:00
Paul Beckingham
3b26979096 Datafile: Added \n to intervals 2016-03-21 19:32:19 -04:00
Paul Beckingham
69d80bc2bb Datafile: Implemented ::commit 2016-03-21 18:54:32 -04:00
Paul Beckingham
13e5736cd6 Datafile: Implemented ::getLatestInterval 2016-03-21 18:54:01 -04:00
Paul Beckingham
03e21073fb Datafile: Implemented ::getAllIntervals 2016-03-21 18:52:59 -04:00