herald  2.0.0
base64_string.h
1 // Copyright 2020-2021 Herald Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #ifndef HERALD_BASE64_STRING_H
6 #define HERALD_BASE64_STRING_H
7 
8 #include "data.h"
9 
10 #include <string>
11 
12 namespace herald {
14 namespace datatype {
15 
18 class Base64String {
19 public:
20  Base64String(); // empty string initialiser
24  Base64String(const Base64String& other) = delete;
27 
29  static bool from(const std::string& original, Base64String& toInitialise) noexcept; // initialise from string
32  static Base64String encode(const Data& from) noexcept; // initialise from Data
33 
36  Data decode() const noexcept;
38  std::string encoded() const noexcept; // Return base64 string representation (copy of, not reference to)
39 private:
40  std::string value; // Base64 encoded, and guarded
41 };
42 
43 } // end namespace
44 } // end namespace
45 
46 #endif
Strongly, rather than stringly, typed representation of Base64 String data. Prevents incorrect initia...
Definition: base64_string.h:18
std::string encoded() const noexcept
Returns the Base64 encoding of this class as a std::string.
Base64String(const Base64String &other)=delete
Deleted copy constructor to prevent temporary memory use.
static bool from(const std::string &original, Base64String &toInitialise) noexcept
Populates a Base64String from a normal std::string.
static Base64String encode(const Data &from) noexcept
Creates a Base64String from an arbitrary set of bytes.
Data decode() const noexcept
Decodes this Base64String's content into a Data instance.
Base64String(Base64String &&other)
Move Constructor.
~Base64String()
Custom destructor.
The main data workhorse class of the Herald API.
Definition: data.h:33
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
Definition: data.h:562