Since the taxonomy is now a real C++ struct with constructor
and destructor, dive_site has to be converted to C++ as well.
A bit hairy for now, but will ultimately be distinctly simpler.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fix loading of the negation of filter conditions. Unlike other
conditions that are persisted as `<key>="<value>"`, this is persisted
to git as `negate`.
This fix remediates this for all cases where the condition has already
been saved to the cloud storage.
Saving to XML takes a different approach and indicates negated
conditions with `negate="1"`, making it identical to all other
attributes. The question is if this approach should be implemented in
addition to the above fix, in order to unify the storage format.
Fixes#4246.
Signed-off-by: Michael Keller <github@ike.ch>
Had to rewrite the thing, because gcc's warnings don't work
with templatized var-args. Since there is no string-format.cpp
and I didn't want to inline it, moved it to format.cpp.
String formatting is distributed around at least four
headers: membuffer.h, subsurface-string.h, format.h
and format-string.h. This really should be unified!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Quite a bit of fallout in users of this structure.
Conveniently, since git-access.cpp is now C++ we can move
some helpers from the monstrous qthelper.cpp to git-access.cpp.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a pattern of code like
match_action(line, state, dive_action, ARRAY_SIZE(dive_action));
The doubling of the array might cause copy & paste errors, where
only one array is replaced.
Therefore, determine the length of the array with (hopefully
easily understood) template tricksery.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When iterating over the converted strings of a line, the
first entry of the array would be popped off, leading to
a full copy of the remaining array.
Instead, use an index in the parser state.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The converted strings were stored in a membuffer and later
converted to std::strings. Generate an std::string directly
to avoid unnecessary copying.
Ultimately, when the core structures are converted to
std::string, there should be no copying of the string data
at all (unless formatting is applied or small string
optimization kicks in, of course).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make the memory management easier to follow. I feel that the old
code was leaking left and right, but not sure because it was so
intractable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simplifies memory management. Think about unglobalizing this,
once everything is in C++ so that we can put an std::string
into struct divelog.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>