mohr_serialize_merged_master #123
@ -1,25 +1,25 @@
|
||||
#include <framework/globalfunctions/printer.h>
|
||||
#include <framework/globalfunctions/arrayprinter.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <bitset>
|
||||
|
||||
void printer::print(const uint8_t *data, size_t size, OutputType type,
|
||||
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
bool printInfo, size_t maxCharPerLine) {
|
||||
if(printInfo) {
|
||||
sif::info << "Printing data with size " << size << ": ";
|
||||
}
|
||||
sif::info << "[";
|
||||
if(type == OutputType::HEX) {
|
||||
printer::printHex(data, size, maxCharPerLine);
|
||||
arrayprinter::printHex(data, size, maxCharPerLine);
|
||||
}
|
||||
else if (type == OutputType::DEC) {
|
||||
printer::printDec(data, size, maxCharPerLine);
|
||||
arrayprinter::printDec(data, size, maxCharPerLine);
|
||||
}
|
||||
else if(type == OutputType::BIN) {
|
||||
printer::printBin(data, size);
|
||||
arrayprinter::printBin(data, size);
|
||||
}
|
||||
}
|
||||
|
||||
void printer::printHex(const uint8_t *data, size_t size,
|
||||
void arrayprinter::printHex(const uint8_t *data, size_t size,
|
||||
size_t maxCharPerLine) {
|
||||
sif::info << std::hex;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
@ -36,7 +36,7 @@ void printer::printHex(const uint8_t *data, size_t size,
|
||||
sif::info << "]" << std::endl;
|
||||
}
|
||||
|
||||
void printer::printDec(const uint8_t *data, size_t size,
|
||||
void arrayprinter::printDec(const uint8_t *data, size_t size,
|
||||
size_t maxCharPerLine) {
|
||||
sif::info << std::dec;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
@ -51,7 +51,7 @@ void printer::printDec(const uint8_t *data, size_t size,
|
||||
sif::info << "]" << std::endl;
|
||||
}
|
||||
|
||||
void printer::printBin(const uint8_t *data, size_t size) {
|
||||
void arrayprinter::printBin(const uint8_t *data, size_t size) {
|
||||
sif::info << "\n" << std::flush;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
sif::info << "Byte " << i + 1 << ": 0b"<<
|
@ -1,16 +1,15 @@
|
||||
#ifndef FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_
|
||||
#define FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_
|
||||
#ifndef FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
|
||||
#define FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace printer {
|
||||
|
||||
enum class OutputType {
|
||||
DEC,
|
||||
HEX,
|
||||
BIN
|
||||
};
|
||||
|
||||
namespace arrayprinter {
|
||||
void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX,
|
||||
bool printInfo = true, size_t maxCharPerLine = 12);
|
||||
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||
@ -18,4 +17,4 @@ void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||
void printBin(const uint8_t* data, size_t size);
|
||||
}
|
||||
|
||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_ */
|
Loading…
Reference in New Issue
Block a user