diff --git a/sdk/base/data.cpp b/sdk/base/data.cpp index 2af22e5..c13c361 100644 --- a/sdk/base/data.cpp +++ b/sdk/base/data.cpp @@ -486,7 +486,7 @@ file_reader::~file_reader() if (map_) map_->release(); notify_progress(len_, len_, 0); // ensure 100% - utils::to_log(LOG_LEVEL_DEBUG, "Read over of file(%s) at(%p/%p).\n", path_.c_str(), consume_, len_); + utils::to_log(LOG_LEVEL_DEBUG, "Read over of file(%s) at(%llu/%llu).\n", path_.c_str(), consume_, len_); } int file_reader::open(const char* file, bool in_mem, size_t off) diff --git a/sdk/sane_opt_json/base_opt.cpp b/sdk/sane_opt_json/base_opt.cpp index 63069d2..13b5380 100644 --- a/sdk/sane_opt_json/base_opt.cpp +++ b/sdk/sane_opt_json/base_opt.cpp @@ -31,6 +31,31 @@ std::string sane_opt_provider::sane_value_2_text(const char* type, void* value) else return ""; } +void sane_opt_provider::set_opt_value(gb_json* opt, void* value, const char* key) +{ + std::string type(""); + + opt->get_value("type", type); + if (!key || *key == 0) + key = "cur"; + + if (type == JSON_SANE_TYPE_BOOL) + { + opt->set_value(key, *(bool*)value); + } + else if (type == JSON_SANE_TYPE_INT) + { + opt->set_value(key, *(int*)value); + } + else if (type == JSON_SANE_TYPE_FIXED) + { + opt->set_value(key, *(double*)value); + } + else if (type == JSON_SANE_TYPE_STRING) + { + opt->set_value(key, (char*)value); + } +} bool sane_opt_provider::set_opt_json_text(char* txt) { diff --git a/sdk/sane_opt_json/base_opt.h b/sdk/sane_opt_json/base_opt.h index cb87518..5c93bdf 100644 --- a/sdk/sane_opt_json/base_opt.h +++ b/sdk/sane_opt_json/base_opt.h @@ -9,6 +9,8 @@ #include #include // for refer +class gb_json; + class sane_opt_provider : public refer { bool is_in_another_module_; @@ -23,6 +25,7 @@ public: sane_opt_provider(); static std::string sane_value_2_text(const char* type, void* value); // convert to readable text. e.g. bool to "true" or "false", ... + static void set_opt_value(gb_json* opt, void* value, const char* key = "cur"); protected: virtual ~sane_opt_provider(); diff --git a/sdk/sane_opt_json/device_opt.cpp b/sdk/sane_opt_json/device_opt.cpp index 54f2ed0..94c573b 100644 --- a/sdk/sane_opt_json/device_opt.cpp +++ b/sdk/sane_opt_json/device_opt.cpp @@ -1213,6 +1213,7 @@ void device_option::insert_option(gb_json* opt, sane_opt_provider* from, const c type = sane_opt_provider::sane_value_2_text(type.c_str(), &val[0]); utils::to_log(LOG_LEVEL_ALL, "Set option '%s' to default value: '%s'\n", opt->key().c_str(), type.c_str()); from->set_value(opt->key().c_str(), &val[0]); + sane_opt_provider::set_opt_value(opt, &val[0]); } } }