use new pos printer settings
This commit is contained in:
parent
dc74c59287
commit
f0078647d4
9 changed files with 144 additions and 47 deletions
|
@ -25,10 +25,10 @@ set(CORE_SOURCES
|
|||
|
||||
add_library(core STATIC ${CORE_SOURCES})
|
||||
if (WIN32)
|
||||
target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARY} ${JSONCPP_LIBRARY})
|
||||
target_link_libraries(core printer Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARY} ${JSONCPP_LIBRARY})
|
||||
target_link_libraries(core bcrypt)
|
||||
else()
|
||||
target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES} ${JSONCPP_LIBRARIES})
|
||||
target_link_libraries(core printer Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES} ${JSONCPP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include <codecvt>
|
||||
#include <iomanip>
|
||||
#include <numeric>
|
||||
#include <codecvt>
|
||||
|
||||
std::string formatCentAsEuroString(const int cent, int width)
|
||||
{
|
||||
|
@ -21,10 +21,36 @@ std::string formatCentAsEuroString(const int cent, int width)
|
|||
return currStream.str();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string convertFromUtf16ToUtf8(std::u16string& utf16String)
|
||||
{
|
||||
std::string u8_conv = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(utf16String);
|
||||
return u8_conv;
|
||||
std::string u8_conv =
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(utf16String);
|
||||
return u8_conv;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <string>
|
||||
#include "posprinter.h"
|
||||
|
||||
#include <locale>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
std::string formatCentAsEuroString(const int cent, int width = 10);
|
||||
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& vendor,
|
||||
const std::string& endpoint);
|
||||
|
||||
#ifdef __WIN32
|
||||
std::string convertFromUtf16ToUtf8(std::u16string& utf16String);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue