Skip to content

Commit

Permalink
Merge pull request #35 from dynarithmic/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
dynarithmic committed Sep 24, 2023
2 parents bc97ec5 + 5892b22 commit 726b45c
Show file tree
Hide file tree
Showing 65 changed files with 694 additions and 640 deletions.
Binary file modified binaries/32bit/32bit_FullDemo.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions binaries/32bit/32bit_FullDemo_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MD5: e0bc988d63f4184ceda1f3a2033567b4
SHA1: 8e57f4bce06aca00ed5289d26f08884b375ffe19
SHA256: f37b2d0722184870e91a295ee5c715f89be333652bee009a0abdc1ab49f894a9
SHA512: 2993bde18689349aaad2c526707f6788e966cda1dbc4091cb3684387993595a71af181b8b15c9494ae29e1deeb4a0cadb6d2b1c39d360d5a60fbc5a231b181a6
MD5: 4ba228394a030b581180fdadb17fa305
SHA1: 6300ca68f47e5098035ccd0cb6ad9d04f4d7b103
SHA256: 1e2329080a53e88170b074020ade1c1b000d7a446758788ce79d3f8ab596a428
SHA512: d182225e97a98b67f8c25667493a3c4eda1bf0d390f5e6b1c081c56a5040f78dd2547ed88c41c385afae8c2ebc87feed5f124b1ed41d8016add5ef9ef8426360
Binary file modified binaries/32bit/release_libraries.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions binaries/32bit/release_ziphashes32.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MD5 hash of "release_libraries.zip" (16 bytes) = c044cbd201439d2777ffa28f6e8e1285
SHA1 hash of "release_libraries.zip" (20 bytes) = 157dde6690be0e4424c649a3ea0d431a97a7c77d
SHA256 hash of "release_libraries.zip" (32 bytes) = 61d6ff84f0d38eaa6531b98339cab879bc2906921819bc848c8832ee6ab5038c
MD5 hash of "release_libraries.zip" (16 bytes) = 39d8d5f7ed93e7eb0bd72225558e4c19
SHA1 hash of "release_libraries.zip" (20 bytes) = 4702a0bfd643e0683ba7fac04f7476f8812ac64f
SHA256 hash of "release_libraries.zip" (32 bytes) = 184538858562c71261b0b44a061e70e0947e51826de03a62173c08d014e93f7f

Binary file modified binaries/32bit_debug/debug_libraries.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions binaries/32bit_debug/debug_ziphashes32.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MD5 hash of "debug_libraries.zip" (16 bytes) = 65f9af664cb67cd8089c8aea7ef4374c
SHA1 hash of "debug_libraries.zip" (20 bytes) = 5a1c6fe16726ee5d80c8394a75fdcecc27e30555
SHA256 hash of "debug_libraries.zip" (32 bytes) = 75a3015cfda01808f3bf64d2f926acd7b1a2aebb3d4403afdeefb7062f8afb15
MD5 hash of "debug_libraries.zip" (16 bytes) = 50b8ff8ddb6750a5716bc9e6e7728278
SHA1 hash of "debug_libraries.zip" (20 bytes) = d74e8a6e32bfc7f5100327233a23724e2b018acc
SHA256 hash of "debug_libraries.zip" (32 bytes) = 2b0307aeda14999b8d84409abcf4cffe002d2aca52cc63c8fbc70c3fe0598861

