libiio
Classes | Typedefs | Functions
iiopp Namespace Reference

Public C++ API. More...

Classes

class  Buffer
 C++ wrapper for the Buffer C-API. More...
 
class  Channel
 C++ wrapper for the Channel C-API. More...
 
class  Context
 C++ wrapper for the Context C-API. More...
 
class  ContextInfo
 
class  cstr
 Non-owning immutable null terminated string. More...
 
class  Device
 C++ wrapper for the Device C-API. More...
 
class  error
 Thrown to report errors. More...
 
class  IAttr
 Common interface for attribute access. More...
 
class  ScanBlock
 
class  ScanContext
 

Typedefs

typedef optional< cstroptstr
 Optional string, used for C-functions that return nullptr for "no value".
 

Functions

std::shared_ptr< Contextcreate_from_uri (cstr uri)
 C++ wrapper for iio_create_context_from_uri.
 
std::shared_ptr< Contextcreate_default_context ()
 C++ wrapper for iio_create_default_context.
 
std::shared_ptr< Contextcreate_local_context ()
 C++ wrapper for iio_create_local_context.
 
std::shared_ptr< Contextcreate_network_context (cstr host)
 C++ wrapper for iio_create_network_context.
 
std::shared_ptr< Contextcreate_xml_context (cstr xml_file)
 C++ wrapper for iio_create_xml_context.
 
std::shared_ptr< Contextcreate_xml_context_mem (char const *xml, size_t len)
 C++ wrapper for iio_create_xml_context_mem.
 
std::shared_ptr< ScanContextcreate_scan_context (optstr backend, int flags)
 
std::shared_ptr< ScanBlockcreate_scan_block (optstr backend, int flags)
 
double value (Channel ch)
 Reads the value of a channel by using "input" or "raw" attribute and applying "scale" and "offset" if available. More...
 

Detailed Description

Public C++ API.

This is a C++ wrapper for iio.h

It requires C++17 or C++11 with Boost (for boost::optional).

It provides:

Warning
All objects live in the iiopp::Context that created them. When a context gets destroyed (when the last std::shared_ptr to it releases it) all its child objects die as well. All types have weak reference semantic and become invalid when the context gets destroyed. Lifetime is managed by std::shared_ptr.

In consequence all types are cheap to copy (at the cost of assigning a pointer and maybe an integer). Copies refer to the same underlying object.

See iiopp-enum.cpp for an example.

Function Documentation

◆ value()

double iiopp::value ( Channel  ch)
inline

Reads the value of a channel by using "input" or "raw" attribute and applying "scale" and "offset" if available.

See also
get_channel_value in the example iio-monitor.c