nlib
nn::nlib::Base64InputStream Class Referencefinal

The class for reading Base64-encoded data. More...

#include "nn/nlib/Base64InputStream.h"

+ Inheritance diagram for nn::nlib::Base64InputStream:

Public Member Functions

errno_t Init (CharOption char_option) noexcept
 Initializes the object. For information on the arguments, see Base64Decoder::CharOption.
 
errno_t Init () noexcept
 Runs Init(Base64Decoder::kBase64Default).
 
- Public Member Functions inherited from nn::nlib::InputConverterStream
errno_t SetStream (InputStream *istr) noexcept
 Sets the input stream for reading the pre-converted data. More...
 
InputStreamGetStream () const noexcept
 Gets the input stream for reading the pre-converted data. More...
 
- Public Member Functions inherited from nn::nlib::InputStream
errno_t GetErrorValue () const noexcept
 Gets the error value. More...
 
size_t Pos () const noexcept
 Returns the current position in the stream. More...
 
uint64_t Pos64 () const noexcept
 Returns the current position in the stream as a 64-bit value. More...
 
bool IsEos () noexcept
 Returns true if the stream is finished being read through to the end. If the stream has not been read through to the end, or if an error occurs, the function returns false. More...
 
int Read () noexcept
 Reads one byte of data from the stream. More...
 
NLIB_CHECK_RESULT int Peek () noexcept
 Reads the next byte without consuming the stream. More...
 
size_t Skip (size_t nbytes) noexcept
 Skips over the number of bytes specified by nBytes. More...
 
size_t Read (void *ptr, size_t nbytes) noexcept
 Reads the number of bytes of data specified by nBytes into the memory region specified by ptr. More...
 
bool Close () noexcept
 Closes the stream. Returns true if successful. More...
 
 operator bool () const
 Returns true if no internal error has occurred.
 
constexpr InputStream () noexcept
 Instantiates the object. This function is called from the derived class.
 
virtual ~InputStream () noexcept
 Destructor. This function is called from the derived class.
 

Additional Inherited Members

- Protected Member Functions inherited from nn::nlib::InputStream
void ResetBuffer (void *p, size_t nbytes) noexcept
 Sets the buffer held by InputStream. More...
 
void SetError (errno_t e) const noexcept
 Sets an error to InputStream. More...
 

Detailed Description

The class for reading Base64-encoded data.

Description
InputConverterStream is held in the base class. When operating as InputStream, the read data is Base64-decoded and returned. The InputConverterStream::SetStream function sets a stream for reading Base64 strings, and then the stream is used.
If characters that have not been converted are read, the following behaviors take place.
  • If the characters are the CR, LF, space, or horizontal tab, they are skipped.
  • Other characters generate an error (EILSEQ).
The EILSEQ error is also generated if there are not enough '=' padding characters.
InputStream& is = ....;
Base64InputStream istr;
// Initialize.
if (nlib_is_error(istr.Init())) { ERROR; }
// Sets the stream from which data is read.
istr.SetStream(&is);
...
// Reads the 'istr' that used the InputStream interface.
...
// The destructor also calls the Close function, but errors cannot be checked.
if (nlib_is_error(istr.Close())) { ERROR; }
if (nlib_is_error(is.Close())) { ERROR; }
Note
Note that initialization with Init() is necessary on and after the 2015-01-26 version.
See also
https://www.ietf.org/rfc/rfc2045.txt (RFC2045, Base64)
The transition of the object state.
The overview of the object state transitions is described below:
dot_inline_dotgraph_3.png

Definition at line 24 of file Base64InputStream.h.


The documentation for this class was generated from the following files: