20 months agoMerge pull request #65 from jpetso/master master
Jakob Petsovits [Sun, 25 Nov 2018 06:26:45 +0000 (01:26 -0500)]
Merge pull request #65 from jpetso/master

Fix a recent warning and ensure inlining for less-smart compilers.

20 months agoAdd CPPCODEC_ALWAYS_INLINE statements to raw_result_buffer. 65/head
Jakob Petsovits [Sun, 25 Nov 2018 03:14:17 +0000 (22:14 -0500)]
Add CPPCODEC_ALWAYS_INLINE statements to raw_result_buffer.

This should make sure it doesn't suffer from unnecessary slowness.
The good news is that GCC and Clang release builds don't seem to
be noticeably affected by this change, they must have already
done the right thing (inlining) beforehand. Nonetheless, compilers
with less predictive skill may get a speed-up from this.

Also, remove raw_result_buffer::last() because it's not needed
and makes it look like it's necessary for data wrappers, which
it's not.

20 months agoFix #59: Unreachable code warning in the padder class.
Jakob Petsovits [Sun, 25 Nov 2018 04:26:37 +0000 (23:26 -0500)]
Fix #59: Unreachable code warning in the padder class.

By taking the padding character put call out of the tail() function
and appending it after the tail() call in encode(), the compiler
will work with a more limited set of numbers known at runtime
instead of a slightly longer list of consecutive numbers at
compile time. The code paths that would cause an unreachable code
warning are now actually removed and would also be impossible
to tell in advance by the compiler.

Code sizes remain the same for clang as well as gcc in all
but debug builds, where they only marginally differ.

What's weird is that this change makes my GCC 8.2 release build
perform better on the "Decoding to vector<uint8_t>" benchmark -
weird because none of the changed code is called by any decode()
code paths. But hey, I'll take it. Average time for this task
go down from approx. 67 microseconds for the size 32768 buffer
to approx. 54 microseconds on my machine. Clang appears unaffected.

20 months agoMerge pull request #64 from jbzdarkid/patch-1
Jakob Petsovits [Wed, 14 Nov 2018 18:06:40 +0000 (13:06 -0500)]
Merge pull request #64 from jbzdarkid/patch-1

Fix comment referring to the wrong RFC encoding

20 months agoFix comment referring to the wrong RFC encoding 64/head
Joseph Blackman [Mon, 12 Nov 2018 23:12:24 +0000 (15:12 -0800)]
Fix comment referring to the wrong RFC encoding

This is "Base 32 Encoding with Extended Hex Alphabet"

21 months agoMerge pull request #63 from GabrieleFrau/master
Jakob Petsovits [Thu, 18 Oct 2018 15:51:50 +0000 (11:51 -0400)]
Merge pull request #63 from GabrieleFrau/master

Fix #62 - compile error when including <Windows.h> due to macro expansion

21 months agoFix #62 63/head
Gabriele_Frau [Wed, 17 Oct 2018 12:35:54 +0000 (14:35 +0200)]
Fix #62

<Windows.h> includes macro definitions named max and min, wrap the call to max and min with parentheses, which prevent the macro expansion

23 months agoMerge pull request #55 from jpetso/master v0.2
Jakob Petsovits [Mon, 20 Aug 2018 14:56:28 +0000 (10:56 -0400)]
Merge pull request #55 from jpetso/master

Update Catch to v2.3.0.

2 years agoUpdate Catch to v2.3.0. 55/head
Jakob Petsovits [Wed, 8 Aug 2018 17:14:47 +0000 (13:14 -0400)]
Update Catch to v2.3.0.

This changes the include path from <catch.hpp> to <catch2/catch.hpp>,
and gets rid of all remaining warnings on VS2017.
(VS2015 still emits a bunch of questionable warnings.)

2 years agoMerge pull request #54 from ndusart/cast
Jakob Petsovits [Wed, 8 Aug 2018 17:01:23 +0000 (13:01 -0400)]
Merge pull request #54 from ndusart/cast

cast int const to alphabet_index_t type

2 years agocast int const to alphabet_index_t type 54/head
Nicolas Dusart [Tue, 7 Aug 2018 12:40:22 +0000 (14:40 +0200)]
cast int const to alphabet_index_t type

clang fail to build without this static_cast

2 years agoMerge pull request #51 from jpetso/master
Jakob Petsovits [Thu, 19 Jul 2018 14:38:43 +0000 (10:38 -0400)]
Merge pull request #51 from jpetso/master

Finishing touches for v0.2

2 years agoAdd a "Philosophy & trade-offs" section to the README. 51/head
Jakob Petsovits [Wed, 18 Jul 2018 15:55:15 +0000 (11:55 -0400)]
Add a "Philosophy & trade-offs" section to the README.

Inspired by issue #52 and earlier discussions.

2 years agoAdd an example for wrapping types, into a new example/ directory.
Jakob Petsovits [Wed, 18 Jul 2018 06:29:02 +0000 (02:29 -0400)]
Add an example for wrapping types, into a new example/ directory.

Move the Hello World example into that directory as well.

2 years agoReorder and slightly change AppVeyor build tasks.
Jakob Petsovits [Tue, 17 Jul 2018 16:18:50 +0000 (12:18 -0400)]
Reorder and slightly change AppVeyor build tasks.

I'm including more Release and less MinSizeRel builds.
The total of 7 build tasks is retained.

2 years agoUn-recommend the baseNN_default_* headers.
Jakob Petsovits [Sun, 15 Jul 2018 13:44:06 +0000 (09:44 -0400)]
Un-recommend the baseNN_default_* headers.

They introduce complexity, make autocompletion more cumbersome,
and shouldn't be included in other header files because they
pollute the global namespace. If people copy base64 code from
one file to the other, the meaning of the code can change based
on which default header is included, which is not great.

I thought they added convenience, but actually, including them
makes cppcodec worse (probably).

So the first thing I can do is to stop recommending these headers.
The second thing will be to deprecate them. This may or may not
happen, I have to contemplate if the work inflicted on users for
changing header files outweighs the benefit of not having too many
"wrong" templates in other GitHub projects.

Either way, no new default headers will be added to cppcodec.

2 years agoRemove bullet point about performance measurement from TODO.md.
Jakob Petsovits [Sun, 15 Jul 2018 13:16:40 +0000 (09:16 -0400)]
Remove bullet point about performance measurement from TODO.md.

We have a pretty good idea about performance now.

2 years agoBump the newest Clang to 6.0 for the Travis CI build matrix.
Jakob Petsovits [Tue, 17 Jul 2018 15:39:57 +0000 (11:39 -0400)]
Bump the newest Clang to 6.0 for the Travis CI build matrix.

2 years agoMerge pull request #50 from jpetso/extra_warnings
Jakob Petsovits [Tue, 17 Jul 2018 15:56:44 +0000 (11:56 -0400)]
Merge pull request #50 from jpetso/extra_warnings

Last bunch of warning-related fixes for now

2 years agoRevert stop_character_mask to a complement. 50/head
Jakob Petsovits [Mon, 16 Jul 2018 05:03:51 +0000 (01:03 -0400)]
Revert stop_character_mask to a complement.

Somehow this makes the MSVC build faster, so we want it.

This time without any more warnings (afaik), by appending
the "u" unsigned suffix to the hex mask for type compatibility.

2 years agoIn unit tests, specify exception types as const-ref to avoid Catch warnings.
Jakob Petsovits [Wed, 9 May 2018 15:52:23 +0000 (11:52 -0400)]
In unit tests, specify exception types as const-ref to avoid Catch warnings.

Discovered this warning by compiling with GCC 8.1.1.

2 years agoMerge pull request #49 from jpetso/extra_warnings
Jakob Petsovits [Mon, 16 Jul 2018 04:13:05 +0000 (00:13 -0400)]
Merge pull request #49 from jpetso/extra_warnings

More compiler warning maintenance, in addition to @thrimbor and @GTValentine patches.

2 years agoAdd -Wextra to non-MSVC, to catch unused variable warnings going forward. 49/head
Jakob Petsovits [Sat, 14 Jul 2018 13:47:30 +0000 (09:47 -0400)]
Add -Wextra to non-MSVC, to catch unused variable warnings going forward.

2 years agoStylistic changes for unused variables.
Jakob Petsovits [Sat, 14 Jul 2018 13:46:43 +0000 (09:46 -0400)]
Stylistic changes for unused variables.

