restructure libs
This commit is contained in:
parent
ec0b7cbf0d
commit
e89728846c
19 changed files with 79 additions and 67 deletions
|
@ -11,6 +11,7 @@ endif()
|
|||
|
||||
set(PRINTER_SOURCES
|
||||
posprinter.cpp
|
||||
utils.cpp
|
||||
)
|
||||
|
||||
add_library(printer STATIC ${PRINTER_SOURCES})
|
||||
|
@ -19,4 +20,4 @@ if(WIN32)
|
|||
else()
|
||||
target_link_libraries(printer core ${LibUSB_LIBRARIES})
|
||||
endif()
|
||||
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "posprinter.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
|
@ -213,4 +213,4 @@ bool PosPrinter::isValid()
|
|||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef POS_PRINTER_H
|
||||
#define POS_PRINTER_H
|
||||
|
||||
#include <sale.h>
|
||||
#include <seller.h>
|
||||
#include <core/sale.h>
|
||||
#include <core/seller.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
26
src/printer/utils.cpp
Normal file
26
src/printer/utils.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "utils.h"
|
||||
|
||||
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& device,
|
||||
const std::string& endpoint)
|
||||
{
|
||||
if (device.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
PrinterDevice printerDevice;
|
||||
std::string delimiter = ":";
|
||||
try {
|
||||
printerDevice.idVendor = std::stoi(device.substr(0, device.find(delimiter)), 0, 16);
|
||||
printerDevice.idProduct = std::stoi(device.substr(device.find(delimiter) + 1), 0, 16);
|
||||
if (endpoint.empty()) {
|
||||
printerDevice.endpoint = 0x03;
|
||||
} else {
|
||||
printerDevice.endpoint = std::stoi(endpoint, 0, 16);
|
||||
}
|
||||
|
||||
} catch (std::exception& ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return printerDevice;
|
||||
}
|
12
src/printer/utils.h
Normal file
12
src/printer/utils.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef PRINTER_UTILS_H
|
||||
#define PRINTER_UTILS_H
|
||||
|
||||
#include "posprinter.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& vendor,
|
||||
const std::string& endpoint);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue