Refactor to store tags as individual attributes

Each tag is stored as `tag_<tagname>: x`.  The `x` is required because
empty attributes are treated as nonexistent.

For compatibility, the `tags` attribute is updated in sync with the
per-tag attributes.  This compatibility support may be dropped in later
versions.

Note that synchronization _updates_ use JSON format, which does not
change with this patch, and thus no compatibility issues exist.  The
synchronization _initialization_, however, uses FF4, meaning that a
sync server initialized from a version of `task` with this patch will
contain `tag_<tagname>` attributes, which will look like orphaned UDAs
to older versions.  However, as updates to tasks are synchronized via
the sync server, the updates will not contain these attributes and they
will show as "deleted" in the `task info` display on the older version.
Aside from the noise in the `task info` output, this is harmless.
This commit is contained in:
Dustin J. Mitchell
2021-08-02 01:25:16 +00:00
committed by Tomas Babej
parent 17e6257e07
commit 20041c120e
6 changed files with 163 additions and 91 deletions

View File

@@ -125,7 +125,7 @@ public:
int getTagCount () const;
bool hasTag (const std::string&) const;
void addTag (const std::string&);
void addTags (const std::vector <std::string>&);
void setTags (const std::vector <std::string>&);
std::vector <std::string> getTags () const;
void removeTag (const std::string&);
@@ -170,6 +170,10 @@ private:
void validate_before (const std::string&, const std::string&);
const std::string encode (const std::string&) const;
const std::string decode (const std::string&) const;
bool isTagAttr (const std::string&) const;
const std::string tag2Attr (const std::string&) const;
const std::string attr2Tag (const std::string&) const;
void fixTagsAttribute ();
public:
float urgency_project () const;