-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface for C++17 string_view (2.rc.02)
- Loading branch information
1 parent
e1b8707
commit 2ca8b88
Showing
4 changed files
with
150 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
WARNINGS= \ | ||
-Werror \ | ||
-Wall \ | ||
-Wextra \ | ||
-pedantic \ | ||
-Wcast-align \ | ||
-Wcast-qual \ | ||
-Wctor-dtor-privacy \ | ||
-Wdisabled-optimization \ | ||
-Wformat=2 \ | ||
-Winit-self \ | ||
-Wlogical-op \ | ||
-Wmissing-include-dirs \ | ||
-Wnoexcept \ | ||
-Wold-style-cast \ | ||
-Woverloaded-virtual \ | ||
-Wredundant-decls \ | ||
-Wshadow \ | ||
-Wsign-promo \ | ||
-Wstrict-null-sentinel \ | ||
-Wstrict-overflow=5 \ | ||
-Wundef \ | ||
-Wno-unused \ | ||
-Wno-variadic-macros \ | ||
-Wno-parentheses \ | ||
-fdiagnostics-show-option | ||
|
||
test: base64-test-11 base64-test-17 | ||
base64-test-11 | ||
base64-test-17 | ||
|
||
base64-test-11: base64-11.o test-11.o | ||
g++ base64-11.o test-11.o -o $@ | ||
|
||
base64-test-17: base64-17.o test-17.o | ||
g++ base64-17.o test-17.o -o $@ | ||
|
||
base64-11.o: base64.cpp base64.h | ||
g++ -std=c++11 $(WARNINGS) -c base64.cpp -o base64-11.o | ||
|
||
base64-17.o: base64.cpp base64.h | ||
g++ -std=c++17 $(WARNINGS) -c base64.cpp -o base64-17.o | ||
|
||
test-11.o: test.cpp | ||
g++ -std=c++11 $(WARNINGS) -c test.cpp -o test-11.o | ||
|
||
test-17.o: test.cpp | ||
g++ -std=c++17 $(WARNINGS) -c test.cpp -o test-17.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
// | ||
// base64 encoding and decoding with C++. | ||
// Version: 2.rc.01 (release candidate) | ||
// Version: 2.rc.02 (release candidate) | ||
// | ||
|
||
#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A | ||
#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A | ||
|
||
#include <string> | ||
|
||
#if __cplusplus >= 201703L | ||
#include <string_view> | ||
#endif // __cplusplus >= 201703L | ||
|
||
std::string base64_encode (std::string const& s, bool url = false); | ||
std::string base64_encode_pem (std::string const& s); | ||
std::string base64_encode_mime(std::string const& s); | ||
|
||
std::string base64_decode(std::string const& s, bool remove_linebreaks = false); | ||
std::string base64_encode(unsigned char const*, unsigned int len, bool url = false); | ||
|
||
#if __cplusplus >= 201703L | ||
// | ||
// Interface with std::string_view rather than const std::string& | ||
// Requires C++17 | ||
// Provided by Yannic Bonenberger (https://github.com/Yannic) | ||
// | ||
std::string base64_encode (std::string_view s, bool url = false); | ||
std::string base64_encode_pem (std::string_view s); | ||
std::string base64_encode_mime(std::string_view s); | ||
|
||
std::string base64_decode(std::string_view s, bool remove_linebreaks = false); | ||
#endif // __cplusplus >= 201703L | ||
|
||
#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters