2 years agoFix #41: Fix the C++17 build breakage introduced in 840ac79
Jakob Petsovits [Sat, 31 Mar 2018 15:05:20 +0000 (11:05 -0400)]
Fix #41: Fix the C++17 build breakage introduced in 840ac79

In C++17, std::string::data() returns a non-const char pointer,
which means that our direct_data_access_result_state will
handle it instead of array_access_result_state.

This commit updates the static_assert() to reflect this change,
with no changes in behavior otherwise.

2 years agoMerge pull request #42 from jpetso/master
Jakob Petsovits [Sat, 31 Mar 2018 15:07:09 +0000 (11:07 -0400)]
Merge pull request #42 from jpetso/master

Refactor CMakeLists.txt to allow for specifying the C++ standard.

2 years agoRefactor CMakeLists.txt to allow for specifying the C++ standard. 42/head
Jakob Petsovits [Sat, 31 Mar 2018 03:32:41 +0000 (23:32 -0400)]
Refactor CMakeLists.txt to allow for specifying the C++ standard.

This can be used by the CI bots to test against newer standards
(C++14, C++17 and beyond) to ensure that cppcodec is indeed
compatible with C++11 *and above*.

(The change does not include changing the CI bot tests.)

2 years agoMerge pull request #40 from jpetso/master
Jakob Petsovits [Wed, 28 Mar 2018 16:38:47 +0000 (12:38 -0400)]
Merge pull request #40 from jpetso/master

Further improve performance by fixing specialized data accessors

2 years agoFurther improve performance by fixing specialized data accessors 40/head
Jakob Petsovits [Mon, 26 Mar 2018 10:33:42 +0000 (06:33 -0400)]
Further improve performance by fixing specialized data accessors

After the previous speed-up, almost 35% of the perf flamegraph
for decoding was caught up in std::string::push_back().
That seemed suspicious, because I thought that initial allocation
with reserve() should make the remaining push_back() calls
very fast. Turns out that's not the case.

Along the way, I found out that the optimized implementation for
containers with mutable data() access (e.g. std::vector<uint8_t>)
did not actually work. What I believed I had gotten to work was
in fact silently removed by SFINAE; as a result, all allocation
went through the fallback path with reserve() and push_back().

The fix required some changes but in the end isn't all that bad.
In addition to the handler for containers with mutable data(),
I added a handler for containers with mutable operator[] such
as std::string (as long as it's possible to assign a char to it).

To make sure it now works as intended, a static_assert() now
ensures that the correct code path is being used.

The benchmark from gaspardpetit/base64 uses std::string for both
encoding and decoding, which is not so great but I guess makes it
easier to integrate all the ad-hoc libraries with std::string APIs.
Consequently, cppcodec now moves to the upper league in both
encoding and decoding benchmarks.

On my system for the 256 buffer size benchmark, encoding was at
1.37 before and is now at 0.80, or 40% less time spent compared
to the previous commit. Decoding got faster from an original
1.68 to about 0.85, i.e. 50% less time spent.

This puts cppcodec performance slightly behind the GNOME base64
implementation for encoding and in the neighborhood of
nehadamvr/arduino-base64, way ahead of ElegantDice and such.
For decoding, cppcodec now beats GNOME and catches up to
Wikibooks.org/C, slightly behind Apache. Polfosol is still
way ahead of cppcodec for both encoding and decoding.

2 years agoMerge pull request #39 from jpetso/master
Jakob Petsovits [Mon, 26 Mar 2018 06:56:04 +0000 (02:56 -0400)]
Merge pull request #39 from jpetso/master

Improve decoding performance by always inlining Codec::index_of()

2 years agoImprove decoding performance by always inlining Codec::index_of() 39/head
Jakob Petsovits [Mon, 26 Mar 2018 06:04:00 +0000 (02:04 -0400)]
Improve decoding performance by always inlining Codec::index_of()

In the gaspardpetit/base64 test, perf showed a significant amount
of time spent in that function, which seemed off because that
function should not exist at all in a release build.

Making sure it's inline reduces decoding time for Gaspard's 256
workload by almost 30% (from approx. 2.38 to 1.69 on my machine).
It seems logical to assume that other codecs get a similar
performance boost this way, so I'm applying the change everywhere.

This puts performance characteristics around the same level of
adamvr/arduino-base64 or the Manuel Martinez one (but without
the latter's apparent setup overhead). Still not the best,
but now definitely in the "fair" spectrum for decoding.

2 years agoMerge pull request #38 from jpetso/master
Jakob Petsovits [Mon, 26 Mar 2018 03:58:08 +0000 (23:58 -0400)]
Merge pull request #38 from jpetso/master

Fix remaining VC14 warnings

2 years agoRemove throw expression from hex::num_encoded_tail_symbols() 38/head
Jakob Petsovits [Mon, 26 Mar 2018 03:15:58 +0000 (23:15 -0400)]
Remove throw expression from hex::num_encoded_tail_symbols()

It was only there for demonstrative purposes / consistency with
other codecs, but conflicted with the noexcept declaration and
thus caused a warning for at least VC14.

Replaced it with a comment.

2 years agoBring back noexcept for index[_last]() without VC14 warnings
Jakob Petsovits [Mon, 26 Mar 2018 02:39:39 +0000 (22:39 -0400)]
Bring back noexcept for index[_last]() without VC14 warnings

2 years agoFix #33: More helpful explanation for base64_url_unpadded
Jakob Petsovits [Sun, 11 Mar 2018 22:52:27 +0000 (18:52 -0400)]
Fix #33: More helpful explanation for base64_url_unpadded

I hope this makes things clear enough for readers.
Let me know if anything is still hard to understand.

2 years agoFix AppVeyor URL in README.md v0.1
Jakob Petsovits [Sun, 11 Mar 2018 16:22:50 +0000 (12:22 -0400)]
Fix AppVeyor URL in README.md

My AppVeyor account doesn't rebuild cppcodec when new changes are being
pushed to master.

Use efidler's AppVeyor URL instead. As tplgy admin, he has kindly added
AppVeyor integration to the upstream project and thus, updates get pushed
to his account.

2 years agoMerge pull request #37 from SoapGentoo/packaging-cleanups
Jakob Petsovits [Sun, 11 Mar 2018 15:56:10 +0000 (11:56 -0400)]
Merge pull request #37 from SoapGentoo/packaging-cleanups

Packaging cleanups

2 years agoCut initial version 0.1 37/head
David Seifert [Sun, 11 Mar 2018 08:40:40 +0000 (09:40 +0100)]
Cut initial version 0.1

2 years agoUpdate Catch2 URL
David Seifert [Sun, 11 Mar 2018 08:40:40 +0000 (09:40 +0100)]
Update Catch2 URL

2 years agoTry to use system Catch2
David Seifert [Sun, 11 Mar 2018 08:40:40 +0000 (09:40 +0100)]
Try to use system Catch2

2 years agoAdd pkg-config file
David Seifert [Sun, 11 Mar 2018 08:40:40 +0000 (09:40 +0100)]
Add pkg-config file

2 years agoModernise CMake
David Seifert [Sun, 11 Mar 2018 08:40:40 +0000 (09:40 +0100)]
Modernise CMake

* Use `GNUInstallDirs` to override allow
  overriding installation directories.
* `CTest` provides a standardized variable
  for enabling tests `BUILD_TESTING`.

3 years agoMerge pull request #31 from nigels-com/master
Jakob Petsovits [Thu, 3 Aug 2017 03:55:52 +0000 (23:55 -0400)]
Merge pull request #31 from nigels-com/master

Fixup: Install base64_url_unpadded.hpp via cmake

3 years agoFixup: Install base64_url_unpadded.hpp via cmake 31/head
Nigel Stewart [Thu, 3 Aug 2017 03:45:04 +0000 (13:45 +1000)]
Fixup: Install base64_url_unpadded.hpp via cmake

3 years agoMerge pull request #30 from jpetso/master
Jakob Petsovits [Wed, 26 Jul 2017 21:18:15 +0000 (17:18 -0400)]
Merge pull request #30 from jpetso/master

Add AppVeyor badge to README.txt.

3 years agoAdd AppVeyor badge to README.txt. 30/head
Jakob Petsovits [Fri, 7 Jul 2017 16:57:47 +0000 (12:57 -0400)]
Add AppVeyor badge to README.txt.

3 years agoMerge pull request #29 from jpetso/master
Eli Fidler [Tue, 4 Jul 2017 22:07:05 +0000 (18:07 -0400)]
Merge pull request #29 from jpetso/master

Fix #10: Appveyor config file for testing on Windows / Visual Studio.

3 years agoFix #10: Appveyor config file for testing on Windows / Visual Studio. 29/head
Jakob Petsovits [Sat, 1 Jul 2017 17:59:09 +0000 (13:59 -0400)]
Fix #10: Appveyor config file for testing on Windows / Visual Studio.

Also, build options appropriate for MSVC in CMakeLists.txt.

3 years agoMerge pull request #28 from kurt-nj/add_files_to_cmake
Eli Fidler [Mon, 19 Jun 2017 19:16:18 +0000 (15:16 -0400)]
Merge pull request #28 from kurt-nj/add_files_to_cmake

base64_default_url_unpadded was missing from cmake files list

3 years agobase64_default_url_unpadded was missing from cmake files list 28/head
Kurt Johnson [Mon, 19 Jun 2017 18:51:48 +0000 (13:51 -0500)]
base64_default_url_unpadded was missing from cmake files list

3 years agoMerge pull request #26 from smasherprog/patch-1
Eli Fidler [Mon, 1 May 2017 15:33:28 +0000 (11:33 -0400)]
Merge pull request #26 from smasherprog/patch-1

Remove compiler warnings about conversion

3 years agoRemove compiler warnings about conversion 26/head
Scott [Sat, 29 Apr 2017 15:42:05 +0000 (08:42 -0700)]
Remove compiler warnings about conversion

This removes a compiler warning on vs
 warning C4244: 'argument': conversion from 'int' to 'uint8_t', possible loss of data

3 years agoMerge pull request #24 from Kronuz/master
Jakob Petsovits [Fri, 28 Oct 2016 17:38:25 +0000 (13:38 -0400)]
Merge pull request #24 from Kronuz/master

Add base64_url_unpadded variant for unpadded base64 encoding

3 years agoAdd base64_url_unpadded variant for unpadded base64 encoding 24/head
German M. Bravo [Wed, 26 Oct 2016 15:18:35 +0000 (10:18 -0500)]
Add base64_url_unpadded variant for unpadded base64 encoding

4 years agoMerge pull request #23 from thrimbor/fixes
Jakob Petsovits [Fri, 5 Aug 2016 23:00:05 +0000 (19:00 -0400)]
Merge pull request #23 from thrimbor/fixes

Fix for VC14 & warnings

4 years agoReplaced C-style casts to prevent warnings 23/head
Stefan Schmidt [Wed, 3 Aug 2016 00:42:47 +0000 (02:42 +0200)]
Replaced C-style casts to prevent warnings

4 years agoWorkaround for VisualC++ compilation (fixes #5)
Stefan Schmidt [Wed, 3 Aug 2016 00:35:36 +0000 (02:35 +0200)]
Workaround for VisualC++ compilation (fixes #5)

4 years agoRemoved the noexcept specifier from methods throwing exceptions (#22)
Stefan Schmidt [Tue, 19 Jul 2016 04:08:06 +0000 (06:08 +0200)]
Removed the noexcept specifier from methods throwing exceptions (#22)

Fixes -Wterminate warnings of GCC 6.

4 years agoChange return type of direct_data_access_result_state::size to size_t (#21)
Stefan Schmidt [Mon, 4 Jul 2016 16:24:23 +0000 (18:24 +0200)]
Change return type of direct_data_access_result_state::size to size_t (#21)

4 years agoMerge pull request #19 from jrogers/jrogers/build
Jakob Petsovits [Mon, 11 Apr 2016 22:14:21 +0000 (18:14 -0400)]
Merge pull request #19 from jrogers/jrogers/build

Set language to C++ otherwise CMake complains

4 years agoSet language to C++ otherwise CMake complains 19/head
Jeff Rogers [Sun, 10 Apr 2016 04:18:01 +0000 (00:18 -0400)]
Set language to C++ otherwise CMake complains

Avoids this error when running CMake:
CMake Error: CMake can not determine linker language for target: cppcodec

4 years agoMerge pull request #16 from jpetso/master
Jakob Petsovits [Sat, 30 Jan 2016 06:16:42 +0000 (01:16 -0500)]
Merge pull request #16 from jpetso/master

Add base32_hex codec variant, a.k.a. base32hex from RFC 4648.

4 years agoAdd base32_hex codec variant, a.k.a. base32hex from RFC 4648. 16/head
Jakob Petsovits [Sat, 30 Jan 2016 05:42:16 +0000 (00:42 -0500)]
Add base32_hex codec variant, a.k.a. base32hex from RFC 4648.

Fixes #8

4 years agoMerge pull request #15 from jpetso/master
Jakob Petsovits [Mon, 25 Jan 2016 02:28:13 +0000 (21:28 -0500)]
Merge pull request #15 from jpetso/master

Centralize block encoding and padding in stream_codec.

4 years agoCentralize block encoding and padding in stream_codec. 15/head
Jakob Petsovits [Sat, 23 Jan 2016 12:07:45 +0000 (07:07 -0500)]
Centralize block encoding and padding in stream_codec.

Codecs now only specify their shifted-bytes-to-index mappings
declaratively in a function index<I>(const uint8_t* binary_block).

stream_codec takes over the implementation of encode_block(),
encode_tail() and pad(). The templates used for this purpose
have been designed and measured to preserve space and runtime
behaviour by using the always_inline attribute where appropriate.

Decoding implementations are untouched for now. I might
decide to centralize them into stream_codec later as well.

Since pad() was rewritten from scratch in a different way,
this commit likely also resolves the VC14 compiler error.

4 years agoEliminate use of ostream to reduce included lines of code.
Jakob Petsovits [Sat, 23 Jan 2016 00:06:38 +0000 (19:06 -0500)]
Eliminate use of ostream to reduce included lines of code.

<*stream> headers contain a lot of code and can be avoided because
I really only wanted to convert a char to a string. Instead of
using std::to_string(), which is missing on Android, make our own
small conversion function.

Reduces line count of "#include <cppcodec/base64_rfc4648.hpp>"
on GCC 5.2.1 from 31158 lines of code to 21922.

That's only about a thousand lines more than the baseline of
including both <string> and <vector>, so assuming we want to
keep those, it seems there's nothing much more to be done there.

4 years agoMerge pull request #14 from jpetso/master
Jakob Petsovits [Tue, 19 Jan 2016 21:05:36 +0000 (16:05 -0500)]
Merge pull request #14 from jpetso/master

Different take on pad() SFINAE, with overloads and only one enable_if<>

4 years agoDifferent take on pad() SFINAE, with overloads and only one enable_if<>. 14/head
Jakob Petsovits [Fri, 15 Jan 2016 21:36:50 +0000 (16:36 -0500)]
Different take on pad() SFINAE, with overloads and only one enable_if<>.

Still breaks on VC14, but with fewer errors. Now we only have to
find a solution for one templated function instead of two.

4 years agoMerge pull request #13 from jpetso/build_ci
Jakob Petsovits [Mon, 18 Jan 2016 18:04:14 +0000 (13:04 -0500)]
Merge pull request #13 from jpetso/build_ci

Build with Travis CI.

4 years agoBuild with Travis CI. 13/head
Jakob Petsovits [Sun, 17 Jan 2016 23:58:14 +0000 (18:58 -0500)]
Build with Travis CI.

Fixes #9

4 years agoFix buffer overflow for null-terminated padded strings.
Jakob Petsovits [Mon, 18 Jan 2016 17:55:14 +0000 (12:55 -0500)]
Fix buffer overflow for null-terminated padded strings.

4 years agoRemove some items from TODO.md that I've added as GitHub issues.
Jakob Petsovits [Sun, 17 Jan 2016 18:47:10 +0000 (13:47 -0500)]
Remove some items from TODO.md that I've added as GitHub issues.

4 years agoAdd tests for hex codecs, and a few extra tests for base64.
Jakob Petsovits [Sat, 16 Jan 2016 22:30:51 +0000 (17:30 -0500)]
Add tests for hex codecs, and a few extra tests for base64.

Fixes #2

4 years agoAlso add case insensitivity test for base32_rfc4648.
Jakob Petsovits [Sat, 16 Jan 2016 22:01:42 +0000 (17:01 -0500)]
Also add case insensitivity test for base32_rfc4648.

4 years agoAdd tests for base32_rfc4648.
Jakob Petsovits [Sat, 16 Jan 2016 21:52:04 +0000 (16:52 -0500)]
Add tests for base32_rfc4648.

Fixes #1

4 years agoRefactoring: Move codec variants into their respective includes.
Jakob Petsovits [Sat, 16 Jan 2016 20:31:18 +0000 (15:31 -0500)]
Refactoring: Move codec variants into their respective includes.

Two advantages here:
1. No need to parse unused code when including only one variant.
2. Might make it easier for people to add new codec variants.

4 years agoDon't name an unused parameter. Avoids a VC14 compiler warning.
Jakob Petsovits [Fri, 15 Jan 2016 20:24:55 +0000 (15:24 -0500)]
Don't name an unused parameter. Avoids a VC14 compiler warning.

Fixes #6

4 years agoClang doesn't like non-lvalue ostringstreams. Fix that build error.
Jakob Petsovits [Thu, 14 Jan 2016 23:26:54 +0000 (18:26 -0500)]
Clang doesn't like non-lvalue ostringstreams. Fix that build error.

4 years agoIgnore Crockford base32 dashes as specified.
Jakob Petsovits [Thu, 14 Jan 2016 23:21:57 +0000 (18:21 -0500)]
Ignore Crockford base32 dashes as specified.

4 years agoIn README.md, mention exceptions for all overloads.
Jakob Petsovits [Mon, 4 Jan 2016 21:30:23 +0000 (16:30 -0500)]
In README.md, mention exceptions for all overloads.

Also tune some wordings a bit.

4 years agoUse -Wall -pedantic to make sure we'll work well within other projects.
Jakob Petsovits [Mon, 4 Jan 2016 21:21:40 +0000 (16:21 -0500)]
Use -Wall -pedantic to make sure we'll work well within other projects.

4 years agoPut base32 bit operations inside parentheses. Avoids some warnings.
Jakob Petsovits [Mon, 4 Jan 2016 21:10:00 +0000 (16:10 -0500)]
Put base32 bit operations inside parentheses. Avoids some warnings.

4 years agoAdd .gitignore.
Jakob Petsovits [Mon, 4 Jan 2016 18:08:11 +0000 (13:08 -0500)]
Add .gitignore.

4 years agoUpdate TODO and README to reflect the current feature status.
Jakob Petsovits [Mon, 28 Dec 2015 00:39:44 +0000 (19:39 -0500)]
Update TODO and README to reflect the current feature status.

4 years agoFix API documentation: default decoded type is std::vector<uint8_t>.
Jakob Petsovits [Mon, 28 Dec 2015 00:29:03 +0000 (19:29 -0500)]
Fix API documentation: default decoded type is std::vector<uint8_t>.

4 years agoAdd base64url tests, and adapt base64 tests to also use "/".
Jakob Petsovits [Mon, 28 Dec 2015 00:21:51 +0000 (19:21 -0500)]
Add base64url tests, and adapt base64 tests to also use "/".

4 years agoTest for some error conditions & refine exception types.
Jakob Petsovits [Sun, 27 Dec 2015 23:53:42 +0000 (18:53 -0500)]
Test for some error conditions & refine exception types.

4 years agoAdd tests for standard base64.
Jakob Petsovits [Sun, 27 Dec 2015 22:17:01 +0000 (17:17 -0500)]
Add tests for standard base64.

4 years agoAdd test framework and a set of tests for base32_crockford.
Jakob Petsovits [Sun, 27 Dec 2015 21:19:16 +0000 (16:19 -0500)]
Add test framework and a set of tests for base32_crockford.

4 years agoFix decoded_max_size() for unpadded stream codecs.
Jakob Petsovits [Sun, 27 Dec 2015 21:14:48 +0000 (16:14 -0500)]
Fix decoded_max_size() for unpadded stream codecs.

The previous version produced sizes that are too big in some cases.
The new version always yields the exact size for cases when the
input data contains only non-whitespace symbols.

4 years agoIn encode(), don't decrease src_end unless a full block is present.
Jakob Petsovits [Sun, 27 Dec 2015 21:11:14 +0000 (16:11 -0500)]
In encode(), don't decrease src_end unless a full block is present.

This prevents us from running into overflow issues when
src_size == 0 and src == 0x0.

4 years agoFix templates/accessors to make all overloads work.
Jakob Petsovits [Sun, 27 Dec 2015 17:36:44 +0000 (12:36 -0500)]
Fix templates/accessors to make all overloads work.

4 years agoAdd TODO item about improving the command line tools.
Jakob Petsovits [Thu, 24 Dec 2015 08:50:24 +0000 (03:50 -0500)]
Add TODO item about improving the command line tools.

4 years agoMake the Hello World example from README.md actually work.
Jakob Petsovits [Thu, 24 Dec 2015 08:20:05 +0000 (03:20 -0500)]
Make the Hello World example from README.md actually work.

Since it passes a string literal (a.k.a. constexpr char array),
we have to make sure to support that for size() and char_data().

Along the way I picked up another piece of template magic too,
to make put() not fail in one instance. As a nice side effect,
this allows us to get rid of the function_traits file.
I'm still only beginning to understand how it could possibly work,
but it seems to be more robust than the previous one.

4 years agoRename non_char_array to non_char_ptr.
Jakob Petsovits [Thu, 24 Dec 2015 08:16:59 +0000 (03:16 -0500)]
Rename non_char_array to non_char_ptr.

That's what it really is, and that's what out SFINAE is
protecting against to avoid the wrong overload from being called.

We're actually sort of fine with actual char arrays.
See next commit.

4 years agoFix decode_tail() logic for base32 and base64.
Jakob Petsovits [Thu, 24 Dec 2015 08:10:54 +0000 (03:10 -0500)]
Fix decode_tail() logic for base32 and base64.

Now, we'll rightfully complain and output the right data if
someone gives us an incorrect number of symbols in the last,
incomplete block.

It also looks much nicer this way.

4 years agoSwitch from `unsigned char` to `uint8_t` everywhere.
Jakob Petsovits [Thu, 24 Dec 2015 04:02:25 +0000 (23:02 -0500)]
Switch from `unsigned char` to `uint8_t` everywhere.

It's shorter, more expressive, better specified, and otherwise
defined to unsigned char on all platforms I'm aware of.

4 years agoRemove unnecessary includes.
Jakob Petsovits [Thu, 24 Dec 2015 03:50:21 +0000 (22:50 -0500)]
Remove unnecessary includes.

4 years agoAdd a TODO file until we're on GitHub and I can switch to issues.
Jakob Petsovits [Thu, 24 Dec 2015 03:42:29 +0000 (22:42 -0500)]
Add a TODO file until we're on GitHub and I can switch to issues.

4 years agoImplement hex via stream_codec, i.e. decode "0F" but not "F".
Jakob Petsovits [Thu, 24 Dec 2015 03:37:37 +0000 (22:37 -0500)]
Implement hex via stream_codec, i.e. decode "0F" but not "F".

4 years agoRefine base32 accepted characters, rename crockstr to crockford.
Jakob Petsovits [Thu, 24 Dec 2015 02:53:25 +0000 (21:53 -0500)]
Refine base32 accepted characters, rename crockstr to crockford.

For naming, I decided to let place-based single number codecs
have the original octet-streaming name plus "_num" appended.
Because they're an edge case, they'll perform worse, and they
people shouldn't be encouraged to use them. A slightly
inconvenient suffix will do that and make the rest of the names
easier to read and come up with.

As for accepted characters, Crockford base32 was missing special
treatment for 'OoIiLl' and RFC 4648 base32 was not accepting
lower-case characters, although it should. Both are now fixed.

README.txt got a bit of a rewrite for codec variants so all of
the codecs are now listed and with hopefully better explanations.

4 years agoActually implement the size_t return value as stated in README.md.
Jakob Petsovits [Wed, 23 Dec 2015 22:53:46 +0000 (17:53 -0500)]
Actually implement the size_t return value as stated in README.md.

This also shows that some encode()/decode() overloads have not
been exercised yet. Need to add testing soon.

4 years agoAdd base64 codec with variants base64_rfc4648 and base64_url.
Jakob Petsovits [Wed, 23 Dec 2015 22:38:11 +0000 (17:38 -0500)]
Add base64 codec with variants base64_rfc4648 and base64_url.

4 years agoReadability: Only access a single variable after block processing.
Jakob Petsovits [Wed, 23 Dec 2015 22:30:34 +0000 (17:30 -0500)]
Readability: Only access a single variable after block processing.

It behaves the same way, but if you only have to deal with a
single variable then that's less confusing.

4 years agoMake index lookups and alphabet arrays safer.
Jakob Petsovits [Wed, 23 Dec 2015 22:27:51 +0000 (17:27 -0500)]
Make index lookups and alphabet arrays safer.

4 years agoFix header guard name (was ...BASE4648 instead of ...RFC4648).
Jakob Petsovits [Wed, 23 Dec 2015 22:26:47 +0000 (17:26 -0500)]
Fix header guard name (was ...BASE4648 instead of ...RFC4648).

4 years agoWrite the print output lines a bit more compactly.
Jakob Petsovits [Wed, 23 Dec 2015 22:26:11 +0000 (17:26 -0500)]
Write the print output lines a bit more compactly.

4 years agoFactor out the codec framework into a stream_codec class.
Jakob Petsovits [Wed, 23 Dec 2015 19:33:36 +0000 (14:33 -0500)]
Factor out the codec framework into a stream_codec class.

This way, the actual codec only has to provide codec variants
plus the {encode,decode}_{block,tail}() and pad() functions.
Encoded/decoded sizes and loops are implemented based on
the codec's binary and encoded block sizes.

This should make it very easy to support other stream codecs
as well, base64 being the obvious example.

4 years agoAdd standard base32 from RFC 4648, introducing base32 variants.
Jakob Petsovits [Wed, 23 Dec 2015 08:12:14 +0000 (03:12 -0500)]
Add standard base32 from RFC 4648, introducing base32 variants.

We now handle (via templates) alphabets including padding and
ignored whitespace characters, as well as a variant option to
generate/require padding characters. Left-padding variants
(a.k.a. place-based single number encoding systems) are still
not supported at this time.

Sharing virtually the entire encoding/decoding logic between the
base32 variants greatly increases confidence that Crockford base32
(concatenative iterative stream interpretation) might actually
be correct. Plus it matches agnoster/base32-js on GitHub. Yay.

4 years agoAlso accept decoded sizes smaller than the max size, not only equal.
Jakob Petsovits [Wed, 23 Dec 2015 07:46:28 +0000 (02:46 -0500)]
Also accept decoded sizes smaller than the max size, not only equal.

4 years agoInitial commit of cppcodec.
Jakob Petsovits [Tue, 22 Dec 2015 19:46:50 +0000 (14:46 -0500)]
Initial commit of cppcodec.

It's starting out with a README.md that contains a pretty
comprehensive documentation of the API and design choices,
plus a first crack at implementing Crockford base32 within
that framework.

The base32 implementation might be incorrect and will have to
be verified/tested, however it exercises all the infrastructure
to go from app to (templated) interface to codec. So adding more
codecs should be fairly straightforward without too much effort.