kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move conversion of ScanMethod to option strings to enums.cpp
rodzic
6fe1db1c73
commit
3ad5a92414
|
@ -491,7 +491,7 @@ libgenesys_la_SOURCES = genesys/genesys.cpp genesys/genesys.h \
|
|||
genesys/command_set.h \
|
||||
genesys/conv.h genesys/conv.cpp \
|
||||
genesys/device.h genesys/device.cpp \
|
||||
genesys/enums.h \
|
||||
genesys/enums.h genesys/enums.cpp \
|
||||
genesys/error.h genesys/error.cpp \
|
||||
genesys/fwd.h \
|
||||
genesys/gl646.cpp genesys/gl646.h genesys/gl646_registers.h \
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
|
||||
Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
|
||||
|
||||
This file is part of the SANE package.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA.
|
||||
|
||||
As a special exception, the authors of SANE give permission for
|
||||
additional uses of the libraries contained in this release of SANE.
|
||||
|
||||
The exception is that, if you link a SANE library with other files
|
||||
to produce an executable, this does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public
|
||||
License. Your use of that executable is in no way restricted on
|
||||
account of linking the SANE library code into it.
|
||||
|
||||
This exception does not, however, invalidate any other reasons why
|
||||
the executable file might be covered by the GNU General Public
|
||||
License.
|
||||
|
||||
If you submit changes to SANE to the maintainers to be included in
|
||||
a subsequent release, you agree by submitting the changes that
|
||||
those changes may be distributed with this exception intact.
|
||||
|
||||
If you write modifications of your own for SANE, it is your choice
|
||||
whether to permit this exception to apply to your modifications.
|
||||
If you do not wish that, delete this exception notice.
|
||||
*/
|
||||
|
||||
#define DEBUG_DECLARE_ONLY
|
||||
|
||||
#include "enums.h"
|
||||
#include "genesys.h"
|
||||
|
||||
namespace genesys {
|
||||
|
||||
const char* scan_method_to_option_string(ScanMethod method)
|
||||
{
|
||||
switch (method) {
|
||||
case ScanMethod::FLATBED: return STR_FLATBED;
|
||||
case ScanMethod::TRANSPARENCY: return STR_TRANSPARENCY_ADAPTER;
|
||||
case ScanMethod::TRANSPARENCY_INFRARED: return STR_TRANSPARENCY_ADAPTER_INFRARED;
|
||||
}
|
||||
throw SaneException("Unknown scan method %d", static_cast<unsigned>(method));
|
||||
}
|
||||
|
||||
ScanMethod option_string_to_scan_method(const std::string& str)
|
||||
{
|
||||
if (str == STR_FLATBED) {
|
||||
return ScanMethod::FLATBED;
|
||||
} else if (str == STR_TRANSPARENCY_ADAPTER) {
|
||||
return ScanMethod::TRANSPARENCY;
|
||||
} else if (str == STR_TRANSPARENCY_ADAPTER_INFRARED) {
|
||||
return ScanMethod::TRANSPARENCY_INFRARED;
|
||||
}
|
||||
throw SaneException("Unknown scan method option %s", str.c_str());
|
||||
}
|
||||
|
||||
} // namespace genesys
|
|
@ -71,6 +71,9 @@ inline void serialize(std::ostream& str, ScanMethod& x)
|
|||
serialize(str, value);
|
||||
}
|
||||
|
||||
const char* scan_method_to_option_string(ScanMethod method);
|
||||
ScanMethod option_string_to_scan_method(const std::string& str);
|
||||
|
||||
enum class ScanColorMode : unsigned {
|
||||
LINEART = 0,
|
||||
HALFTONE,
|
||||
|
|
|
@ -97,10 +97,6 @@ namespace {
|
|||
StaticInit<std::list<Genesys_Device>> s_devices;
|
||||
} // namespace
|
||||
|
||||
#define STR_FLATBED SANE_I18N("Flatbed")
|
||||
#define STR_TRANSPARENCY_ADAPTER SANE_I18N("Transparency Adapter")
|
||||
#define STR_TRANSPARENCY_ADAPTER_INFRARED SANE_I18N("Transparency Adapter Infrared")
|
||||
|
||||
static SANE_String_Const mode_list[] = {
|
||||
SANE_VALUE_SCAN_MODE_COLOR,
|
||||
SANE_VALUE_SCAN_MODE_GRAY,
|
||||
|
@ -3404,28 +3400,6 @@ static unsigned pick_resolution(const std::vector<unsigned>& resolutions, unsign
|
|||
return best_res;
|
||||
}
|
||||
|
||||
static const char* scan_method_to_option_string(ScanMethod method)
|
||||
{
|
||||
switch (method) {
|
||||
case ScanMethod::FLATBED: return STR_FLATBED;
|
||||
case ScanMethod::TRANSPARENCY: return STR_TRANSPARENCY_ADAPTER;
|
||||
case ScanMethod::TRANSPARENCY_INFRARED: return STR_TRANSPARENCY_ADAPTER_INFRARED;
|
||||
}
|
||||
throw SaneException("Unknown scan method %d", static_cast<unsigned>(method));
|
||||
}
|
||||
|
||||
static ScanMethod option_string_to_scan_method(const std::string& str)
|
||||
{
|
||||
if (str == STR_FLATBED) {
|
||||
return ScanMethod::FLATBED;
|
||||
} else if (str == STR_TRANSPARENCY_ADAPTER) {
|
||||
return ScanMethod::TRANSPARENCY;
|
||||
} else if (str == STR_TRANSPARENCY_ADAPTER_INFRARED) {
|
||||
return ScanMethod::TRANSPARENCY_INFRARED;
|
||||
}
|
||||
throw SaneException("Unknown scan method option %s", str.c_str());
|
||||
}
|
||||
|
||||
static void calc_parameters(Genesys_Scanner* s)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
#define SANE_I18N(text) text
|
||||
#endif
|
||||
|
||||
#define STR_FLATBED SANE_I18N("Flatbed")
|
||||
#define STR_TRANSPARENCY_ADAPTER SANE_I18N("Transparency Adapter")
|
||||
#define STR_TRANSPARENCY_ADAPTER_INFRARED SANE_I18N("Transparency Adapter Infrared")
|
||||
|
||||
namespace genesys {
|
||||
|
||||
/** List of SANE options
|
||||
|
|
Ładowanie…
Reference in New Issue