]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/classes.cpp
Build: Include <config.h> first in all source files
[libsigrok.git] / bindings / cxx / classes.cpp
index 850225fdd467840630442442ab2159e3f852022d..324da04270cdc586278fb6650065e0535add21db 100644 (file)
@@ -17,7 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "libsigrokcxx/libsigrokcxx.hpp"
+#include <config.h>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 #include <sstream>
 #include <cmath>
@@ -77,7 +78,7 @@ Context::Context() :
 {
        check(sr_init(&_structure));
 
-       struct sr_dev_driver **driver_list = sr_driver_list();
+       struct sr_dev_driver **driver_list = sr_driver_list(_structure);
        if (driver_list)
                for (int i = 0; driver_list[i]; i++)
                        _drivers[driver_list[i]->name] =
@@ -161,16 +162,6 @@ void Context::set_log_level(const LogLevel *level)
        check(sr_log_loglevel_set(level->id()));
 }
 
-string Context::log_domain()
-{
-       return valid_string(sr_log_logdomain_get());
-}
-
-void Context::set_log_domain(string value)
-{
-       check(sr_log_logdomain_set(value.c_str()));
-}
-
 static int call_log_callback(void *cb_data, int loglevel, const char *format, va_list args)
 {
        va_list args_copy;
@@ -1438,9 +1429,9 @@ shared_ptr<InputDevice> Input::device()
        return _device->get_shared_pointer(shared_from_this());
 }
 
-void Input::send(string data)
+void Input::send(void *data, size_t length)
 {
-       auto gstr = g_string_new(data.c_str());
+       auto gstr = g_string_new_len((gchar *)data, length);
        auto ret = sr_input_send(_structure, gstr);
        g_string_free(gstr, false);
        check(ret);
@@ -1565,10 +1556,33 @@ shared_ptr<Output> OutputFormat::create_output(
                Output::Deleter());
 }
 
+shared_ptr<Output> OutputFormat::create_output(string filename,
+       shared_ptr<Device> device, map<string, Glib::VariantBase> options)
+{
+       return shared_ptr<Output>(
+               new Output(filename, shared_from_this(), device, options),
+               Output::Deleter());
+}
+
+bool OutputFormat::test_flag(const OutputFlag *flag)
+{
+       return sr_output_test_flag(_structure, flag->id());
+}
+
 Output::Output(shared_ptr<OutputFormat> format,
                shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
        UserOwned(sr_output_new(format->_structure,
-               map_to_hash_variant(options), device->_structure)),
+               map_to_hash_variant(options), device->_structure, NULL)),
+       _format(format),
+       _device(device),
+       _options(options)
+{
+}
+
+Output::Output(string filename, shared_ptr<OutputFormat> format,
+               shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
+       UserOwned(sr_output_new(format->_structure,
+               map_to_hash_variant(options), device->_structure, filename.c_str())),
        _format(format),
        _device(device),
        _options(options)
@@ -1596,6 +1610,6 @@ string Output::receive(shared_ptr<Packet> packet)
        }
 }
 
-#include "enums.cpp"
+#include <enums.cpp>
 
 }