libzypp  17.23.8
zypp::base::DrunkenBishop::Impl Class Reference

DrunkenBishop implementation. More...

Inheritance diagram for zypp::base::DrunkenBishop::Impl:

Public Member Functions

 Impl ()
 Default is an empty board. More...
 
void compute (const std::string &data_r, const std::string &title_r, unsigned height_r=Auto, unsigned width_r=Auto)
 Build up a new board. More...
 
std::ostream & dumpOn (std::ostream &str, const std::string &prefix_r, Options options_r) const
 Render board to a stream. More...
 

Static Public Member Functions

static shared_ptr< Implnullimpl ()
 Offer default Impl. More...
 

Private Member Functions

void move (Direction direction_r)
 Move Bishop from _e into direction_r and update the _board. More...
 
bool atTL () const
 Whether _e is in the top left corner. More...
 
bool atTR () const
 Whether _e is in the top right corner. More...
 
bool atBL () const
 Whether _e is in the bottom left corner. More...
 
bool atBR () const
 Whether _e is in the bottom right corner. More...
 
bool atT () const
 Whether _e is in the top row. More...
 
bool atB () const
 Whether _e is in the bottom row. More...
 
bool atL () const
 Whether _e is in the left column. More...
 
bool atR () const
 Whether _e is in the right column. More...
 
const char * color (std::uint8_t idx_r) const
 ANSI color heatmap. More...
 
std::ostream & renderTitleOn (std::ostream &str, const std::string &title_r) const
 Render non empty title strings. More...
 
std::ostream & renderOn (std::ostream &str, bool useColor_r, unsigned pos_r) const
 Render board numbers to printable chars. More...
 

Static Private Member Functions

static unsigned odd (unsigned val_r)
 Increment even width/height values. More...
 
static std::uint8_t bite (const char *&ch_r)
 Get next 4 moves (8 bit) from next 2 hex digits (1st digit != '\0' asserted, 0-pad if necessary). More...
 

Private Attributes

std::vector< std::uint8_t > _board
 the board More...
 
unsigned _h
 board height More...
 
unsigned _w
 board with More...
 
unsigned _s
 start position More...
 
unsigned _e
 end position More...
 
bool _renderSSH
 whether to render the ssh (or gpg) char set More...
 
std::string _fp
 fingerprint to render as bottom title More...
 
std::string _tt
 text to render as top title More...
 

Static Private Attributes

static constexpr const unsigned Auto = unsigned(-1)
 Request default width/height values. More...
 

Detailed Description

DrunkenBishop implementation.

Definition at line 71 of file DrunkenBishop.cc.

Constructor & Destructor Documentation

◆ Impl()

zypp::base::DrunkenBishop::Impl::Impl ( )
inline

Default is an empty board.

Definition at line 75 of file DrunkenBishop.cc.

Member Function Documentation

◆ compute()

void zypp::base::DrunkenBishop::Impl::compute ( const std::string &  data_r,
const std::string &  title_r,
unsigned  height_r = Auto,
unsigned  width_r = Auto 
)
inline

Build up a new board.

Exceptions
std::invalid_argument

Definition at line 86 of file DrunkenBishop.cc.

◆ dumpOn()

std::ostream& zypp::base::DrunkenBishop::Impl::dumpOn ( std::ostream &  str,
const std::string &  prefix_r,
Options  options_r 
) const
inline

Render board to a stream.

Definition at line 130 of file DrunkenBishop.cc.

◆ odd()

static unsigned zypp::base::DrunkenBishop::Impl::odd ( unsigned  val_r)
inlinestaticprivate

Increment even width/height values.

Definition at line 163 of file DrunkenBishop.cc.

◆ bite()

static std::uint8_t zypp::base::DrunkenBishop::Impl::bite ( const char *&  ch_r)
inlinestaticprivate

Get next 4 moves (8 bit) from next 2 hex digits (1st digit != '\0' asserted, 0-pad if necessary).

Exceptions
std::invalid_argumentif char is not a hex digit or 1st char is \0

Definition at line 169 of file DrunkenBishop.cc.

◆ move()

void zypp::base::DrunkenBishop::Impl::move ( Direction  direction_r)
inlineprivate

Move Bishop from _e into direction_r and update the _board.

