logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

FBB::IBase64Buf - Input Filtering stream buffer doing base64 conversion

Author

       Frank B. Brokken (f.b.brokken@rug.nl).

libbobcat-dev_6.07.01                               2005-2025                           FBB::IBase64Buf(3bobcat)

Bobcat

       Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

Bobcat Project Files

       o      https://fbb-git.gitlab.io/bobcat/: gitlab project page;

       Debian Bobcat project files:

       o      libbobcat6: debian package containing the shared library, changelog and copyright note;

       o      libbobcat-dev:  debian package containing the static library, headers, manual pages, and developer
              info;

Bugs

       None reported.

Constructor

       o      IBase64Buf<CryptType>(std::istream&in,size_tbufSize=1000):
              This constructor initializes the streambuf.

              - IBase64Buf<ENCRYPT> objects perform base64 encoding;
              - IBase64Buf<DECRYPT> objects perform base64 decoding;
              - IBase64Buf<CryptType> objects obtain the bytes to encode or decode from std::istream&in;
              -  The  IFilterBuf base class is initialized with a buffer of size bufSize, using a lower bound of
              100.

              The constructor uses a configurable buffer size for reading. Characters that were  read  into  the
              buffer  but  are  not  part of the actual base64 encoded data are unavailable after completing the
              base64 decrypting. If information beyond the base64 input  block  should  remain  available,  then
              specify a buffer size of 1.

       Copy and move constructors (and assignment operators) are not available.

Description

       The information made available by IBase64Buf objects has been subject to base64 encoding or decoding. The
       information to be converted is made available to IBase64Buf object via std::istream objects.

       The  classIBase64Buf is a class template, using a FBB::CryptType template non-type parameter. Objects of
       the class FBB::IBase64Buf<FBB::ENCRYPT> base64 encode the information they receive, objects of the  class
       FBB::IBase64Buf<FBB::DECRYPT>  base64  decode  the information they receive. See also section ENUMERATION
       below.

Enumeration

IBase64Buf  objects  either  base64  encode  or  decode  information.  IBase64Buf  objects  of  the class
       FBB::IBase64Buf<FBB::ENCRYPT> base64 encode the data  they  receive,  IBase64Buf  objects  of  the  class
       FBB::IBase64Buf<FBB::DECRYPT> base64 decode the data they receive.

       The values ENCRYPT and DECRYPT are defined in the enumCryptType, which is defined in the FBB namespace.

Example

       The  example  shows the construction of IBase64Buf<ENCRYPT> objects encode which are used to initialize a
       std::istream object. The information read from this istream is base64 encoded.

       IBase64Buf<DECRYPT> objects (decode reads  base64  encoded  information  from  std::istream  objects  and
       decodes it again).

       The  std::istreamdin object is initialized with the IBase64Buf<DECRYPT> object, and its content is sent
       to std::cout. The information that is presented at std::cin and  that  appears  at  std::cout  should  be
       identical.

       #include <iostream>
       #include <istream>

       #include <bobcat/ibase64buf>

       using namespace std;
       using namespace FBB;

       int main(int argc, char **argv)
       {
           switch (argv[1][0])
           {
               case ’e’:
               {
                   IBase64Buf<ENCRYPT> encode(cin);
                   istream ein(&encode);
                   cout << ein.rdbuf();
               }
               break;

               case ’d’:
               {
                   IBase64Buf<DECRYPT> decode(cin);
                   istream din(&decode);
                   cout << din.rdbuf();
               }
               break;

               case ’b’:
               {
                   IBase64Buf<ENCRYPT> encode(cin);
                   istream ein(&encode);

                   IBase64Buf<DECRYPT> decode(ein);
                   istream din(&decode);
                   cout << din.rdbuf();
               }
               break;

               default:
                   cout << "Usage: " << argv[0] << " [edb] < infile > outfile\n"
                           "to base64 -e-ncode, -d-ecode or -b-oth\n";
               break;
           }
       }

Files

bobcat/ibase64buf - defines the class interface

Inherits From

FBB::IFilterBuf

Member Functions

       All members of FBB::IFilterBuf are available, as IBase64Buf inherits from this class.

Name

       FBB::IBase64Buf - Input Filtering stream buffer doing base64 conversion

Namespace

FBB
       All constructors, members, operators and manipulators, mentioned in this man-page,  are  defined  in  the
       namespace FBB.

See Also

bobcat(7), isymcryptstreambuf(3bobcat), ibase64stream(3bobcat), ifilterbuf(3bobcat), ofilterbuf(3bobcat),
       std::streambuf.

Synopsis

#include<bobcat/ibase64buf>
       Linking option: -lbobcat

See Also