2 years agoMerge pull request #48 from thrimbor/warning_reduction
Jakob Petsovits [Mon, 16 Jul 2018 03:33:46 +0000 (23:33 -0400)]
Merge pull request #48 from thrimbor/warning_reduction

Warning fixes

2 years agoDeleted unused parameters (#47)
Valentin [Mon, 16 Jul 2018 03:24:16 +0000 (20:24 -0700)]
Deleted unused parameters (#47)

Added /W4 option for MSVC, cleaned up some warnings.

2 years agoReplaced all C-style casts in access.hpp 48/head
Stefan Schmidt [Fri, 22 Jun 2018 20:46:17 +0000 (22:46 +0200)]
Replaced all C-style casts in access.hpp

2 years agoMerge pull request #45 from jpetso/master
Jakob Petsovits [Sat, 5 May 2018 15:19:20 +0000 (11:19 -0400)]
Merge pull request #45 from jpetso/master

Make cppcodec runtime performance competitive

2 years agoNow that cppcodec is viably fast, advertise this in the README. 45/head
Jakob Petsovits [Mon, 30 Apr 2018 06:21:53 +0000 (02:21 -0400)]
Now that cppcodec is viably fast, advertise this in the README.

Cross-platform and warning-free are also features these days
that I support on keeping. Mention those as well.

2 years agoChange the LICENSE file so GitHub will recognize and highlight its info.
Jakob Petsovits [Mon, 30 Apr 2018 05:57:49 +0000 (01:57 -0400)]
Change the LICENSE file so GitHub will recognize and highlight its info.

This includes changing it from LICENSE.txt to LICENSE,
and adding a more conventional copyright header instead of the
current, more verbose one.

One-time contributors are still listed with full copyright
in the individual codec variant files. I chose not to include
those here for maintainability reasons, but if you're one of them
and you'd like to show up in here as well, let me know and it
shall be done.

2 years agoImprove decode() performance by counting using pointers, not indexes.
Jakob Petsovits [Sun, 29 Apr 2018 19:28:22 +0000 (15:28 -0400)]
Improve decode() performance by counting using pointers, not indexes.

This makes a huge impact on MSVC/x64, which apparently had a
hard time optimizing the alphabet_indexes[current_index] access
syntax (which is really &alphabet_indexes[0] + current_index)
to something more efficient.

Other compilers get a minor improvement in benchmark numbers.
As follows (MinSizeRel build, benchmarked on my laptop):

Decoding to string (buffers of size 32768):
VS2017/Win32: previously 128, now 97 (default C++ standard)
VS2017/x64:   previously 340, now 88 (default C++ standard)
Clang 6/x64:  previously  74, now 80 (C++17)
GCC 7.3/x64:  previously  79, now 78

Decoding to vector<uint8_t>:
VS2017/Win32: previously  99, now 94
VS2017/x64:   previously 328, now 86
Clang 6/x64:  previously  72, now 78
GCC 7.3/x64:  previously  78, now 76

Clang is doing slightly worse after this patch, but not nearly
enough to veto this patch, given the massive VS2017 improvement.

As a bonus, here are current Release build numbers:
VS2017/Win32: enc 101, dec string 106 (gaspardpetit benchmark)
VS2017/x64:   enc  99, dec string 102 (gaspardpetit benchmark)
Clang 6/x64:  enc  93, dec string  73, dec vector<uint8_t> 73 (C++17)
GCC 7.3/x64:  enc  32, dec string  62, dec vector<uint8_t> 62 (C++17)

GCC Release comes out as a definitive winner here, beating the
Apache base64 implemention and the polfosol snippet by a few
microseconds in both the encoding benchmark, and Apache again
by a few microseconds in decoding as well, as measured by
gaspardpetit/base64 when built in the same Release build.

It's still about half as slow as the polfosol decoding snippet,
but then again, polfosol does not do any handling of special
cases whereas cppcodec handles zero termination characters,
throws on invalid (out of alphabet) characters and on
incorrect padding.

I had an earlier patch to reduce the number of checks but it
actually made things worse (probably due to increased code size)
so we'll leave it at this for now.

2 years agoCache the buffer pointer for direct_data_access_result_state.
Jakob Petsovits [Tue, 24 Apr 2018 04:54:16 +0000 (00:54 -0400)]
Cache the buffer pointer for direct_data_access_result_state.

result.data() may perform a calculation to retrieve the
buffer address. E.g. std::string (since C++11) will use
small string optimization, so it needs to check if it's
using allocated data or (ab)using its own member variables
interpreted as char array. Conditional code paths are
potentially slow so we now only do it once, at the start.

direct_data_access_result_state is used for std::string
for C++17 and later, as well as for std::vector.

Decoding to string (buffers of size 32768):
VS2017/Win32: previously 128, now 128 (default C++ standard)
VS2017/x64:   previously 340, now 340 (default C++ standard)
Clang 6/x64:  previously  74, now  74 (C++17)
GCC 7.3/x64:  previously  79, now  79

Decoding to vector<uint8_t>:
VS2017/Win32: previously 126, now  99
VS2017/x64:   previously 328, now 328
Clang 6/x64:  previously  72, now  72
GCC 7.3/x64:  previously  78, now  78

So not a ton of impact, but improved numbers for VS2017/Win32
without downsides, while everything else stays the same.
Less conditions in the generated code. Let's have it.

2 years agoSignificantly improve decoding performance by using a lookup table.
Jakob Petsovits [Mon, 2 Apr 2018 15:39:47 +0000 (11:39 -0400)]
Significantly improve decoding performance by using a lookup table.

I got myself a disassembler and looked at the generated code for
one call of the most basic decode variant (passing a raw pointer).
Once I found the function, it was immediately clear what was
slowing down decoding: A large number of comparisons from

Given this knowledge, the solution was also obvious:
We need a lookup table to replace the many char comparisons
with a single lookup operation. To avoid writing and maintaining
lookup tables for each codec variant, I decided to generate them
via templates and constexpr function calls. This ends up making
the API for codec variants simpler, CodecVariant::index_of() is
now not required or used anymore.

The actual implementation of this concept was a bit of a pain
with workarounds to satisfy all supported compilers.
It paid off in terms of performance though - all measurements
on my laptop (MinSizeRel configuration):

Decoding to string (buffers of size 32768):
VS2017/Win32: previously 490, now 128 (default C++ standard)
VS2017/x64:   previously 438, now 340 (default C++ standard)
Clang 6/x64:  previously 368, now  74 (C++17)
GCC 7.3/x64:  previously 342, now  79

Decoding to vector<uint8_t>:
VS2017/Win32: previously 483, now 126
VS2017/x64:   previously 447, now 328
Clang 6/x64:  previously 383, now  72
GCC 7.3/x64:  previously 347, now  78

The hex_base class is removed because lookup is now
autogenerated, so most of it was not necessary anymore
and the rest is folded into hex_lower/hex_upper.

Also included are additions of CPPCODEC_ALWAYS_INLINE to several
functions in base32 or hex, some of which I forgot to equip with
this modifier earlier. They're not currently being benchmarked
but this change ensures that they perform as well as base64.

2 years agoAdd #defines to benchmark_cppcodec to turn off individual benchmarks.
Jakob Petsovits [Sun, 29 Apr 2018 17:10:18 +0000 (13:10 -0400)]
Add #defines to benchmark_cppcodec to turn off individual benchmarks.

This sometimes comes in handy in debugging/disassembling when
you're only interested in a certain benchmark but not the others.

2 years agoCompile on MSVC with /std:c++17 even without /Zc:__cplusplus
Jakob Petsovits [Tue, 24 Apr 2018 04:34:17 +0000 (00:34 -0400)]
Compile on MSVC with /std:c++17 even without /Zc:__cplusplus

MSVC up to at least VS 2017 would define __cplusplus as 199711L
even when a different standard is passed as command line option,
because it hasn't been fully compatible with C++11 (and later)
requirements so far. To rectify this, they introduced another
option that fixes the __cplusplus macro, which is how AppVeyor
and others were able to build the code at all.

By adding an extra check for the Microsoft-specific macro
_MSVC_LANG, it's possible to build even without passing the
extra option.

See also:

2 years agoAdd a "minimal decode" executable to the test directory.
Jakob Petsovits [Tue, 24 Apr 2018 05:10:10 +0000 (01:10 -0400)]
Add a "minimal decode" executable to the test directory.

When diving into disassembly, it's useful to have an executable
that only deals with the one thing being tested. Makes it easier
to find stuff.

2 years agoFix #35: Improve MSVC performance by adding MSVC always-inline macro
Jakob Petsovits [Mon, 2 Apr 2018 05:48:10 +0000 (01:48 -0400)]
Fix #35: Improve MSVC performance by adding MSVC always-inline macro

GCC and Clang have long had this optimization, which reduces
function calls in the generated assembly for (template) code
that I wanted to make more modular but without introducing
actual physical indirections. For the Visual Studio compiler,
I hadn't previously been able to verify that it works so I
didn't hadn't incorporated this change until now.

For the current codebase, this makes a particularly large impact
on encoding performance. MSVC encoding runtime on my machine goes
down from 1.90 to 1.00 for buffer size 256, which is a 52%
reduction in time spent. Decoding on MSVC for the same buffer size
was 1.95 and is now 1.46, i.e. 25% less time than before.

It seems like MSVC (on Windows) is still slower than GCC or Clang
(on Linux) at least on my system, where my numbers for the same
benchmark were 0.85 for encoding and 0.80 for decoding according
to an earlier commit message. Travis's benchmark results are much
closer to the size-256 results for MSVC, which might be relevant
because my Linux numbers for large buffer sizes (size 32768) are
roughly similar to Travis's.

MSVC improvements for size 32768 are roughly proportional for
encoding (222 -> 98) but less pronounced for decoding (533 -> 498),
implying that the latter is still dragged down by something else.

2 years agoMerge pull request #44 from jpetso/master
Jakob Petsovits [Mon, 2 Apr 2018 13:02:37 +0000 (09:02 -0400)]
Merge pull request #44 from jpetso/master

Add an encoding/decoding benchmark to test/ and CI bots

2 years agoExecute test/benchmark_cppcodec on Travis and AppVeyor builds. 44/head
Jakob Petsovits [Sun, 1 Apr 2018 08:50:40 +0000 (04:50 -0400)]
Execute test/benchmark_cppcodec on Travis and AppVeyor builds.

We can't be sure if the resources for the builds are going to be
consistent, so performance numbers may not be comparable from one
build to another. However, they should get us a rough idea about
differences on an order of magnitude, and/or average out over
multiple builds. If things are going very wrong or very right,
the build bots will help provide indicators.

2 years agoAdd a benchmark to test runtime performance.
Jakob Petsovits [Sun, 1 Apr 2018 06:07:20 +0000 (02:07 -0400)]
Add a benchmark to test runtime performance.

Numbers are comparable to the gaspardpetit/base64 benchmark,
in which the runtime duration of encoding or decoding runs is
averaged out over many iterations (1 million or up to 0.5s,
whichever one is shorter). Code is all new.

Run test/benchmark_cppcodec without arguments to get numbers
for encoding to strings, decoding to strings and decoding to
vector<uint8_t> for base64_rfc4648.

This should be enough to test the performance fix for Windows
from #35. We can add command line options later, such as
selecting the codec or the set of decoded buffer sizes.

2 years agoAdd my copyright to files that I improved earlier this year.
Jakob Petsovits [Sat, 31 Mar 2018 18:31:51 +0000 (14:31 -0400)]
Add my copyright to files that I improved earlier this year.

2 years agoMerge pull request #43 from jpetso/master
Jakob Petsovits [Sat, 31 Mar 2018 17:49:35 +0000 (13:49 -0400)]
Merge pull request #43 from jpetso/master

Fix #41 (compile error), verify by adding C++17 builds to Travis

2 years agoUpdate Travis config to use Trusty and several C++11 standards 43/head
Jakob Petsovits [Sat, 31 Mar 2018 14:48:21 +0000 (10:48 -0400)]
Update Travis config to use Trusty and several C++11 standards

Since we're now on Trusty, there are more and cleaner options
for testing clang, so the test matrix is expanded by adding
several extra clang builds.

I tried to put in a good mix of C++11, C++14 and C++17 builds.
The former two ought to behave the same, whereas C++17 has a
change to std::string::data() which causes a different optimized
code path to be selected. Testing it with C++17 will verify the
build fix for #41 from my previous commit.

I also believe that passing the CMAKE_BUILD_TYPE didn't work for
selecting Debug/Release configurations, which is fixed now by
passing it as a command line argument instead of merely setting
an environment variable.

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.