cpp-bencoding
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
bencoding::PrettyPrinter Class Reference

Pretty printer of data. More...

#include <PrettyPrinter.h>

Inheritance diagram for bencoding::PrettyPrinter:
bencoding::BItemVisitor

Public Member Functions

std::string getPrettyRepr (std::shared_ptr< BItem > data, const std::string &indent=" ")
 Returns a pretty representation of data. More...
 

Static Public Member Functions

static std::unique_ptr< PrettyPrintercreate ()
 Creates a new printer. More...
 

Private Member Functions

 PrettyPrinter ()
 Constructs a printer. More...
 
BItemVisitor Interface
virtual void visit (BDictionary *bDictionary) override
 
virtual void visit (BInteger *bInteger) override
 
virtual void visit (BList *bList) override
 
virtual void visit (BString *bString) override
 
Indentation
void storeCurrentIndent ()
 Stores the current indentation into prettyRepr. More...
 
void increaseIndentLevel ()
 Increases the current indentation by a single level. More...
 
void decreaseIndentLevel ()
 Decreases the current indentation by a single level. More...
 
- Private Member Functions inherited from bencoding::BItemVisitor
virtual ~BItemVisitor ()
 Destructs the visitor. More...
 
 BItemVisitor ()
 Constructs the visitor. More...
 

Private Attributes

std::string prettyRepr = ""
 Pretty representation of the data obtained so far. More...
 
std::string indentLevel = " "
 A single level of indentation. More...
 
std::string currentIndent = ""
 The current level of indentation. More...
 

Detailed Description

Pretty printer of data.

Can format data in a readable way.

Use create() to create instances.

Constructor & Destructor Documentation

◆ PrettyPrinter()

bencoding::PrettyPrinter::PrettyPrinter ( )
privatedefault

Constructs a printer.

Member Function Documentation

◆ create()

std::unique_ptr< PrettyPrinter > bencoding::PrettyPrinter::create ( )
static

Creates a new printer.

◆ decreaseIndentLevel()

void bencoding::PrettyPrinter::decreaseIndentLevel ( )
private

Decreases the current indentation by a single level.

◆ getPrettyRepr()

std::string bencoding::PrettyPrinter::getPrettyRepr ( std::shared_ptr< BItem data,
const std::string &  indent = "    " 
)

Returns a pretty representation of data.

Parameters
[in]dataData to return a pretty representation for.
[in]indentA single level of indentation.

◆ increaseIndentLevel()

void bencoding::PrettyPrinter::increaseIndentLevel ( )
private

Increases the current indentation by a single level.

◆ storeCurrentIndent()

void bencoding::PrettyPrinter::storeCurrentIndent ( )
private

Stores the current indentation into prettyRepr.

◆ visit() [1/4]

void bencoding::PrettyPrinter::visit ( BDictionary bDictionary)
overrideprivatevirtual

◆ visit() [2/4]

void bencoding::PrettyPrinter::visit ( BInteger bInteger)
overrideprivatevirtual

◆ visit() [3/4]

void bencoding::PrettyPrinter::visit ( BList bList)
overrideprivatevirtual

◆ visit() [4/4]

void bencoding::PrettyPrinter::visit ( BString bString)
overrideprivatevirtual

Member Data Documentation

◆ currentIndent

std::string bencoding::PrettyPrinter::currentIndent = ""
private

The current level of indentation.

◆ indentLevel

std::string bencoding::PrettyPrinter::indentLevel = " "
private

A single level of indentation.

◆ prettyRepr

std::string bencoding::PrettyPrinter::prettyRepr = ""
private

Pretty representation of the data obtained so far.


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