Commit Graph
32 Commits
Author SHA1 Message Date
lmat a9cc488cbf Should return std::string
This is only used in C++, so there is no need to g_strdup in here. Also,
this fixes a memory leak in KvpFrameImpl.
2017-08-29 14:12:25 -04:00
lmat 048b8e37a1 Clear up guile2 vs. guile cmake confusion 2017-08-29 13:58:31 -04:00
lmat 85770afb8e Replaced inheritance from boost uuid with composition
Rather than extending boost::uuids::uuid, we add a boost::uuids::uuid
member to handle the implementation of equality checking, uuid
generation, etc.
2016-10-25 12:36:53 -04:00
lmat 0a5a0ab7ab Separate C guid from C++ guid 2016-10-21 17:19:58 -04:00
lmat e1e85cee16 Added forward declaration for struct GncGUID
I also removed the guid.hpp include where I could.
2016-10-19 17:05:48 -04:00
lmat 1c00937abe Clean up guid usage.
Now that there is a subclass of boost::uuids::uuid, that subclass can be
used for GncGUID implementation. This removes the need for the untidy
casts to/from bost::uuids::uuid, and simplifies the logic in many areas.
2016-06-09 15:07:54 -07:00
lmat 293a286693 Add C++ header for guid.cpp and tests. 2016-06-09 15:07:54 -07:00
lmat 74800e18f3 Remove unused, left over typedef 2016-06-09 15:04:54 -07:00
lmat 0ee7e61b48 Adding googletest cases for c++ qofsession struct 2016-06-09 14:51:21 -07:00
lmat 3063c87346 Replace C qofsession struct with c++ qofsession struct 2016-06-09 14:51:21 -07:00
lmat 557a5e2f2d Check the appropriate locations for gmock and gtest sources
Although we test libgtest_main, we don't test for libgmock_main. This
shouldn't be necessary since gmock was absorbed by gtest in upstream,
so I'm not planning on working hard to correct this problem robustly.
We'll just check for the source files in the other location where they
might be.
2016-06-09 14:51:21 -07:00
lmat 3390886051 Corrected "misleading" indentation
gcc 6.1.1 throws an error because with 8-space tabs, it looks like a
line is in an if statement when it isn't.
2016-06-09 14:51:21 -07:00
lmat 7d5f0a66a0 Kvp-Frame test cases
Adding google tests for many of Kvp Frame's member functions. One
function in KvpFrameImpl, for_each_slot, should probably be something
like

