libDwm-0.9.45
DwmBase64.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2018
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMBASE64_HH_
42#define _DWMBASE64_HH_
43
44#include <iostream>
45#include <string>
46
47namespace Dwm {
48
49 //--------------------------------------------------------------------------
52 //--------------------------------------------------------------------------
53 class Base64
54 {
55 public:
56 //------------------------------------------------------------------------
58 //------------------------------------------------------------------------
59 static std::string Encode(const std::string & s);
60
61 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
65 static std::string Decode(const std::string & s);
66
67 //------------------------------------------------------------------------
70 //------------------------------------------------------------------------
71 static std::ostream & Encode(std::istream & is, std::ostream & os);
72
73 //------------------------------------------------------------------------
78 //------------------------------------------------------------------------
79 static std::ostream & Decode(std::istream & is, std::ostream & os);
80 };
81
82 //--------------------------------------------------------------------------
85 //--------------------------------------------------------------------------
87 {
88 public:
89 //------------------------------------------------------------------------
91 //------------------------------------------------------------------------
92 static std::string Encode(const std::string & s);
93
94 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 static std::string Decode(const std::string & s);
99
100 //------------------------------------------------------------------------
103 //------------------------------------------------------------------------
104 static std::ostream & Encode(std::istream & is, std::ostream & os);
105
106 //------------------------------------------------------------------------
111 //------------------------------------------------------------------------
112 static std::ostream & Decode(std::istream & is, std::ostream & os);
113 };
114
115} // namespace Dwm
116
117#endif // _DWMBASE64_HH_
118
119
120//---------------------------- emacs settings -----------------------------
121// Local Variables:
122// mode: C++
123// tab-width: 2
124// indent-tabs-mode: nil
125// c-basic-offset: 2
126// End:
127//-------------------------------------------------------------------------
RFC 4648 base64 enconding and decoding functions for URLs.
Definition DwmBase64.hh:87
static std::ostream & Encode(std::istream &is, std::ostream &os)
Base64url encodes the contents of istream is into the ostream @ c os.
static std::ostream & Decode(std::istream &is, std::ostream &os)
Decodes the base64url encoded contents of istream is into the ostream os.
static std::string Encode(const std::string &s)
Returns a base64url encoded version of s.
static std::string Decode(const std::string &s)
Returns a decoded string for the base64url-encoded string s on success, an empty string on failure.
RFC 4648 base64 encoding and decoding functions.
Definition DwmBase64.hh:54
static std::ostream & Decode(std::istream &is, std::ostream &os)
Decodes the base64 encoded contents of istream is into the ostream os.
static std::ostream & Encode(std::istream &is, std::ostream &os)
Base64 encodes the contents of istream is into the ostream @ c os.
static std::string Decode(const std::string &s)
Returns a decoded string for the base64-encoded string s on success, an empty string on failure.
static std::string Encode(const std::string &s)
Returns a base64 encoded version of s.