BigDigits C++ OOP  1.0.1
Static Public Member Functions | List of all members
dibigd::Bvec Class Reference

Utilities for a vector of bytes. More...

Static Public Member Functions

static std::vector< unsigned char > from_hex (std::string s)
 Decodes a hex-encoded string to a byte vector. More...
 
static void print_hex (std::string prefix, std::vector< unsigned char > barr, std::string sep=" ")
 Print contents of byte array vector in hex with prefix. More...
 
static void print_hex (std::vector< unsigned char > barr, std::string sep=" ")
 Print contents of byte array vector in hex. More...
 

Detailed Description

Utilities for a vector of bytes.

Member Function Documentation

◆ from_hex()

static std::vector<unsigned char> dibigd::Bvec::from_hex ( std::string  s)
static

Decodes a hex-encoded string to a byte vector.

Parameters
sString of hex digits (with or without a '0x' prefix)
Returns
Decoded byte vector.
Remarks
Leading zeros are significant.
Exceptions
std::invalid_argumentexception if an invalid character is found.

◆ print_hex() [1/2]

static void dibigd::Bvec::print_hex ( std::string  prefix,
std::vector< unsigned char >  barr,
std::string  sep = " " 
)
static

Print contents of byte array vector in hex with prefix.

Parameters
prefixPrefix string.
barrA vector of bytes.
sepOptional separator string (default=" ", space)

◆ print_hex() [2/2]

static void dibigd::Bvec::print_hex ( std::vector< unsigned char >  barr,
std::string  sep = " " 
)
static

Print contents of byte array vector in hex.

Parameters
barrA vector of bytes.
sepOptional separator string (default=" ")
BigDigit b(0xdeadbeef);
std::vector<unsigned char> barr = b.to_octets();
Bvec::print_hex(barr); // de ad be ef
Bvec::print_hex(barr, ""); // deadbeef
Bvec::print_hex(barr, " : "); // de : ad : be : ef
// Specify exact length
barr = b.to_octets(6);
Vec::print_hex(barr); // 00 00 de ad be ef
static void print_hex(std::vector< unsigned char > barr, std::string sep=" ")
Print contents of byte array vector in hex.
Copyright © 2026 D.I. Management Services Pty Limited ABN 78 083 210 584 Australia. All rights reserved. <https://di-mgt.com.au/bigdigits.html> Generated on Tue May 5 2026 15:15:13 by Doxygen 1.9.1.