+string InputFormat::name()
+{
+ return valid_string(sr_input_id_get(_structure));
+}
+
+string InputFormat::description()
+{
+ return valid_string(sr_input_description_get(_structure));
+}
+
+map<string, shared_ptr<Option>> InputFormat::options()
+{
+ const struct sr_option **options = sr_input_options_get(_structure);
+ auto option_array = shared_ptr<const struct sr_option *>(
+ options, sr_input_options_free);
+ map<string, shared_ptr<Option>> result;
+ for (int i = 0; options[i]; i++)
+ result[options[i]->id] = shared_ptr<Option>(
+ new Option(options[i], option_array), Option::Deleter());
+ return result;
+}
+
+shared_ptr<Input> InputFormat::create_input(
+ map<string, Glib::VariantBase> options)
+{
+ auto input = sr_input_new(_structure, map_to_hash_variant(options));
+ if (!input)
+ throw Error(SR_ERR_ARG);
+ return shared_ptr<Input>(
+ new Input(_parent->shared_from_this(), input), Input::Deleter());
+}
+
+Input::Input(shared_ptr<Context> context, const struct sr_input *structure) :
+ UserOwned(structure),
+ _context(context),
+ _device(nullptr)
+{
+}
+
+shared_ptr<InputDevice> Input::device()
+{
+ if (!_device)
+ {
+ auto sdi = sr_input_dev_inst_get(_structure);
+ if (!sdi)
+ throw Error(SR_ERR_NA);
+ _device = new InputDevice(shared_from_this(), sdi);
+ }
+
+ return _device->get_shared_pointer(shared_from_this());
+}
+
+void Input::send(string data)
+{
+ auto gstr = g_string_new(data.c_str());
+ auto ret = sr_input_send(_structure, gstr);
+ g_string_free(gstr, false);
+ check(ret);
+}
+
+void Input::end()
+{
+ check(sr_input_end(_structure));
+}
+
+Input::~Input()
+{
+ if (_device)
+ delete _device;
+ sr_input_free(_structure);
+}
+
+InputDevice::InputDevice(shared_ptr<Input> input,
+ struct sr_dev_inst *structure) :
+ ParentOwned(structure),
+ Device(structure),
+ _input(input)
+{
+}
+
+InputDevice::~InputDevice()