46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
|
|
// SANE-Option
|
|
//
|
|
// created on 2022-10-24
|
|
//
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <base/utils.h> // for refer
|
|
#include <sane/sane_ex.h>
|
|
|
|
class sane_opt_provider : public refer
|
|
{
|
|
bool is_in_another_module_;
|
|
|
|
std::string opt_jsn_txt_;
|
|
std::string where_;
|
|
|
|
protected:
|
|
std::map<std::string, sane_opt_provider*> following_;
|
|
|
|
public:
|
|
sane_opt_provider();
|
|
|
|
protected:
|
|
virtual ~sane_opt_provider();
|
|
|
|
bool set_opt_json_text(char* txt);
|
|
void set_where(const char* where);
|
|
|
|
public:
|
|
const char* get_opt_json(void); // if no content, return "" plz.
|
|
const char* from(void); // if no content, return "" plz.
|
|
bool is_in_another_module(void) { return is_in_another_module_; }
|
|
void set_following_provider(const char* name, sane_opt_provider* following); // when option has provided by more than one
|
|
sane_opt_provider* get_following(const char* name); // caller should ->release returned value
|
|
|
|
public:
|
|
// return malloc(), real data size stored in parameter 'size'. invoker should free() the returned value
|
|
virtual char* get_value(const char* name, void* value, size_t* size, int* err = nullptr);
|
|
virtual int set_value(const char* name, void* val);
|
|
virtual void enable(const char* name, bool able);
|
|
};
|
|
|