Commit Graph

13 Commits

Author SHA1 Message Date
Jason Rhinelander 0738695eb9 Add lokimq compatibility headers 2021-01-14 15:32:38 -04:00
Jason Rhinelander 2ae6b96016 Rename LokiMQ to OxenMQ 2021-01-14 15:32:38 -04:00
Jason Rhinelander bd9313bf19 Fix decoding into a std::byte
Decoding into a std::byte output iterator was not working because the
`*out++ = val` assignment doesn't work when the output is std::byte and
val is a char/unsigned char/uint8_t.  Instead we need to explicitly
cast, but figuring out what we have to cast to is a little bit tricky.

This PR makes it work (and bumps the version for this and the is_hex
fix).
2020-12-14 13:05:14 -04:00
Jason Rhinelander 90701e5d62 Make lokimq::is_hex check for size being a multiple of 2
`is_hex()` is a bit misleading as `from_hex()` requires an even-length
hex string, but `is_hex()` also allows odd-length hex strings, which
means currently callers should be doing `if (lokimq::is_hex(str) &&
str.size() % 2 == 0)`, but probably aren't.

Since the main point of `lokimq/hex.h` is for byte<->hex conversions it
doesn't make much sense to allow `is_hex()` to return true for something
that can't be validly decoded via `from_hex()`, thus this PR changes it
to return false.

If someone *really* wants to test for an odd-length hex string (though
I'm skeptical that there is a need for this), this also exposes
`is_hex_digit` so that they could use:

    bool all_hex = std::all_of(str.begin(), str.end(), lokimq::is_hex_digit<char>)
2020-12-12 20:25:01 -04:00
Jason Rhinelander 9ac47ec419 Add missing <string> headers for libc++ 2020-05-15 01:32:29 -03:00
Jason Rhinelander 1479a030d7 Add it pair versions of {to,from}_{hex,base32z,base64}
Previously you could only generate a string from a string_view, or could
manage the string yourself and pass input iterators plus an output
iterator.

This commit adds an intermediate version that creates a string from a
pair of input iterators.
2020-05-13 14:47:01 -03:00
Jason Rhinelander 1f60abf50e Make from_{hex,base32z,base64} compatible with std::byte
Make the char handling a bit more generic so that std::byte (or other
size-1 types) will work.
2020-05-12 19:38:05 -03:00
Jason Rhinelander 7b42537801 Require C++17
Removes lokimq::string_view (the type alias is still provided for
backwards compat, but now is always std::string_view).

Bump version (on dev branch) to 1.2.0
2020-05-12 15:33:59 -03:00
Jason Rhinelander 46d007e1ac Add base32z encoder/decoder 2020-05-08 13:34:42 -03:00
Jason Rhinelander af42875e97 Made simple_string_view take a char type
This allows (most usefully) a `ustring_view` for viewing unsigned char
strings.
2020-04-03 12:28:50 -03:00
Jason Rhinelander 428ef12506 Add missing `inline` to de-templatized hex funcs 2020-03-03 15:06:39 -04:00
Jason Rhinelander 465b398b10 Use string_view instead of taking string type by template
Fixes the case of using a char *
2020-03-02 18:50:43 -04:00
Jason Rhinelander f3d583c520 Initial LokiMQ release
This library is adapted from lokid's existing quorumnet code (added in
6.x) used for SN-to-SN communication for quorum voting but generalized
to be usable both there and as a basis for other communication channels
with loki projects (for example: wallet-to-lokid communication; loki-ss
and lokinet internal communication with lokid; loki-ss to loki-ss
communication and message passing; perhaps eventually loki p2p traffic).

This initial release compiles but likely has a few warts and bugs that
need ironing out in the implementation before it is production ready.
Some tests will follow.
2020-02-02 22:39:26 -04:00