Monero
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
qrcodegen::QrCode Class Referencefinal

#include <QrCode.hpp>

Public Types

enum  Ecc { Ecc::LOW = 0, Ecc::MEDIUM, Ecc::QUARTILE, Ecc::HIGH }
 

Public Member Functions

 QrCode (int ver, Ecc ecl, const std::vector< std::uint8_t > &dataCodewords, int msk)
 
int getVersion () const
 
int getSize () const
 
Ecc getErrorCorrectionLevel () const
 
int getMask () const
 
bool getModule (int x, int y) const
 
std::string toSvgString (int border) const
 

Static Public Member Functions

static QrCode encodeText (const char *text, Ecc ecl)
 
static QrCode encodeBinary (const std::vector< std::uint8_t > &data, Ecc ecl)
 
static QrCode encodeSegments (const std::vector< QrSegment > &segs, Ecc ecl, int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true)
 

Static Public Attributes

static constexpr int MIN_VERSION = 1
 
static constexpr int MAX_VERSION = 40
 

Private Member Functions

void drawFunctionPatterns ()
 
void drawFormatBits (int msk)
 
void drawVersion ()
 
void drawFinderPattern (int x, int y)
 
void drawAlignmentPattern (int x, int y)
 
void setFunctionModule (int x, int y, bool isBlack)
 
bool module (int x, int y) const
 
std::vector< std::uint8_taddEccAndInterleave (const std::vector< std::uint8_t > &data) const
 
void drawCodewords (const std::vector< std::uint8_t > &data)
 
void applyMask (int msk)
 
long getPenaltyScore () const
 
std::vector< int > getAlignmentPatternPositions () const
 
int finderPenaltyCountPatterns (const std::array< int, 7 > &runHistory) const
 
int finderPenaltyTerminateAndCount (bool currentRunColor, int currentRunLength, std::array< int, 7 > &runHistory) const
 
void finderPenaltyAddHistory (int currentRunLength, std::array< int, 7 > &runHistory) const
 

Static Private Member Functions

static int getFormatBits (Ecc ecl)
 
static int getNumRawDataModules (int ver)
 
static int getNumDataCodewords (int ver, Ecc ecl)
 
static std::vector< std::uint8_treedSolomonComputeDivisor (int degree)
 
static std::vector< std::uint8_treedSolomonComputeRemainder (const std::vector< std::uint8_t > &data, const std::vector< std::uint8_t > &divisor)
 
static std::uint8_t reedSolomonMultiply (std::uint8_t x, std::uint8_t y)
 
static bool getBit (long x, int i)
 

Private Attributes

int version
 
int size
 
Ecc errorCorrectionLevel
 
int mask
 
std::vector< std::vector< bool > > modules
 
std::vector< std::vector< bool > > isFunction
 

Static Private Attributes

static const int PENALTY_N1 = 3
 
static const int PENALTY_N2 = 3
 
static const int PENALTY_N3 = 40
 
static const int PENALTY_N4 = 10
 
static const std::int8_t ECC_CODEWORDS_PER_BLOCK [4][41]
 
static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS [4][41]
 

Member Enumeration Documentation

◆ Ecc

Enumerator
LOW 
MEDIUM 
QUARTILE 
HIGH 

Constructor & Destructor Documentation

◆ QrCode()

qrcodegen::QrCode::QrCode ( int  ver,
Ecc  ecl,
const std::vector< std::uint8_t > &  dataCodewords,
int  msk 
)

Member Function Documentation

◆ addEccAndInterleave()

vector< uint8_t > qrcodegen::QrCode::addEccAndInterleave ( const std::vector< std::uint8_t > &  data) const
private

◆ applyMask()

void qrcodegen::QrCode::applyMask ( int  msk)
private

◆ drawAlignmentPattern()

void qrcodegen::QrCode::drawAlignmentPattern ( int  x,
int  y 
)
private

◆ drawCodewords()

void qrcodegen::QrCode::drawCodewords ( const std::vector< std::uint8_t > &  data)
private

◆ drawFinderPattern()

void qrcodegen::QrCode::drawFinderPattern ( int  x,
int  y 
)
private

◆ drawFormatBits()

void qrcodegen::QrCode::drawFormatBits ( int  msk)
private

◆ drawFunctionPatterns()

void qrcodegen::QrCode::drawFunctionPatterns ( )
private

◆ drawVersion()

void qrcodegen::QrCode::drawVersion ( )
private

◆ encodeBinary()

QrCode qrcodegen::QrCode::encodeBinary ( const std::vector< std::uint8_t > &  data,
Ecc  ecl 
)
static

◆ encodeSegments()

