#pragma once #include #include #include #include #include #include #include #if defined(WIN32) || defined(_WIN64) #define bzero(b, s) memset(b, 0, s) #else #include #endif #include "../sdk/hginclude/huagaoxxx_warraper_ex.h" #include "sane/sane_ex.h" #include "json.h" namespace local_utility { void* acquire_memory(size_t bytes, const char* info); void free_memory(void* m); }; class sane_std_opts { typedef struct _sane_opt { SANE_Option_Descriptor* desc; int opt; }SANEOPT; typedef struct _opt_map { SANEOPT known; SANEOPT user; std::string init; }OPTMAP; std::vector known_opts_; int opt_num_base_; int page_width_; int page_height_; SANE_Option_Descriptor* get_known_option(int opt, int* ind = nullptr); SANE_Option_Descriptor* get_known_option(const char* name, int* ind = nullptr); void to_known_opt_value(OPTMAP* opmap, const void* data, void* known_data); void* from_known_opt_value(OPTMAP* opmap, const void* known_data, long* len); public: sane_std_opts(int opt_base); ~sane_std_opts(); public: static json* get_opt_json(scanner_handle h, int opt); // call delete to free the returned object static void* get_current_value(scanner_handle h, int opt); // call local_utility::free_memory to free the returned buffer public: void init_known_opt(int option, SANE_Option_Descriptor* desc); SANE_Option_Descriptor* get_option(int option); void clear(void); bool is_known_option(int opt, SANE_Option_Descriptor** user = nullptr); void* get_default_value(scanner_handle h, int opt); // call local_utility::free_memory to free the returned buffer scanner_err get_value(scanner_handle h, int opt, void* buf); // call this ONLY when is_known_option returnning true scanner_err set_value(scanner_handle h, int opt, void* buf); // call this ONLY when is_known_option returnning true };