Binary file modified binaries/64bit/64bit_FullDemo.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions binaries/64bit/64bit_FullDemo_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MD5: 8b19e9c921fd0ca184e5158b354f940c
SHA1: c6261e536eefd1e68eeecb6df742d6329f2341ce
SHA256: d282650ca439065a5f5dace83f8493e340c7de0abf96dd65924a9916bce670d3
SHA512: 05497cdc0a3186da73ac0fd9aaa656e9fef7840abd25175ed372cc7ee4d2ad5ea64ba92beedced0e975b2d72cf5c545a025b2140e4a9aa3cc4b95aa3efe4ce3c
MD5: 33cf9cb3e747468db43f49c7d5da41c4
SHA1: 683d3ad3b2c4c360ce1f479a109467c63171a76b
SHA256: 1477c96cd644d8a0aaf662091fe385719cb6466e281e98f46e0a3eceadbe161e
SHA512: 19b4588e948b1e59e9f9f7782253f0632c9bbb250d408dcc0c9ed12288bfd51a3053b31b655f7a271b2d8ba2fa0332c1c238b44142d0f3a4b5f573548998bc50
Binary file modified binaries/64bit/release_libraries.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions binaries/64bit/release_ziphashes64.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MD5 hash of "release_libraries.zip" (16 bytes) = 6b5df6928b461f47feb188eeb843e764
SHA1 hash of "release_libraries.zip" (20 bytes) = 1dba20189a666d2e616b20bf7a4af35e8175146b
SHA256 hash of "release_libraries.zip" (32 bytes) = e0441296b76015585dc46108e6a8d2bd8b4407dab9b4e02742ded97d2e84fc08
MD5 hash of "release_libraries.zip" (16 bytes) = 3763899a7cea3279ac417ca009a03833
SHA1 hash of "release_libraries.zip" (20 bytes) = 57f41a80f4e85b836c5bea203bac9dd9722dc4d1
SHA256 hash of "release_libraries.zip" (32 bytes) = dbee22d1123609836a2a2b9660555f720fe6c7df5d83ddf1aa542d7f97735e06

2 changes: 1 addition & 1 deletion demos/c_cpp_includes/dtwain_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#define DTWAIN_MAJOR_VERSION 5
#define DTWAIN_MINOR_VERSION 4
#define DTWAIN_PATCHLEVEL_VERSION 0
#define DTWAIN_PATCHLEVEL_VERSION 1