QrCode qrcodegen::QrCode::encodeSegments ( const std::vector< QrSegment > &  segs,
Ecc  ecl,
int  minVersion = 1,
int  maxVersion = 40,
int  mask = -1,
bool  boostEcl = true 
)
static

◆ encodeText()

QrCode qrcodegen::QrCode::encodeText ( const char *  text,
Ecc  ecl 
)
static

◆ finderPenaltyAddHistory()

void qrcodegen::QrCode::finderPenaltyAddHistory ( int  currentRunLength,
std::array< int, 7 > &  runHistory 
) const
private

◆ finderPenaltyCountPatterns()

int qrcodegen::QrCode::finderPenaltyCountPatterns ( const std::array< int, 7 > &  runHistory) const
private

◆ finderPenaltyTerminateAndCount()

int qrcodegen::QrCode::finderPenaltyTerminateAndCount ( bool  currentRunColor,
int  currentRunLength,
std::array< int, 7 > &  runHistory 
) const
private

◆ getAlignmentPatternPositions()

vector< int > qrcodegen::QrCode::getAlignmentPatternPositions ( ) const
private

◆ getBit()

bool qrcodegen::QrCode::getBit ( long  x,
int  i 
)
staticprivate

◆ getErrorCorrectionLevel()

QrCode::Ecc qrcodegen::QrCode::getErrorCorrectionLevel ( ) const

◆ getFormatBits()

int qrcodegen::QrCode::getFormatBits ( Ecc  ecl)
staticprivate

◆ getMask()

int qrcodegen::QrCode::getMask ( ) const

◆ getModule()

bool qrcodegen::QrCode::getModule ( int  x,
int  y 
) const

◆ getNumDataCodewords()

int qrcodegen::QrCode::getNumDataCodewords ( int  ver,
Ecc  ecl 
)
staticprivate

◆ getNumRawDataModules()

int qrcodegen::QrCode::getNumRawDataModules ( int  ver)
staticprivate

◆ getPenaltyScore()

long qrcodegen::QrCode::getPenaltyScore ( ) const
private

◆ getSize()

int qrcodegen::QrCode::getSize ( ) const

◆ getVersion()

int qrcodegen::QrCode::getVersion ( ) const

◆ module()

bool qrcodegen::QrCode::module ( int  x,
int  y 
) const
private

◆ reedSolomonComputeDivisor()

vector< uint8_t > qrcodegen::QrCode::reedSolomonComputeDivisor ( int  degree)
staticprivate

◆ reedSolomonComputeRemainder()

vector< uint8_t > qrcodegen::QrCode::reedSolomonComputeRemainder ( const std::vector< std::uint8_t > &  data,
const std::vector< std::uint8_t > &  divisor 
)
staticprivate

◆ reedSolomonMultiply()

uint8_t qrcodegen::QrCode::reedSolomonMultiply ( std::uint8_t  x,
std::uint8_t  y 
)
staticprivate

◆ setFunctionModule()

void qrcodegen::QrCode::setFunctionModule ( int  x,
int  y,
bool  isBlack 
)
private

◆ toSvgString()

std::string qrcodegen::QrCode::toSvgString ( int  border) const

Member Data Documentation

◆ ECC_CODEWORDS_PER_BLOCK

const int8_t qrcodegen::QrCode::ECC_CODEWORDS_PER_BLOCK
staticprivate
Initial value:
= {
{-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
{-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28},
{-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
{-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
}

◆ errorCorrectionLevel

Ecc qrcodegen::QrCode::errorCorrectionLevel
private

◆ isFunction

std::vector<std::vector<bool> > qrcodegen::QrCode::isFunction
private

◆ mask

int qrcodegen::QrCode::mask
private

◆ MAX_VERSION

constexpr int qrcodegen::QrCode::MAX_VERSION = 40
static

◆ MIN_VERSION

constexpr int qrcodegen::QrCode::MIN_VERSION = 1
static

◆ modules

std::vector<std::vector<bool> > qrcodegen::QrCode::modules
private

◆ NUM_ERROR_CORRECTION_BLOCKS

const int8_t qrcodegen::QrCode::NUM_ERROR_CORRECTION_BLOCKS
staticprivate
Initial value:
= {
{-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25},
{-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49},
{-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68},
{-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81},
}

◆ PENALTY_N1

const int qrcodegen::QrCode::PENALTY_N1 = 3
staticprivate

◆ PENALTY_N2

const int qrcodegen::QrCode::PENALTY_N2 = 3
staticprivate

◆ PENALTY_N3

const int qrcodegen::QrCode::PENALTY_N3 = 40
staticprivate

◆ PENALTY_N4

const int qrcodegen::QrCode::PENALTY_N4 = 10
staticprivate

◆ size

int qrcodegen::QrCode::size
private

◆ version

int qrcodegen::QrCode::version
private

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