From Crypto++ Wiki
Jump to navigation Jump to search
#include <cryptopp/filters.h>

A MeterFilter is a filter which counts the number of bytes processed by the filter.

Sources, filters and sinks are discussed at Pipelining. The pipeline article explains the design and shows you how to use them.

Sample Programs

The sample below demonstrates use of a MeterFilter and Redirector to count the number of bytes output by the HexEncoder and subsequently input to the StringSink.

byte data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };

string encoded;
MeterFilter meter( new StringSink( encoded ) );

ArraySource( data, sizeof( data ), true,
    new HexEncoder(
        new Redirector( meter ),
        true /*UCase*/, 2 /*Group*/,
        " " /*Separator*/

cout << "processed " << meter.GetTotalBytes() << " bytes" << endl;
cout << encoded << endl;

Output: Processed 23 bytes
00 01 02 03 04 05 06 07