#define DTWAIN_STRINGER_2_(x) #x
#define DTWAIN_STRINGER_(x) DTWAIN_STRINGER_2_(x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@ int Runner::Run()
// In this example, we will test whether the session was started successfully
if (session)
{
// For a centered dialog, uncomment the line below:
// auto selection = RunnerBase::SelectDialog(session);

// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int Runner::Run()
twain_session ts(startup_mode::autostart);

// select a source (TWAIN session will automatically start)
auto selection = ts.select_source();
auto selection = RunnerBase::SelectDialog(ts);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp_wrapper/PDFAddTextDemo/PDFAddTextDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp_wrapper/PDFDemo/PDFDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp_wrapper/ShowCustomDSData/ShowCustomDSData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int Runner::Run()
twain_session session(startup_mode::autostart);

// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int Runner::Run()
twain_session session(startup_mode::autostart);

// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// For a centered dialog, uncomment the line below:
// auto selection = RunnerBase::SelectDialog(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp_wrapper/TwainCallbackDemo/TwainCallbackDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp_wrapper/TwainCapListing/TwainCapListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
29 changes: 19 additions & 10 deletions demos/cpp_wrapper/TwainLoggingDemo/TwainLoggingDemo.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <iostream>
#include <string>

#include <dynarithmic/twain/twain_session.hpp> // for dynarithmic::twain::twain_session
#include <dynarithmic/twain/twain_source.hpp> // for dynarithmic::twain::twain_source
#include <dynarithmic/twain/acquire_characteristics.hpp> // for acquire_characteristics
#include <dynarithmic\/twain/logging/twain_logger.hpp>
#include "..\Runner\runnerbase.h"

struct Runner : RunnerBase
Expand All @@ -13,6 +15,19 @@ struct Runner : RunnerBase

using namespace dynarithmic::twain;

struct twain_derived_logger : public twain_logger
{
public:
twain_derived_logger()
{
std::cout << "Derived Logger Created" << "\n";
}
virtual void log(const char* msg) override
{
std::cout << "I got a message for this logger: " << msg << "\n";
}
};

int Runner::Run()
{
// Create a TWAIN session and automatically open the TWAIN data source manager
Expand All @@ -21,20 +36,14 @@ int Runner::Run()
twain_session session;

// create a logger and set the twain session to use the logger
session.register_logger(twain_logger().enable().
set_destination(logger_destination::toconsole). // log to the console
set_verbosity(logger_verbosity::verbose2). // verbosity level
enable_custom(true). // enable the custom log destination to our logger's custom handler
set_custom_function([](const char* msg)
{
std::string s = "I got a message: " + std::string(msg) + "\n";
OutputDebugStringA(s.c_str());
}));
auto& logger = session.register_logger<twain_derived_logger>();
logger.enable().
set_verbosity(logger_verbosity::verbose2); // verbosity level
// Start the session
session.start();

// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int Runner::Run()
if (session)
{
// select a source
auto selection = session.select_source();
auto selection = RunnerBase::SelectDialog(session);

// check if user canceled the selection
if (selection.canceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ namespace dynarithmic
const auto thisObject = reinterpret_cast<twain_session*>(UserData);
if (thisObject)
{
twain_session::logger_type& sesObject = thisObject->get_logger();
twain_session::logger_type& sesObject = thisObject->get_logger_type();
if (sesObject.second && sesObject.second->is_enabled())
{
const auto& fn = sesObject.second->get_custom_function();
if (fn)
fn(msg);
const auto& fn = sesObject.second;
fn->log(msg);
}
}
return 1;
Expand Down
30 changes: 5 additions & 25 deletions demos/cpp_wrapper_lib/dynarithmic/twain/logging/twain_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ namespace dynarithmic
{
namespace twain
{
enum class logger_destination
{
tofile = DTWAIN_LOG_USEFILE,
toconsole = DTWAIN_LOG_CONSOLE,
todebug = DTWAIN_LOG_DEBUGMONITOR,
tofile_and_console = tofile | toconsole,
tofile_and_debug = tofile | todebug,
toconsole_and_debug = toconsole | todebug,
toall = tofile | todebug | toconsole,
tonone = 0
};

enum class logger_verbosity
{
verbose0 = 0,
Expand All @@ -53,15 +41,16 @@ namespace dynarithmic

class twain_logger
{
logger_destination m_log_destination = logger_destination::tonone;
logger_verbosity m_log_verbosity = logger_verbosity::verbose4;
std::string m_log_filename;
std::array<LONG, 5> m_verbose_settings;
bool m_bEnabled = false;
bool m_bCustomEnabled = false;
std::function<void(const char*)> m_customFunc;
std::vector<std::function<void(twain_logger&, const char*)>> m_vCustomFuncs;
public:
typedef std::function<void(const char*)> custom_function_type;
typedef std::function<void(twain_logger&, const char*)> log_proc_type;
virtual ~twain_logger() = default;
virtual void log(const char* /*msg*/) {}

twain_logger() : m_log_verbosity(logger_verbosity::verbose1)
{
m_verbose_settings[0] = 0;
Expand All @@ -72,19 +61,10 @@ namespace dynarithmic
}

twain_logger& enable(bool bEnable = true) { m_bEnabled = bEnable; return *this; }
twain_logger& enable_custom(bool bEnable = true) { m_bCustomEnabled = bEnable; return *this; }
twain_logger& set_destination(logger_destination ld) { m_log_destination = ld; return *this; }
logger_destination get_destination() const { return m_log_destination; }
twain_logger& set_verbosity(logger_verbosity lv) { m_log_verbosity = lv; return *this; }
logger_verbosity get_verbosity() const { return m_log_verbosity; }
long get_verbosity_aslong() const { return m_verbose_settings[static_cast<LONG>(m_log_verbosity)];}
twain_logger& set_filename(const std::string& filename) { m_log_filename = filename; return *this; }
std::string get_filename() const { return m_log_filename; }
bool is_enabled() const { return m_bEnabled; }
bool is_custom_enabled() const { return m_bCustomEnabled; }
twain_logger& set_custom_function(custom_function_type fn) { m_customFunc = fn; return *this; }
custom_function_type get_custom_function() const { return m_customFunc; }

/// Logs a custom error message to the logging system
///
/// This function will pass a message to the logging system. The message will show up in the log with time stamp.
Expand Down
Loading

0 comments on commit 726b45c

Please sign in to comment.