Skip to content

Commit

Permalink
Add 'cppcodec' package (ruslo#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbsheth authored and ruslo committed Dec 19, 2018
1 parent c035cad commit 8c4a3bb
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ hunter_default_version(clBLAS VERSION 2.10.0-p0)
hunter_default_version(convertutf VERSION 1.0.1)
hunter_default_version(corrade VERSION v2018.10)
hunter_default_version(cpp_redis VERSION 3.5.0-h1)
hunter_default_version(cppcodec VERSION 0.2-p0)
hunter_default_version(cpr VERSION 1.3.0)
hunter_default_version(crashpad VERSION v0.0.1-p0)
hunter_default_version(crashup VERSION 0.0.2)
Expand Down
31 changes: 31 additions & 0 deletions cmake/projects/cppcodec/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2016-2018, Ruslan Baratov
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_cmake_args)
include(hunter_download)
include(hunter_pick_scheme)

hunter_add_version(
PACKAGE_NAME
cppcodec
VERSION
0.2-p0
URL
"https://github.com/hunter-packages/cppcodec/archive/v0.2-p0.tar.gz"
SHA1
9c52a769670a0fec4fc524fc036fa792fbb3e22e
)

hunter_cmake_args(
cppcodec
CMAKE_ARGS
BUILD_TESTING=OFF
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)
hunter_cacheable(cppcodec)
hunter_download(PACKAGE_NAME cppcodec)
21 changes: 21 additions & 0 deletions docs/packages/pkg/cppcodec.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. spelling::

cppcodec

.. index::
single: crypto base; cppcodec

.. _pkg.cppcodec:

cppcodec
========

- `Official <https://github.com/tplgy/cppcodec>`__
- `Hunterized <https://github.com/hunter-packages/cppcodec>`__
- `Example <https://github.com/ruslo/hunter/blob/master/examples/cppcodec/CMakeLists.txt>`__
- Added by `Rahul Sheth <https://github.com/rbsheth>`__ (`pr-1676 <https://github.com/ruslo/hunter/pull/1676>`__)

.. literalinclude:: /../examples/cppcodec/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }
18 changes: 18 additions & 0 deletions examples/cppcodec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2016-2018, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.2)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-cppcodec)

# DOCUMENTATION_START {
hunter_add_package(cppcodec)
find_package(cppcodec CONFIG REQUIRED)

add_executable(boo boo.cpp)
target_link_libraries(boo PUBLIC cppcodec::cppcodec)
# DOCUMENTATION_END }
39 changes: 39 additions & 0 deletions examples/cppcodec/boo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* This is free and unencumbered software released into the public domain.
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/

#include <cppcodec/base32_crockford.hpp>
#include <cppcodec/base64_rfc4648.hpp>
#include <iostream>

int main() {
using base32 = cppcodec::base32_crockford;
using base64 = cppcodec::base64_rfc4648;

std::vector<uint8_t> decoded = base64::decode("YW55IGNhcm5hbCBwbGVhc3VyZQ==");
std::cout << "decoded size (\"any carnal pleasure\"): " << decoded.size() << '\n';
std::cout << base32::encode(decoded) << std::endl; // "C5Q7J833C5S6WRBC41R6RSB1EDTQ4S8"
return 0;
}

0 comments on commit 8c4a3bb

Please sign in to comment.