X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Finclude%2Flibsigrokcxx%2Flibsigrokcxx.hpp;h=b1ab7a5bd6f6e04a06607c80017e8fc0d9473f73;hb=c5d081f721a0d99e726596d4f8afe72cf803a576;hp=eb7957e5a5a9c6c7737ab5ebd561b7b9b0e8e594;hpb=32ba0d80054df01767ec323c621ab1c6bc5f310c;p=libsigrok.git diff --git a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp index eb7957e5..b1ab7a5b 100644 --- a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp +++ b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp @@ -115,6 +115,7 @@ class SR_API PacketType; class SR_API Quantity; class SR_API Unit; class SR_API QuantityFlag; +class SR_API Rational; class SR_API Input; class SR_API InputDevice; class SR_API Output; @@ -767,10 +768,35 @@ class SR_API Analog : public: /** Pointer to data. */ void *data_pointer(); + /** + * Fills dest pointer with the analog data converted to float. + * The pointer must have space for num_samples() floats. + */ + void get_data_as_float(float *dest); /** Number of samples in this packet. */ unsigned int num_samples() const; /** Channels for which this packet contains data. */ vector > channels(); + /** Size of a single sample in bytes. */ + unsigned int unitsize() const; + /** Samples use a signed data type. */ + bool is_signed() const; + /** Samples use float. */ + bool is_float() const; + /** Samples are stored in big-endian order. */ + bool is_bigendian() const; + /** + * Number of significant digits after the decimal point if positive, + * or number of non-significant digits before the decimal point if negative + * (refers to the value we actually read on the wire). + */ + int digits() const; + /** TBD */ + bool is_digits_decimal() const; + /** TBD */ + shared_ptr scale(); + /** TBD */ + shared_ptr offset(); /** Measured quantity of the samples in this packet. */ const Quantity *mq() const; /** Unit of the samples in this packet. */ @@ -787,6 +813,28 @@ private: friend class Packet; }; +/** Number represented by a numerator/denominator integer pair */ +class SR_API Rational : + public ParentOwned +{ +public: + /** Numerator, i.e. the dividend. */ + int64_t numerator() const; + /** Denominator, i.e. the divider. */ + uint64_t denominator() const; + /** Actual (lossy) value. */ + float value() const; +private: + explicit Rational(const struct sr_rational *structure); + ~Rational(); + shared_ptr share_owned_by(shared_ptr parent); + + const struct sr_rational *_structure; + + friend class Analog; + friend struct std::default_delete; +}; + /** An input format supported by the library */ class SR_API InputFormat : public ParentOwned @@ -828,6 +876,7 @@ public: void send(void *data, size_t length); /** Signal end of input data. */ void end(); + void reset(); private: Input(shared_ptr context, const struct sr_input *structure); ~Input();