Definition at line 179 of file DrunkenBishop.cc.

◆ atTL()

bool zypp::base::DrunkenBishop::Impl::atTL ( ) const
inlineprivate

Whether _e is in the top left corner.

Definition at line 235 of file DrunkenBishop.cc.

◆ atTR()

bool zypp::base::DrunkenBishop::Impl::atTR ( ) const
inlineprivate

Whether _e is in the top right corner.

Definition at line 239 of file DrunkenBishop.cc.

◆ atBL()

bool zypp::base::DrunkenBishop::Impl::atBL ( ) const
inlineprivate

Whether _e is in the bottom left corner.

Definition at line 243 of file DrunkenBishop.cc.

◆ atBR()

bool zypp::base::DrunkenBishop::Impl::atBR ( ) const
inlineprivate

Whether _e is in the bottom right corner.

Definition at line 247 of file DrunkenBishop.cc.

◆ atT()

bool zypp::base::DrunkenBishop::Impl::atT ( ) const
inlineprivate

Whether _e is in the top row.

Definition at line 251 of file DrunkenBishop.cc.

◆ atB()

bool zypp::base::DrunkenBishop::Impl::atB ( ) const
inlineprivate

Whether _e is in the bottom row.

Definition at line 255 of file DrunkenBishop.cc.

◆ atL()

bool zypp::base::DrunkenBishop::Impl::atL ( ) const
inlineprivate

Whether _e is in the left column.

Definition at line 259 of file DrunkenBishop.cc.

◆ atR()

bool zypp::base::DrunkenBishop::Impl::atR ( ) const
inlineprivate

Whether _e is in the right column.

Definition at line 263 of file DrunkenBishop.cc.

◆ color()

const char* zypp::base::DrunkenBishop::Impl::color ( std::uint8_t  idx_r) const
inlineprivate

ANSI color heatmap.

Definition at line 268 of file DrunkenBishop.cc.

◆ renderTitleOn()

std::ostream& zypp::base::DrunkenBishop::Impl::renderTitleOn ( std::ostream &  str,
const std::string &  title_r 
) const
inlineprivate

Render non empty title strings.

Definition at line 304 of file DrunkenBishop.cc.

◆ renderOn()

std::ostream& zypp::base::DrunkenBishop::Impl::renderOn ( std::ostream &  str,
bool  useColor_r,
unsigned  pos_r 
) const
inlineprivate

Render board numbers to printable chars.

Definition at line 322 of file DrunkenBishop.cc.

◆ nullimpl()

static shared_ptr<Impl> zypp::base::DrunkenBishop::Impl::nullimpl ( )
inlinestatic

Offer default Impl.

Definition at line 358 of file DrunkenBishop.cc.

Member Data Documentation

◆ Auto

constexpr const unsigned zypp::base::DrunkenBishop::Impl::Auto = unsigned(-1)
staticconstexprprivate

Request default width/height values.

Definition at line 342 of file DrunkenBishop.cc.

◆ _board

std::vector<std::uint8_t> zypp::base::DrunkenBishop::Impl::_board
private

the board

Definition at line 345 of file DrunkenBishop.cc.

◆ _h

unsigned zypp::base::DrunkenBishop::Impl::_h
private

board height

Definition at line 346 of file DrunkenBishop.cc.

◆ _w

unsigned zypp::base::DrunkenBishop::Impl::_w
private

board with

Definition at line 347 of file DrunkenBishop.cc.

◆ _s

unsigned zypp::base::DrunkenBishop::Impl::_s
private

start position

Definition at line 348 of file DrunkenBishop.cc.

◆ _e

unsigned zypp::base::DrunkenBishop::Impl::_e
private

end position

Definition at line 349 of file DrunkenBishop.cc.

◆ _renderSSH

bool zypp::base::DrunkenBishop::Impl::_renderSSH
private

whether to render the ssh (or gpg) char set

Definition at line 352 of file DrunkenBishop.cc.

◆ _fp

std::string zypp::base::DrunkenBishop::Impl::_fp
private

fingerprint to render as bottom title

Definition at line 353 of file DrunkenBishop.cc.

◆ _tt

std::string zypp::base::DrunkenBishop::Impl::_tt
private

text to render as top title

Definition at line 354 of file DrunkenBishop.cc.


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