template <typename T> void
for_each_slot (T & t, void * data) const
{
    std::for_each(......
    [&t, data] (... a)
    {
        t(a, data);
    }
}

This way, we could create a functor mock object for testing purposes,
but of course, pointers would still behave correctly.
2014-12-20 14:27:49 -08:00
lmat ba59350f69 Adding KvpValueImpl test suite 2014-11-18 09:54:34 -08:00
lmat 8de928241f Added quotes to gtest section in configure.ac
Without these quotes, the error messages can be confusing in the case that
variables contain spaces, and, more likely, when the variables are empty.
2014-11-07 14:26:20 -08:00
lmat 076f1fb25d Implement KvpFrame in C++ using std::vector
KvpFrame was implemented using GList. Given the current desire
to distance ourselves from glib and acquaint the project with
C++, the standard library thereof, and boost libraries, KvpFrame
has been replaced by an implementation that uses a std::map<
const char *, KvpValueImpl *>.

There were some cases of the KvpFrame's glist being accessed
directly. A new API to help callers access the KvpFrame's contents
systematically by providing a list of keys has been created, and
call sites of the GList code have been updated.

Another deprecated #define was found and removed (kvp_frame_set_str).
2014-11-03 12:27:00 -08:00
lmat 6c2a42bf49 Fixed kvp-value delete
Delete wasn't being called properly due to bad template resolution.
2014-10-31 12:01:57 -07:00
lmat fabbfdb054 Removing another deprecated #define
kvp_frame should not be used by C code, but rather the standard
KvpFrame. The deprecated value just adds one more name for this
class that doesn't add any value.
2014-10-13 12:22:11 -07:00
lmat 8a7f426f3b Implement KvpValue in c++ using boost::variant
KvpValue is now instantiated as a boost::variant and passed around as an opaque
pointer in C. The C interface is basically unchanged and a c++ interface exists
in kvp-value.hpp

The c++ implementation for KvpValue is called KvpValueImpl and is in kvp-value.cpp.
We don't use structured exception handling at this point, so c++ functions are
marked 'noexcept'.

The logic is within the c++ implementations. C wrapper functions do little besides
ensure that the pointer is not nullptr before calling into c++.
The logic in kvp_value_glist_to_string was moved to the c++ class. It's an
implementation detail, but unfortunately, it was being exposed through a pointer,
so I had to modify the test just a bit to not use it directly.

In order to work around what seems to be a bug in an Apple compiler, it was decided
to create an header file private to kvp-value and kvp_frame that holds the definition
of KvpFrame so that it was visible to both translation units.
2014-10-07 09:43:14 -07:00
lmat b109c94f2c Removing deprecated #define
kvp_value should not be used, but rather the standard KvpValue. Using
the deprecated value just adds one more variation on this typename.
2014-09-21 13:32:59 -07:00
lmat d2913915e6 Removed binary from kvpvalues
It looks like the binary kvpvalue wasn't being used, and, since
it is difficult to deal with, it is easiest to remove it altogether.
2014-09-16 15:12:12 -07:00
lmat 3363a2c572 Replace C++ reserved words for future compatibility with C++ 2014-09-05 11:56:48 -07:00
lmat 9711ae2446 Added new tests.
Added tests for string_to_guid and guid_replace.
2014-08-01 10:23:30 -04:00
lmat 726ab02d65 Simplified some of the GUID code.
This change applies some recommendations from jralls. It better utilizes for loops,
and usage of swap. We also try to make sure the null guid is not freed since it's
reused, and catch a c++ exception to make sure it doens't escape into C code when
parsing a GUID.
2014-07-28 17:03:07 -04:00
lmat ce94872ec8 Cleaned up some code and comments.
There should be no impacting changes in this commit.
2014-07-28 16:52:22 -04:00
lmat cbc292cc91 Removed the md5 file and updated the build system.
We no longer need md5.h or md5.c because all that work is done in the boost
uuid implementation.
2014-07-28 11:15:28 -04:00
lmat f40a93c6e1 Remove guid_init and guid_shutdown
They no longer do anything, and it's not probable that they ever will.
2014-07-25 17:38:33 -04:00
lmat 30fac05e35 Corrected uses of guid_to_string.
Previously, guid_to_string had been marked deprecated with a note about
it not being thread-safe. It was much worse than "not thread safe", it
was only safe in a particular situation, and its safety was being violated
throughout the code. It was clear that users of guid_to_string did not
understand what it was purporting to do because of its varied uses. Most
uses simply treated it like a Garbage-Collected Java String (use and forget).
I actually found at least one instance where the string was being freed. (!!!)

I made the method have a particular easy-to-understand semantic: it returns
a pointer to a string which must be freed by the caller. I then tried to
track down all uses of this function and correct them. Mostly, I just changed
the usage to guid_to_string_buff with a stack-allocated string to avoid the
the malloc/free cycle.
2014-07-25 17:30:55 -04:00
lmat 2a408ab9ef Cleared up GUID construction and allocation
To allocate a GUID, use guid_malloc. To allocate and construct a guid
(which is actually unique), use guid_new (and be sure to free it using
guid_free).
2014-07-25 14:14:09 -04:00
lmat 9c82a1e9bc Rename guid_new to guid_replace
`new` implies some allocation. Since guid_new was actually constructing
a guid in place rather than allocating it, it makes much more sense to
call it guid_replace (or guid_construct). We went with guid_replace.
2014-07-25 08:26:54 -04:00
lmat 26a49f9644 Implement GUID using boost's implementation
Since we're maintaining a C api, the implementation is sometimes less than
intuitive from either a C or C++ perspective. I am trying to use as much
boost as possible while making all the guarantees that the C code makes.

One function was declared deprecated because it "wasn't thread safe". This
was straightforward to repair, and is no longer marked deprecated, and there
are now two ways to convert GUID to String: passing your own character
buffer, and having one returned to you that you need to free.
2014-07-25 08:17:28 -04:00
lmat 949702d04d Added a GUID test suite
The plan is to change gnc guid to use boost's guid implementation. There were
no tests for guid before, but we need them to ensure that we don't have regressions
when that work begins.
2014-06-15 14:42:47 -07:00