GNU Radio Manual and C++ API Reference  3.9.4.0
The Free & Open Software Radio Ecosystem
pmt.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2009,2010,2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_PMT_H
12 #define INCLUDED_PMT_H
13 
14 #include <pmt/api.h>
15 #include <boost/any.hpp>
16 #include <boost/noncopyable.hpp>
17 #include <complex>
18 #include <cstdint>
19 #include <iosfwd>
20 #include <memory>
21 #include <stdexcept>
22 #include <string>
23 #include <vector>
24 
25 namespace gr {
26 namespace messages {
27 class msg_accepter;
28 }
29 } // namespace gr
30 
31 /*!
32  * This file defines a polymorphic type and the operations on it.
33  *
34  * It draws heavily on the idea of scheme and lisp data types.
35  * The interface parallels that in Guile 1.8, with the notable
36  * exception that these objects are transparently reference counted.
37  */
38 
39 namespace pmt {
40 
41 /*!
42  * \brief base class of all pmt types
43  */
45 {
46 
47 public:
48  pmt_base(){};
49  pmt_base(const pmt_base&) = delete;
50  virtual ~pmt_base();
51 
52  virtual bool is_bool() const { return false; }
53  virtual bool is_symbol() const { return false; }
54  virtual bool is_number() const { return false; }
55  virtual bool is_integer() const { return false; }
56  virtual bool is_uint64() const { return false; }
57  virtual bool is_real() const { return false; }
58  virtual bool is_complex() const { return false; }
59  virtual bool is_null() const { return false; }
60  virtual bool is_pair() const { return false; }
61  virtual bool is_tuple() const { return false; }
62  virtual bool is_vector() const { return false; }
63  virtual bool is_dict() const { return false; }
64  virtual bool is_any() const { return false; }
65 
66  virtual bool is_uniform_vector() const { return false; }
67  virtual bool is_u8vector() const { return false; }
68  virtual bool is_s8vector() const { return false; }
69  virtual bool is_u16vector() const { return false; }
70  virtual bool is_s16vector() const { return false; }
71  virtual bool is_u32vector() const { return false; }
72  virtual bool is_s32vector() const { return false; }
73  virtual bool is_u64vector() const { return false; }
74  virtual bool is_s64vector() const { return false; }
75  virtual bool is_f32vector() const { return false; }
76  virtual bool is_f64vector() const { return false; }
77  virtual bool is_c32vector() const { return false; }
78  virtual bool is_c64vector() const { return false; }
79 };
80 
81 /*!
82  * \brief typedef for shared pointer (transparent reference counting).
83  */
84 typedef std::shared_ptr<pmt_base> pmt_t;
85 
86 class PMT_API exception : public std::logic_error
87 {
88 public:
89  exception(const std::string& msg, pmt_t obj);
90 };
91 
92 class PMT_API wrong_type : public std::invalid_argument
93 {
94 public:
95  wrong_type(const std::string& msg, pmt_t obj);
96 };
97 
99 {
100 public:
101  out_of_range(const std::string& msg, pmt_t obj);
102 };
103 
105 {
106 public:
107  notimplemented(const std::string& msg, pmt_t obj);
108 };
109 
110 
111 /*
112  * ------------------------------------------------------------------------
113  * Constants
114  * ------------------------------------------------------------------------
115  */
116 
121 
122 #define PMT_NIL get_PMT_NIL()
123 #define PMT_T get_PMT_T()
124 #define PMT_F get_PMT_F()
125 #define PMT_EOF get_PMT_EOF()
126 
127 
128 /*
129  * ------------------------------------------------------------------------
130  * Booleans. Two constants, #t and #f.
131  *
132  * In predicates, anything that is not #f is considered true.
133  * I.e., there is a single false value, #f.
134  * ------------------------------------------------------------------------
135  */
136 
137 //! Return true if obj is \#t or \#f, else return false.
138 PMT_API bool is_bool(pmt_t obj);
139 
140 //! Return false if obj is \#f, else return true.
141 PMT_API bool is_true(pmt_t obj);
142 
143 //! Return true if obj is \#f, else return true.
144 PMT_API bool is_false(pmt_t obj);
145 
146 //! Return \#f is val is false, else return \#t.
147 PMT_API pmt_t from_bool(bool val);
148 
149 //! Return true if val is pmt::True, return false when val is pmt::PMT_F,
150 // else raise wrong_type exception.
151 PMT_API bool to_bool(pmt_t val);
152 
153 /*
154  * ------------------------------------------------------------------------
155  * Symbols
156  * ------------------------------------------------------------------------
157  */
158 
159 //! Return true if obj is a symbol, else false.
160 PMT_API bool is_symbol(const pmt_t& obj);
161 
162 //! Return the symbol whose name is \p s.
163 PMT_API pmt_t string_to_symbol(const std::string& s);
164 
165 //! Alias for pmt_string_to_symbol
166 PMT_API pmt_t intern(const std::string& s);
167 
168 
169 /*!
170  * If \p is a symbol, return the name of the symbol as a string.
171  * Otherwise, raise the wrong_type exception.
172  */
173 PMT_API const std::string symbol_to_string(const pmt_t& sym);
174 
175 /*
176  * ------------------------------------------------------------------------
177  * Numbers: we support integer, real and complex
178  * ------------------------------------------------------------------------
179  */
180 
181 //! Return true if obj is any kind of number, else false.
182 PMT_API bool is_number(pmt_t obj);
183 
184 /*
185  * ------------------------------------------------------------------------
186  * Integers
187  * ------------------------------------------------------------------------
188  */
189 
190 //! Return true if \p x is an integer number, else false
191 PMT_API bool is_integer(pmt_t x);
192 
193 //! Return the pmt value that represents the integer \p x.
194 PMT_API pmt_t from_long(long x);
195 
196 /*!
197  * \brief Convert pmt to long if possible.
198  *
199  * When \p x represents an exact integer that fits in a long,
200  * return that integer. Else raise an exception, either wrong_type
201  * when x is not an exact integer, or out_of_range when it doesn't fit.
202  */
203 PMT_API long to_long(pmt_t x);
204 
205 /*
206  * ------------------------------------------------------------------------
207  * uint64_t
208  * ------------------------------------------------------------------------
209  */
210 
211 //! Return true if \p x is an uint64 number, else false
212 PMT_API bool is_uint64(pmt_t x);
213 
214 //! Return the pmt value that represents the uint64 \p x.
215 PMT_API pmt_t from_uint64(uint64_t x);
216 
217 /*!
218  * \brief Convert pmt to uint64 if possible.
219  *
220  * When \p x represents an exact integer that fits in a uint64,
221  * return that uint64. Else raise an exception, either wrong_type
222  * when x is not an exact uint64, or out_of_range when it doesn't fit.
223  */
224 PMT_API uint64_t to_uint64(pmt_t x);
225 
226 /*
227  * ------------------------------------------------------------------------
228  * Reals
229  * ------------------------------------------------------------------------
230  */
231 
232 /*
233  * \brief Return true if \p obj is a real number, else false.
234  */
235 PMT_API bool is_real(pmt_t obj);
236 
237 //! Return the pmt value that represents double \p x.
238 PMT_API pmt_t from_double(double x);
239 PMT_API pmt_t from_float(float x);
240 
241 /*!
242  * \brief Convert pmt to double if possible.
243  *
244  * Returns the number closest to \p val that is representable
245  * as a double. The argument \p val must be a real or integer, otherwise
246  * a wrong_type exception is raised.
247  */
248 PMT_API double to_double(pmt_t x);
249 
250 /*!
251  * \brief Convert pmt to float if possible.
252  *
253  * This basically is to_double() with a type-cast; the PMT stores
254  * the value as a double in any case. Use this when strict typing
255  * is required.
256  */
257 PMT_API float to_float(pmt_t x);
258 
259 /*
260  * ------------------------------------------------------------------------
261  * Complex
262  * ------------------------------------------------------------------------
263  */
264 
265 /*!
266  * \brief return true if \p obj is a complex number, false otherwise.
267  */
268 PMT_API bool is_complex(pmt_t obj);
269 
270 //! Return a complex number constructed of the given real and imaginary parts.
271 PMT_API pmt_t make_rectangular(double re, double im);
272 
273 //! Return a complex number constructed of the given real and imaginary parts.
274 PMT_API pmt_t from_complex(double re, double im);
275 
276 //! Return a complex number constructed of the given a complex number.
277 PMT_API pmt_t from_complex(const std::complex<double>& z);
278 
279 //! Return a complex number constructed of the given real and imaginary parts.
280 PMT_API pmt_t pmt_from_complex(double re, double im);
281 
282 //! Return a complex number constructed of the given a complex number.
283 PMT_API pmt_t pmt_from_complex(const std::complex<double>& z);
284 
285 /*!
286  * If \p z is complex, real or integer, return the closest complex<double>.
287  * Otherwise, raise the wrong_type exception.
288  */
289 PMT_API std::complex<double> to_complex(pmt_t z);
290 
291 /*
292  * ------------------------------------------------------------------------
293  * Pairs
294  * ------------------------------------------------------------------------
295  */
296 
297 //! Return true if \p x is the empty list, otherwise return false.
298 PMT_API bool is_null(const pmt_t& x);
299 
300 //! Return true if \p obj is a pair, else false (warning: also returns true for a dict)
301 PMT_API bool is_pair(const pmt_t& obj);
302 
303 //! Return a newly allocated pair whose car is \p x and whose cdr is \p y.
304 PMT_API pmt_t cons(const pmt_t& x, const pmt_t& y);
305 
306 //! If \p pair is a pair, return the car of the \p pair, otherwise raise wrong_type.
307 PMT_API pmt_t car(const pmt_t& pair);
308 
309 //! If \p pair is a pair, return the cdr of the \p pair, otherwise raise wrong_type.
310 PMT_API pmt_t cdr(const pmt_t& pair);
311 
312 //! Stores \p value in the car field of \p pair.
313 PMT_API void set_car(pmt_t pair, pmt_t value);
314 
315 //! Stores \p value in the cdr field of \p pair.
316 PMT_API void set_cdr(pmt_t pair, pmt_t value);
317 
318 PMT_API pmt_t caar(pmt_t pair);
319 PMT_API pmt_t cadr(pmt_t pair);
320 PMT_API pmt_t cdar(pmt_t pair);
321 PMT_API pmt_t cddr(pmt_t pair);
322 PMT_API pmt_t caddr(pmt_t pair);
323 PMT_API pmt_t cadddr(pmt_t pair);
324 
325 /*
326  * ------------------------------------------------------------------------
327  * Tuples
328  *
329  * Store a fixed number of objects. Tuples are not modifiable, and thus
330  * are excellent for use as messages. Indexing is zero based.
331  * Access time to an element is O(1).
332  * ------------------------------------------------------------------------
333  */
334 
335 //! Return true if \p x is a tuple, otherwise false.
336 PMT_API bool is_tuple(pmt_t x);
337 
339 PMT_API pmt_t make_tuple(const pmt_t& e0);
340 PMT_API pmt_t make_tuple(const pmt_t& e0, const pmt_t& e1);
341 PMT_API pmt_t make_tuple(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2);
342 PMT_API pmt_t make_tuple(const pmt_t& e0,
343  const pmt_t& e1,
344  const pmt_t& e2,
345  const pmt_t& e3);
347  const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3, const pmt_t& e4);
348 PMT_API pmt_t make_tuple(const pmt_t& e0,
349  const pmt_t& e1,
350  const pmt_t& e2,
351  const pmt_t& e3,
352  const pmt_t& e4,
353  const pmt_t& e5);
354 PMT_API pmt_t make_tuple(const pmt_t& e0,
355  const pmt_t& e1,
356  const pmt_t& e2,
357  const pmt_t& e3,
358  const pmt_t& e4,
359  const pmt_t& e5,
360  const pmt_t& e6);
361 PMT_API pmt_t make_tuple(const pmt_t& e0,
362  const pmt_t& e1,
363  const pmt_t& e2,
364  const pmt_t& e3,
365  const pmt_t& e4,
366  const pmt_t& e5,
367  const pmt_t& e6,
368  const pmt_t& e7);
369 PMT_API pmt_t make_tuple(const pmt_t& e0,
370  const pmt_t& e1,
371  const pmt_t& e2,
372  const pmt_t& e3,
373  const pmt_t& e4,
374  const pmt_t& e5,
375  const pmt_t& e6,
376  const pmt_t& e7,
377  const pmt_t& e8);
378 PMT_API pmt_t make_tuple(const pmt_t& e0,
379  const pmt_t& e1,
380  const pmt_t& e2,
381  const pmt_t& e3,
382  const pmt_t& e4,
383  const pmt_t& e5,
384  const pmt_t& e6,
385  const pmt_t& e7,
386  const pmt_t& e8,
387  const pmt_t& e9);
388 
389 /*!
390  * If \p x is a vector or proper list, return a tuple containing the elements of x
391  */
392 PMT_API pmt_t to_tuple(const pmt_t& x);
393 
394 /*!
395  * Return the contents of position \p k of \p tuple.
396  * \p k must be a valid index of \p tuple.
397  */
398 PMT_API pmt_t tuple_ref(const pmt_t& tuple, size_t k);
399 
400 /*
401  * ------------------------------------------------------------------------
402  * Vectors
403  *
404  * These vectors can hold any kind of objects. Indexing is zero based.
405  * ------------------------------------------------------------------------
406  */
407 
408 //! Return true if \p x is a vector, otherwise false.
409 PMT_API bool is_vector(pmt_t x);
410 
411 //! Make a vector of length \p k, with initial values set to \p fill
412 PMT_API pmt_t make_vector(size_t k, pmt_t fill);
413 
414 /*!
415  * Return the contents of position \p k of \p vector.
416  * \p k must be a valid index of \p vector.
417  */
418 PMT_API pmt_t vector_ref(pmt_t vector, size_t k);
419 
420 //! Store \p obj in position \p k.
421 PMT_API void vector_set(pmt_t vector, size_t k, pmt_t obj);
422 
423 //! Store \p fill in every position of \p vector
424 PMT_API void vector_fill(pmt_t vector, pmt_t fill);
425 
426 /*
427  * ------------------------------------------------------------------------
428  * Binary Large Objects (BLOBs)
429  *
430  * Handy for passing around uninterpreted chunks of memory.
431  * ------------------------------------------------------------------------
432  */
433 
434 //! Return true if \p x is a blob, otherwise false.
435 PMT_API bool is_blob(pmt_t x);
436 
437 /*!
438  * \brief Make a blob given a pointer and length in bytes
439  *
440  * \param buf is the pointer to data to use to create blob
441  * \param len is the size of the data in bytes.
442  *
443  * The data is copied into the blob.
444  */
445 PMT_API pmt_t make_blob(const void* buf, size_t len);
446 
447 //! Return a pointer to the blob's data
448 PMT_API const void* blob_data(pmt_t blob);
449 
450 //! Return the blob's length in bytes
451 PMT_API size_t blob_length(pmt_t blob);
452 
453 /*!
454  * <pre>
455  * Uniform Numeric Vectors
456  *
457  * A uniform numeric vector is a vector whose elements are all of single
458  * numeric type. pmt offers uniform numeric vectors for signed and
459  * unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
460  * floating point values, and complex floating-point numbers of these
461  * two sizes. Indexing is zero based.
462  *
463  * The names of the functions include these tags in their names:
464  *
465  * u8 unsigned 8-bit integers
466  * s8 signed 8-bit integers
467  * u16 unsigned 16-bit integers
468  * s16 signed 16-bit integers
469  * u32 unsigned 32-bit integers
470  * s32 signed 32-bit integers
471  * u64 unsigned 64-bit integers
472  * s64 signed 64-bit integers
473  * f32 the C++ type float
474  * f64 the C++ type double
475  * c32 the C++ type complex<float>
476  * c64 the C++ type complex<double>
477  * </pre>
478  */
479 
480 //! true if \p x is any kind of uniform numeric vector
482 
483 PMT_API bool is_u8vector(pmt_t x);
484 PMT_API bool is_s8vector(pmt_t x);
485 PMT_API bool is_u16vector(pmt_t x);
486 PMT_API bool is_s16vector(pmt_t x);
487 PMT_API bool is_u32vector(pmt_t x);
488 PMT_API bool is_s32vector(pmt_t x);
489 PMT_API bool is_u64vector(pmt_t x);
490 PMT_API bool is_s64vector(pmt_t x);
491 PMT_API bool is_f32vector(pmt_t x);
492 PMT_API bool is_f64vector(pmt_t x);
493 PMT_API bool is_c32vector(pmt_t x);
494 PMT_API bool is_c64vector(pmt_t x);
495 
496 //! item size in bytes if \p x is any kind of uniform numeric vector
498 
499 PMT_API pmt_t make_u8vector(size_t k, uint8_t fill);
500 PMT_API pmt_t make_s8vector(size_t k, int8_t fill);
501 PMT_API pmt_t make_u16vector(size_t k, uint16_t fill);
502 PMT_API pmt_t make_s16vector(size_t k, int16_t fill);
503 PMT_API pmt_t make_u32vector(size_t k, uint32_t fill);
504 PMT_API pmt_t make_s32vector(size_t k, int32_t fill);
505 PMT_API pmt_t make_u64vector(size_t k, uint64_t fill);
506 PMT_API pmt_t make_s64vector(size_t k, int64_t fill);
507 PMT_API pmt_t make_f32vector(size_t k, float fill);
508 PMT_API pmt_t make_f64vector(size_t k, double fill);
509 PMT_API pmt_t make_c32vector(size_t k, std::complex<float> fill);
510 PMT_API pmt_t make_c64vector(size_t k, std::complex<double> fill);
511 
512 PMT_API pmt_t init_u8vector(size_t k, const uint8_t* data);
513 PMT_API pmt_t init_u8vector(size_t k, const std::vector<uint8_t>& data);
514 PMT_API pmt_t init_s8vector(size_t k, const int8_t* data);
515 PMT_API pmt_t init_s8vector(size_t k, const std::vector<int8_t>& data);
516 PMT_API pmt_t init_u16vector(size_t k, const uint16_t* data);
517 PMT_API pmt_t init_u16vector(size_t k, const std::vector<uint16_t>& data);
518 PMT_API pmt_t init_s16vector(size_t k, const int16_t* data);
519 PMT_API pmt_t init_s16vector(size_t k, const std::vector<int16_t>& data);
520 PMT_API pmt_t init_u32vector(size_t k, const uint32_t* data);
521 PMT_API pmt_t init_u32vector(size_t k, const std::vector<uint32_t>& data);
522 PMT_API pmt_t init_s32vector(size_t k, const int32_t* data);
523 PMT_API pmt_t init_s32vector(size_t k, const std::vector<int32_t>& data);
524 PMT_API pmt_t init_u64vector(size_t k, const uint64_t* data);
525 PMT_API pmt_t init_u64vector(size_t k, const std::vector<uint64_t>& data);
526 PMT_API pmt_t init_s64vector(size_t k, const int64_t* data);
527 PMT_API pmt_t init_s64vector(size_t k, const std::vector<int64_t>& data);
528 PMT_API pmt_t init_f32vector(size_t k, const float* data);
529 PMT_API pmt_t init_f32vector(size_t k, const std::vector<float>& data);
530 PMT_API pmt_t init_f64vector(size_t k, const double* data);
531 PMT_API pmt_t init_f64vector(size_t k, const std::vector<double>& data);
532 PMT_API pmt_t init_c32vector(size_t k, const std::complex<float>* data);
533 PMT_API pmt_t init_c32vector(size_t k, const std::vector<std::complex<float>>& data);
534 PMT_API pmt_t init_c64vector(size_t k, const std::complex<double>* data);
535 PMT_API pmt_t init_c64vector(size_t k, const std::vector<std::complex<double>>& data);
536 
537 PMT_API uint8_t u8vector_ref(pmt_t v, size_t k);
538 PMT_API int8_t s8vector_ref(pmt_t v, size_t k);
539 PMT_API uint16_t u16vector_ref(pmt_t v, size_t k);
540 PMT_API int16_t s16vector_ref(pmt_t v, size_t k);
541 PMT_API uint32_t u32vector_ref(pmt_t v, size_t k);
542 PMT_API int32_t s32vector_ref(pmt_t v, size_t k);
543 PMT_API uint64_t u64vector_ref(pmt_t v, size_t k);
544 PMT_API int64_t s64vector_ref(pmt_t v, size_t k);
545 PMT_API float f32vector_ref(pmt_t v, size_t k);
546 PMT_API double f64vector_ref(pmt_t v, size_t k);
547 PMT_API std::complex<float> c32vector_ref(pmt_t v, size_t k);
548 PMT_API std::complex<double> c64vector_ref(pmt_t v, size_t k);
549 
550 PMT_API void u8vector_set(pmt_t v, size_t k, uint8_t x); //< v[k] = x
551 PMT_API void s8vector_set(pmt_t v, size_t k, int8_t x);
552 PMT_API void u16vector_set(pmt_t v, size_t k, uint16_t x);
553 PMT_API void s16vector_set(pmt_t v, size_t k, int16_t x);
554 PMT_API void u32vector_set(pmt_t v, size_t k, uint32_t x);
555 PMT_API void s32vector_set(pmt_t v, size_t k, int32_t x);
556 PMT_API void u64vector_set(pmt_t v, size_t k, uint64_t x);
557 PMT_API void s64vector_set(pmt_t v, size_t k, int64_t x);
558 PMT_API void f32vector_set(pmt_t v, size_t k, float x);
559 PMT_API void f64vector_set(pmt_t v, size_t k, double x);
560 PMT_API void c32vector_set(pmt_t v, size_t k, std::complex<float> x);
561 PMT_API void c64vector_set(pmt_t v, size_t k, std::complex<double> x);
562 
563 // Return const pointers to the elements
564 
565 PMT_API const void*
566 uniform_vector_elements(pmt_t v, size_t& len); //< works with any; len is in bytes
567 
568 PMT_API const uint8_t* u8vector_elements(pmt_t v, size_t& len); //< len is in elements
569 PMT_API const int8_t* s8vector_elements(pmt_t v, size_t& len); //< len is in elements
570 PMT_API const uint16_t* u16vector_elements(pmt_t v, size_t& len); //< len is in elements
571 PMT_API const int16_t* s16vector_elements(pmt_t v, size_t& len); //< len is in elements
572 PMT_API const uint32_t* u32vector_elements(pmt_t v, size_t& len); //< len is in elements
573 PMT_API const int32_t* s32vector_elements(pmt_t v, size_t& len); //< len is in elements
574 PMT_API const uint64_t* u64vector_elements(pmt_t v, size_t& len); //< len is in elements
575 PMT_API const int64_t* s64vector_elements(pmt_t v, size_t& len); //< len is in elements
576 PMT_API const float* f32vector_elements(pmt_t v, size_t& len); //< len is in elements
577 PMT_API const double* f64vector_elements(pmt_t v, size_t& len); //< len is in elements
578 PMT_API const std::complex<float>* c32vector_elements(pmt_t v,
579  size_t& len); //< len is in elements
580 PMT_API const std::complex<double>*
581 c64vector_elements(pmt_t v, size_t& len); //< len is in elements
582 
583 // len is in elements
584 PMT_API const std::vector<uint8_t> u8vector_elements(pmt_t v);
585 PMT_API const std::vector<int8_t> s8vector_elements(pmt_t v);
586 PMT_API const std::vector<uint16_t> u16vector_elements(pmt_t v);
587 PMT_API const std::vector<int16_t> s16vector_elements(pmt_t v);
588 PMT_API const std::vector<uint32_t> u32vector_elements(pmt_t v);
589 PMT_API const std::vector<int32_t> s32vector_elements(pmt_t v);
590 PMT_API const std::vector<uint64_t> u64vector_elements(pmt_t v);
591 PMT_API const std::vector<int64_t> s64vector_elements(pmt_t v);
592 PMT_API const std::vector<float> f32vector_elements(pmt_t v);
593 PMT_API const std::vector<double> f64vector_elements(pmt_t v);
594 PMT_API const std::vector<std::complex<float>> c32vector_elements(pmt_t v);
595 PMT_API const std::vector<std::complex<double>> c64vector_elements(pmt_t v);
596 
597 // Return non-const pointers to the elements
598 
599 PMT_API void*
601  size_t& len); //< works with any; len is in bytes
602 
603 PMT_API uint8_t* u8vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
604 PMT_API int8_t* s8vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
606  size_t& len); //< len is in elements
607 PMT_API int16_t* s16vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
609  size_t& len); //< len is in elements
610 PMT_API int32_t* s32vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
612  size_t& len); //< len is in elements
613 PMT_API int64_t* s64vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
614 PMT_API float* f32vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
615 PMT_API double* f64vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
616 PMT_API std::complex<float>*
617 c32vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
618 PMT_API std::complex<double>*
619 c64vector_writable_elements(pmt_t v, size_t& len); //< len is in elements
620 
621 /*
622  * ------------------------------------------------------------------------
623  * Dictionary (a.k.a associative array, hash, map)
624  *
625  * This is a functional data structure that is persistent. Updating a
626  * functional data structure does not destroy the existing version, but
627  * rather creates a new version that coexists with the old.
628  * ------------------------------------------------------------------------
629  */
630 
631 //! Return true if \p obj is a dictionary
632 PMT_API bool is_dict(const pmt_t& obj);
633 
634 //! Return a newly allocated dict whose car is a key-value pair \p x and whose cdr is a
635 //! dict \p y.
636 PMT_API pmt_t dcons(const pmt_t& x, const pmt_t& y);
637 
638 //! Make an empty dictionary
640 
641 //! Return a new dictionary with \p key associated with \p value.
642 PMT_API pmt_t dict_add(const pmt_t& dict, const pmt_t& key, const pmt_t& value);
643 
644 //! Return a new dictionary with \p key removed.
645 PMT_API pmt_t dict_delete(const pmt_t& dict, const pmt_t& key);
646 
647 //! Return true if \p key exists in \p dict
648 PMT_API bool dict_has_key(const pmt_t& dict, const pmt_t& key);
649 
650 //! If \p key exists in \p dict, return associated value; otherwise return \p not_found.
651 PMT_API pmt_t dict_ref(const pmt_t& dict, const pmt_t& key, const pmt_t& not_found);
652 
653 //! Return list of (key . value) pairs
655 
656 //! Return list of keys
658 
659 //! Return a new dictionary \p dict1 with k=>v pairs from \p dict2 added.
660 PMT_API pmt_t dict_update(const pmt_t& dict1, const pmt_t& dict2);
661 
662 //! Return list of values
664 
665 /*
666  * ------------------------------------------------------------------------
667  * Any (wraps boost::any -- can be used to wrap pretty much anything)
668  *
669  * Cannot be serialized or used across process boundaries.
670  * See http://www.boost.org/doc/html/any.html
671  * ------------------------------------------------------------------------
672  */
673 
674 //! Return true if \p obj is an any
675 PMT_API bool is_any(pmt_t obj);
676 
677 //! make an any
678 PMT_API pmt_t make_any(const boost::any& any);
679 
680 //! Return underlying boost::any
681 PMT_API boost::any any_ref(pmt_t obj);
682 
683 //! Store \p any in \p obj
684 PMT_API void any_set(pmt_t obj, const boost::any& any);
685 
686 
687 /*
688  * ------------------------------------------------------------------------
689  * msg_accepter -- pmt representation of pmt::msg_accepter
690  * ------------------------------------------------------------------------
691  */
692 //! Return true if \p obj is a msg_accepter
693 PMT_API bool is_msg_accepter(const pmt_t& obj);
694 
695 //! make a msg_accepter
696 PMT_API pmt_t make_msg_accepter(std::shared_ptr<gr::messages::msg_accepter> ma);
697 
698 //! Return underlying msg_accepter
699 PMT_API std::shared_ptr<gr::messages::msg_accepter> msg_accepter_ref(const pmt_t& obj);
700 
701 /*
702  * ------------------------------------------------------------------------
703  * General functions
704  * ------------------------------------------------------------------------
705  */
706 
707 /*!
708  * Returns true if the object is a PDU meaning:
709  * the object is a pair
710  * the car is a dictionary type object (including an empty dict)
711  * the cdr is a uniform vector of any type
712  */
713 PMT_API bool is_pdu(const pmt_t& obj);
714 
715 //! Return true if x and y are the same object; otherwise return false.
716 PMT_API bool eq(const pmt_t& x, const pmt_t& y);
717 
718 /*!
719  * \brief Return true if x and y should normally be regarded as the same object, else
720  * false.
721  *
722  * <pre>
723  * eqv returns true if:
724  * x and y are the same object.
725  * x and y are both \#t or both \#f.
726  * x and y are both symbols and their names are the same.
727  * x and y are both numbers, and are numerically equal.
728  * x and y are both the empty list (nil).
729  * x and y are pairs or vectors that denote same location in store.
730  * </pre>
731  */
732 PMT_API bool eqv(const pmt_t& x, const pmt_t& y);
733 
734 /*!
735  * pmt::equal recursively compares the contents of pairs and vectors,
736  * applying pmt::eqv on other objects such as numbers and symbols.
737  * pmt::equal may fail to terminate if its arguments are circular data
738  * structures.
739  */
740 PMT_API bool equal(const pmt_t& x, const pmt_t& y);
741 
742 
743 //! Return the number of elements in v
744 PMT_API size_t length(const pmt_t& v);
745 
746 /*!
747  * \brief Find the first pair in \p alist whose car field is \p obj
748  * and return that pair.
749  *
750  * \p alist (for "association list") must be a list of pairs. If no pair
751  * in \p alist has \p obj as its car then \#f is returned.
752  * Uses pmt::eq to compare \p obj with car fields of the pairs in \p alist.
753  */
755 
756 /*!
757  * \brief Find the first pair in \p alist whose car field is \p obj
758  * and return that pair.
759  *
760  * \p alist (for "association list") must be a list of pairs. If no pair
761  * in \p alist has \p obj as its car then \#f is returned.
762  * Uses pmt::eqv to compare \p obj with car fields of the pairs in \p alist.
763  */
765 
766 /*!
767  * \brief Find the first pair in \p alist whose car field is \p obj
768  * and return that pair.
769  *
770  * \p alist (for "association list") must be a list of pairs. If no pair
771  * in \p alist has \p obj as its car then \#f is returned.
772  * Uses pmt::equal to compare \p obj with car fields of the pairs in \p alist.
773  */
775 
776 /*!
777  * \brief Apply \p proc element-wise to the elements of list and returns
778  * a list of the results, in order.
779  *
780  * \p list must be a list. The dynamic order in which \p proc is
781  * applied to the elements of \p list is unspecified.
782  */
783 PMT_API pmt_t map(pmt_t proc(const pmt_t&), pmt_t list);
784 
785 /*!
786  * \brief reverse \p list.
787  *
788  * \p list must be a proper list.
789  */
790 PMT_API pmt_t reverse(pmt_t list);
791 
792 /*!
793  * \brief destructively reverse \p list.
794  *
795  * \p list must be a proper list.
796  */
798 
799 /*!
800  * \brief (acons x y a) == (cons (cons x y) a)
801  */
802 inline static pmt_t acons(pmt_t x, pmt_t y, pmt_t a) { return dcons(cons(x, y), a); }
803 
804 /*!
805  * \brief locates \p nth element of \n list where the car is the 'zeroth' element.
806  */
807 PMT_API pmt_t nth(size_t n, pmt_t list);
808 
809 /*!
810  * \brief returns the tail of \p list that would be obtained by calling
811  * cdr \p n times in succession.
812  */
813 PMT_API pmt_t nthcdr(size_t n, pmt_t list);
814 
815 /*!
816  * \brief Return the first sublist of \p list whose car is \p obj.
817  * If \p obj does not occur in \p list, then \#f is returned.
818  * pmt::memq use pmt::eq to compare \p obj with the elements of \p list.
819  */
820 PMT_API pmt_t memq(pmt_t obj, pmt_t list);
821 
822 /*!
823  * \brief Return the first sublist of \p list whose car is \p obj.
824  * If \p obj does not occur in \p list, then \#f is returned.
825  * pmt::memv use pmt::eqv to compare \p obj with the elements of \p list.
826  */
827 PMT_API pmt_t memv(pmt_t obj, pmt_t list);
828 
829 /*!
830  * \brief Return the first sublist of \p list whose car is \p obj.
831  * If \p obj does not occur in \p list, then \#f is returned.
832  * pmt::member use pmt::equal to compare \p obj with the elements of \p list.
833  */
834 PMT_API pmt_t member(pmt_t obj, pmt_t list);
835 
836 /*!
837  * \brief Return true if every element of \p list1 appears in \p list2, and false
838  * otherwise. Comparisons are done with pmt::eqv.
839  */
841 
842 /*!
843  * \brief Return a list of length 1 containing \p x1
844  */
845 PMT_API pmt_t list1(const pmt_t& x1);
846 
847 /*!
848  * \brief Return a list of length 2 containing \p x1, \p x2
849  */
850 PMT_API pmt_t list2(const pmt_t& x1, const pmt_t& x2);
851 
852 /*!
853  * \brief Return a list of length 3 containing \p x1, \p x2, \p x3
854  */
855 PMT_API pmt_t list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3);
856 
857 /*!
858  * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4
859  */
860 PMT_API pmt_t list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4);
861 
862 /*!
863  * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p x5
864  */
866  const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5);
867 
868 /*!
869  * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p
870  * x5, \p x6
871  */
872 PMT_API pmt_t list6(const pmt_t& x1,
873  const pmt_t& x2,
874  const pmt_t& x3,
875  const pmt_t& x4,
876  const pmt_t& x5,
877  const pmt_t& x6);
878 
879 /*!
880  * \brief Return \p list with \p item added to it.
881  */
882 PMT_API pmt_t list_add(pmt_t list, const pmt_t& item);
883 
884 /*!
885  * \brief Return \p list with \p item removed from it.
886  */
887 PMT_API pmt_t list_rm(pmt_t list, const pmt_t& item);
888 
889 /*!
890  * \brief Return bool of \p list contains \p item
891  */
892 PMT_API bool list_has(pmt_t list, const pmt_t& item);
893 
894 
895 /*
896  * ------------------------------------------------------------------------
897  * read / write
898  * ------------------------------------------------------------------------
899  */
900 
901 //! return true if obj is the EOF object, otherwise return false.
902 PMT_API bool is_eof_object(pmt_t obj);
903 
904 /*!
905  * read converts external representations of pmt objects into the
906  * objects themselves. Read returns the next object parsable from
907  * the given input port, updating port to point to the first
908  * character past the end of the external representation of the
909  * object.
910  *
911  * If an end of file is encountered in the input before any
912  * characters are found that can begin an object, then an end of file
913  * object is returned. The port remains open, and further attempts
914  * to read will also return an end of file object. If an end of file
915  * is encountered after the beginning of an object's external
916  * representation, but the external representation is incomplete and
917  * therefore not parsable, an error is signaled.
918  */
919 PMT_API pmt_t read(std::istream& port);
920 
921 /*!
922  * Write a written representation of \p obj to the given \p port.
923  */
924 PMT_API void write(pmt_t obj, std::ostream& port);
925 
926 /*!
927  * Return a string representation of \p obj.
928  * This is the same output as would be generated by pmt::write.
929  */
930 PMT_API std::string write_string(pmt_t obj);
931 
932 
933 PMT_API std::ostream& operator<<(std::ostream& os, pmt_t obj);
934 
935 /*!
936  * \brief Write pmt string representation to stdout.
937  */
938 PMT_API void print(pmt_t v);
939 
940 
941 /*
942  * ------------------------------------------------------------------------
943  * portable byte stream representation
944  * ------------------------------------------------------------------------
945  */
946 /*!
947  * \brief Write portable byte-serial representation of \p obj to \p sink
948  */
949 PMT_API bool serialize(pmt_t obj, std::streambuf& sink);
950 
951 /*!
952  * \brief Create obj from portable byte-serial representation
953  */
954 PMT_API pmt_t deserialize(std::streambuf& source);
955 
956 
957 PMT_API void dump_sizeof(); // debugging
958 
959 /*!
960  * \brief Provide a simple string generating interface to pmt's serialize function
961  */
962 PMT_API std::string serialize_str(pmt_t obj);
963 
964 /*!
965  * \brief Provide a simple string generating interface to pmt's deserialize function
966  */
967 PMT_API pmt_t deserialize_str(std::string str);
968 
969 /*!
970  * \brief Provide a comparator function object to allow pmt use in stl types
971  */
973 {
974 public:
975  bool operator()(pmt::pmt_t const& p1, pmt::pmt_t const& p2) const
976  {
977  return pmt::eqv(p1, p2) ? false : p1.get() > p2.get();
978  }
979 };
980 
981 } /* namespace pmt */
982 
983 #include <pmt/pmt_sugar.h>
984 
985 #endif /* INCLUDED_PMT_H */
pmt::pmt_base::is_c32vector
virtual bool is_c32vector() const
Definition: pmt.h:77
pmt::caar
PMT_API pmt_t caar(pmt_t pair)
pmt::is_dict
PMT_API bool is_dict(const pmt_t &obj)
Return true if obj is a dictionary.
pmt::s64vector_writable_elements
PMT_API int64_t * s64vector_writable_elements(pmt_t v, size_t &len)
pmt::s16vector_set
PMT_API void s16vector_set(pmt_t v, size_t k, int16_t x)
pmt::s16vector_elements
const PMT_API int16_t * s16vector_elements(pmt_t v, size_t &len)
pmt::make_s32vector
PMT_API pmt_t make_s32vector(size_t k, int32_t fill)
pmt::init_f64vector
PMT_API pmt_t init_f64vector(size_t k, const double *data)
pmt::serialize
PMT_API bool serialize(pmt_t obj, std::streambuf &sink)
Write portable byte-serial representation of obj to sink.
pmt::make_dict
PMT_API pmt_t make_dict()
Make an empty dictionary.
pmt::pmt_base::is_null
virtual bool is_null() const
Definition: pmt.h:59
pmt::make_f64vector
PMT_API pmt_t make_f64vector(size_t k, double fill)
pmt::assoc
PMT_API pmt_t assoc(pmt_t obj, pmt_t alist)
Find the first pair in alist whose car field is obj and return that pair.
pmt::u16vector_elements
const PMT_API uint16_t * u16vector_elements(pmt_t v, size_t &len)
pmt::blob_data
const PMT_API void * blob_data(pmt_t blob)
Return a pointer to the blob's data.
pmt::any_set
PMT_API void any_set(pmt_t obj, const boost::any &any)
Store any in obj.
pmt::caddr
PMT_API pmt_t caddr(pmt_t pair)
pmt::print
PMT_API void print(pmt_t v)
Write pmt string representation to stdout.
pmt::init_c64vector
PMT_API pmt_t init_c64vector(size_t k, const std::complex< double > *data)
pmt::s16vector_writable_elements
PMT_API int16_t * s16vector_writable_elements(pmt_t v, size_t &len)
pmt::nth
PMT_API pmt_t nth(size_t n, pmt_t list)
locates nth element of list where the car is the 'zeroth' element.
pmt::s64vector_ref
PMT_API int64_t s64vector_ref(pmt_t v, size_t k)
pmt::list_add
PMT_API pmt_t list_add(pmt_t list, const pmt_t &item)
Return list with item added to it.
pmt::to_double
PMT_API double to_double(pmt_t x)
Convert pmt to double if possible.
pmt::dcons
PMT_API pmt_t dcons(const pmt_t &x, const pmt_t &y)
Return a newly allocated dict whose car is a key-value pair x and whose cdr is a dict y.
pmt::dict_update
PMT_API pmt_t dict_update(const pmt_t &dict1, const pmt_t &dict2)
Return a new dictionary dict1 with k=>v pairs from dict2 added.
pmt::s8vector_set
PMT_API void s8vector_set(pmt_t v, size_t k, int8_t x)
pmt::f64vector_set
PMT_API void f64vector_set(pmt_t v, size_t k, double x)
pmt::c32vector_ref
PMT_API std::complex< float > c32vector_ref(pmt_t v, size_t k)
pmt::blob_length
PMT_API size_t blob_length(pmt_t blob)
Return the blob's length in bytes.
pmt::map
PMT_API pmt_t map(pmt_t proc(const pmt_t &), pmt_t list)
Apply proc element-wise to the elements of list and returns a list of the results,...
pmt::is_complex
PMT_API bool is_complex(pmt_t obj)
return true if obj is a complex number, false otherwise.
pmt::dict_ref
PMT_API pmt_t dict_ref(const pmt_t &dict, const pmt_t &key, const pmt_t &not_found)
If key exists in dict, return associated value; otherwise return not_found.
pmt::pmt_base::is_pair
virtual bool is_pair() const
Definition: pmt.h:60
pmt::make_vector
PMT_API pmt_t make_vector(size_t k, pmt_t fill)
Make a vector of length k, with initial values set to fill.
pmt::pmt_from_complex
PMT_API pmt_t pmt_from_complex(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
pmt::pmt_base::is_u64vector
virtual bool is_u64vector() const
Definition: pmt.h:73
pmt::get_PMT_NIL
PMT_API pmt_t get_PMT_NIL()
pmt::acons
static pmt_t acons(pmt_t x, pmt_t y, pmt_t a)
(acons x y a) == (cons (cons x y) a)
Definition: pmt.h:802
pmt::get_PMT_F
PMT_API pmt_t get_PMT_F()
pmt::is_f64vector
PMT_API bool is_f64vector(pmt_t x)
pmt::list_rm
PMT_API pmt_t list_rm(pmt_t list, const pmt_t &item)
Return list with item removed from it.
pmt::u32vector_ref
PMT_API uint32_t u32vector_ref(pmt_t v, size_t k)
pmt::symbol_to_string
const PMT_API std::string symbol_to_string(const pmt_t &sym)
pmt::u64vector_writable_elements
PMT_API uint64_t * u64vector_writable_elements(pmt_t v, size_t &len)
pmt::to_complex
PMT_API std::complex< double > to_complex(pmt_t z)
pmt::c64vector_ref
PMT_API std::complex< double > c64vector_ref(pmt_t v, size_t k)
pmt::is_false
PMT_API bool is_false(pmt_t obj)
Return true if obj is #f, else return true.
pmt::pmt_base::is_real
virtual bool is_real() const
Definition: pmt.h:57
pmt::vector_fill
PMT_API void vector_fill(pmt_t vector, pmt_t fill)
Store fill in every position of vector.
pmt::pmt_base::is_c64vector
virtual bool is_c64vector() const
Definition: pmt.h:78
pmt::any_ref
PMT_API boost::any any_ref(pmt_t obj)
Return underlying boost::any.
pmt::is_number
PMT_API bool is_number(pmt_t obj)
Return true if obj is any kind of number, else false.
pmt::make_tuple
PMT_API pmt_t make_tuple()
pmt::s8vector_ref
PMT_API int8_t s8vector_ref(pmt_t v, size_t k)
pmt::to_bool
PMT_API bool to_bool(pmt_t val)
Return true if val is pmt::True, return false when val is pmt::PMT_F,.
pmt::is_c32vector
PMT_API bool is_c32vector(pmt_t x)
pmt::get_PMT_EOF
PMT_API pmt_t get_PMT_EOF()
pmt::s16vector_ref
PMT_API int16_t s16vector_ref(pmt_t v, size_t k)
pmt::is_eof_object
PMT_API bool is_eof_object(pmt_t obj)
return true if obj is the EOF object, otherwise return false.
pmt::pmt_base::is_s64vector
virtual bool is_s64vector() const
Definition: pmt.h:74
pmt::is_s64vector
PMT_API bool is_s64vector(pmt_t x)
pmt::vector_ref
PMT_API pmt_t vector_ref(pmt_t vector, size_t k)
pmt::u64vector_elements
const PMT_API uint64_t * u64vector_elements(pmt_t v, size_t &len)
pmt::dump_sizeof
PMT_API void dump_sizeof()
pmt::list4
PMT_API pmt_t list4(const pmt_t &x1, const pmt_t &x2, const pmt_t &x3, const pmt_t &x4)
Return a list of length 4 containing x1, x2, x3, x4.
pmt::string_to_symbol
PMT_API pmt_t string_to_symbol(const std::string &s)
Return the symbol whose name is s.
pmt::is_blob
PMT_API bool is_blob(pmt_t x)
Return true if x is a blob, otherwise false.
pmt::init_s64vector
PMT_API pmt_t init_s64vector(size_t k, const int64_t *data)
pmt::deserialize
PMT_API pmt_t deserialize(std::streambuf &source)
Create obj from portable byte-serial representation.
pmt::f32vector_set
PMT_API void f32vector_set(pmt_t v, size_t k, float x)
pmt::nthcdr
PMT_API pmt_t nthcdr(size_t n, pmt_t list)
returns the tail of list that would be obtained by calling cdr n times in succession.
pmt::set_car
PMT_API void set_car(pmt_t pair, pmt_t value)
Stores value in the car field of pair.
pmt::make_s8vector
PMT_API pmt_t make_s8vector(size_t k, int8_t fill)
pmt::init_f32vector
PMT_API pmt_t init_f32vector(size_t k, const float *data)
pmt_sugar.h
pmt::make_s64vector
PMT_API pmt_t make_s64vector(size_t k, int64_t fill)
pmt::pmt_base::is_dict
virtual bool is_dict() const
Definition: pmt.h:63
pmt::is_uint64
PMT_API bool is_uint64(pmt_t x)
Return true if x is an uint64 number, else false.
pmt::init_s32vector
PMT_API pmt_t init_s32vector(size_t k, const int32_t *data)
pmt::cadddr
PMT_API pmt_t cadddr(pmt_t pair)
pmt::comparator
Provide a comparator function object to allow pmt use in stl types.
Definition: pmt.h:972
pmt::is_msg_accepter
PMT_API bool is_msg_accepter(const pmt_t &obj)
Return true if obj is a msg_accepter.
pmt::pmt_base::is_s8vector
virtual bool is_s8vector() const
Definition: pmt.h:68
pmt::is_symbol
PMT_API bool is_symbol(const pmt_t &obj)
Return true if obj is a symbol, else false.
pmt::wrong_type
Definition: pmt.h:92
pmt::reverse
PMT_API pmt_t reverse(pmt_t list)
reverse list.
pmt::is_u8vector
PMT_API bool is_u8vector(pmt_t x)
pmt::subsetp
PMT_API bool subsetp(pmt_t list1, pmt_t list2)
Return true if every element of list1 appears in list2, and false otherwise. Comparisons are done wit...
pmt::is_pdu
PMT_API bool is_pdu(const pmt_t &obj)
pmt::s64vector_set
PMT_API void s64vector_set(pmt_t v, size_t k, int64_t x)
pmt::assv
PMT_API pmt_t assv(pmt_t obj, pmt_t alist)
Find the first pair in alist whose car field is obj and return that pair.
pmt::is_tuple
PMT_API bool is_tuple(pmt_t x)
Return true if x is a tuple, otherwise false.
pmt::u32vector_writable_elements
PMT_API uint32_t * u32vector_writable_elements(pmt_t v, size_t &len)
pmt::u8vector_set
PMT_API void u8vector_set(pmt_t v, size_t k, uint8_t x)
PMT_API
#define PMT_API
Definition: gnuradio-runtime/include/pmt/api.h:18
pmt::pmt_base
base class of all pmt types
Definition: pmt.h:44
pmt::make_u32vector
PMT_API pmt_t make_u32vector(size_t k, uint32_t fill)
pmt::is_f32vector
PMT_API bool is_f32vector(pmt_t x)
pmt::notimplemented
Definition: pmt.h:104
pmt::list2
PMT_API pmt_t list2(const pmt_t &x1, const pmt_t &x2)
Return a list of length 2 containing x1, x2.
pmt::pmt_base::is_number
virtual bool is_number() const
Definition: pmt.h:54
v
Definition: cc_common.h:35
pmt::is_u32vector
PMT_API bool is_u32vector(pmt_t x)
pmt::is_s32vector
PMT_API bool is_s32vector(pmt_t x)
pmt::from_float
PMT_API pmt_t from_float(float x)
pmt::dict_has_key
PMT_API bool dict_has_key(const pmt_t &dict, const pmt_t &key)
Return true if key exists in dict.
pmt::tuple_ref
PMT_API pmt_t tuple_ref(const pmt_t &tuple, size_t k)
api.h
pmt::is_pair
PMT_API bool is_pair(const pmt_t &obj)
Return true if obj is a pair, else false (warning: also returns true for a dict)
pmt::make_c32vector
PMT_API pmt_t make_c32vector(size_t k, std::complex< float > fill)
pmt::to_float
PMT_API float to_float(pmt_t x)
Convert pmt to float if possible.
pmt::s8vector_writable_elements
PMT_API int8_t * s8vector_writable_elements(pmt_t v, size_t &len)
pmt::list6
PMT_API pmt_t list6(const pmt_t &x1, const pmt_t &x2, const pmt_t &x3, const pmt_t &x4, const pmt_t &x5, const pmt_t &x6)
Return a list of length 6 containing x1, x2, x3, x4, x5, x6.
pmt::u8vector_writable_elements
PMT_API uint8_t * u8vector_writable_elements(pmt_t v, size_t &len)
pmt::s32vector_writable_elements
PMT_API int32_t * s32vector_writable_elements(pmt_t v, size_t &len)
pmt::cdar
PMT_API pmt_t cdar(pmt_t pair)
pmt::u32vector_elements
const PMT_API uint32_t * u32vector_elements(pmt_t v, size_t &len)
pmt::c64vector_set
PMT_API void c64vector_set(pmt_t v, size_t k, std::complex< double > x)
pmt::init_u16vector
PMT_API pmt_t init_u16vector(size_t k, const uint16_t *data)
pmt::init_u64vector
PMT_API pmt_t init_u64vector(size_t k, const uint64_t *data)
pmt::eqv
PMT_API bool eqv(const pmt_t &x, const pmt_t &y)
Return true if x and y should normally be regarded as the same object, else false.
pmt::u8vector_ref
PMT_API uint8_t u8vector_ref(pmt_t v, size_t k)
pmt::is_s16vector
PMT_API bool is_s16vector(pmt_t x)
pmt::s32vector_set
PMT_API void s32vector_set(pmt_t v, size_t k, int32_t x)
pmt::from_bool
PMT_API pmt_t from_bool(bool val)
Return #f is val is false, else return #t.
alist
Definition: alist.h:32
pmt::is_s8vector
PMT_API bool is_s8vector(pmt_t x)
pmt::f64vector_ref
PMT_API double f64vector_ref(pmt_t v, size_t k)
pmt::is_bool
PMT_API bool is_bool(pmt_t obj)
Return true if obj is #t or #f, else return false.
pmt::get_PMT_T
PMT_API pmt_t get_PMT_T()
pmt::is_u16vector
PMT_API bool is_u16vector(pmt_t x)
pmt::u8vector_elements
const PMT_API uint8_t * u8vector_elements(pmt_t v, size_t &len)
pmt::eq
PMT_API bool eq(const pmt_t &x, const pmt_t &y)
Return true if x and y are the same object; otherwise return false.
pmt::write
PMT_API void write(pmt_t obj, std::ostream &port)
pmt::c32vector_writable_elements
PMT_API std::complex< float > * c32vector_writable_elements(pmt_t v, size_t &len)
pmt::make_any
PMT_API pmt_t make_any(const boost::any &any)
make an any
pmt::car
PMT_API pmt_t car(const pmt_t &pair)
If pair is a pair, return the car of the pair, otherwise raise wrong_type.
pmt::pmt_base::pmt_base
pmt_base()
Definition: pmt.h:48
pmt::f64vector_writable_elements
PMT_API double * f64vector_writable_elements(pmt_t v, size_t &len)
pmt::c32vector_set
PMT_API void c32vector_set(pmt_t v, size_t k, std::complex< float > x)
pmt::f32vector_writable_elements
PMT_API float * f32vector_writable_elements(pmt_t v, size_t &len)
pmt::cddr
PMT_API pmt_t cddr(pmt_t pair)
pmt::pmt_base::is_vector
virtual bool is_vector() const
Definition: pmt.h:62
pmt::pmt_base::is_s32vector
virtual bool is_s32vector() const
Definition: pmt.h:72
pmt::init_u8vector
PMT_API pmt_t init_u8vector(size_t k, const uint8_t *data)
pmt::init_s16vector
PMT_API pmt_t init_s16vector(size_t k, const int16_t *data)
pmt::pmt_base::is_s16vector
virtual bool is_s16vector() const
Definition: pmt.h:70
pmt::s32vector_ref
PMT_API int32_t s32vector_ref(pmt_t v, size_t k)
pmt::to_tuple
PMT_API pmt_t to_tuple(const pmt_t &x)
pmt::f32vector_elements
const PMT_API float * f32vector_elements(pmt_t v, size_t &len)
pmt::pmt_base::is_tuple
virtual bool is_tuple() const
Definition: pmt.h:61
pmt::s8vector_elements
const PMT_API int8_t * s8vector_elements(pmt_t v, size_t &len)
pmt::uniform_vector_elements
const PMT_API void * uniform_vector_elements(pmt_t v, size_t &len)
pmt::write_string
PMT_API std::string write_string(pmt_t obj)
pmt::list3
PMT_API pmt_t list3(const pmt_t &x1, const pmt_t &x2, const pmt_t &x3)
Return a list of length 3 containing x1, x2, x3.
pmt::pmt_base::is_integer
virtual bool is_integer() const
Definition: pmt.h:55
pmt::list5
PMT_API pmt_t list5(const pmt_t &x1, const pmt_t &x2, const pmt_t &x3, const pmt_t &x4, const pmt_t &x5)
Return a list of length 5 containing x1, x2, x3, x4, x5.
pmt::make_u16vector
PMT_API pmt_t make_u16vector(size_t k, uint16_t fill)
pmt::uniform_vector_itemsize
PMT_API size_t uniform_vector_itemsize(pmt_t x)
item size in bytes if x is any kind of uniform numeric vector
pmt::is_c64vector
PMT_API bool is_c64vector(pmt_t x)
pmt::is_real
PMT_API bool is_real(pmt_t obj)
pmt::reverse_x
PMT_API pmt_t reverse_x(pmt_t list)
destructively reverse list.
pmt::memv
PMT_API pmt_t memv(pmt_t obj, pmt_t list)
Return the first sublist of list whose car is obj. If obj does not occur in list, then #f is returned...
pmt::pmt_t
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:84
pmt::from_complex
PMT_API pmt_t from_complex(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
pmt::pmt_base::is_symbol
virtual bool is_symbol() const
Definition: pmt.h:53
pmt::to_long
PMT_API long to_long(pmt_t x)
Convert pmt to long if possible.
pmt::is_uniform_vector
PMT_API bool is_uniform_vector(pmt_t x)
true if x is any kind of uniform numeric vector
pmt::memq
PMT_API pmt_t memq(pmt_t obj, pmt_t list)
Return the first sublist of list whose car is obj. If obj does not occur in list, then #f is returned...
pmt::pmt_base::is_u8vector
virtual bool is_u8vector() const
Definition: pmt.h:67
pmt::comparator::operator()
bool operator()(pmt::pmt_t const &p1, pmt::pmt_t const &p2) const
Definition: pmt.h:975
pmt::from_double
PMT_API pmt_t from_double(double x)
Return the pmt value that represents double x.
pmt::set_cdr
PMT_API void set_cdr(pmt_t pair, pmt_t value)
Stores value in the cdr field of pair.
pmt::s32vector_elements
const PMT_API int32_t * s32vector_elements(pmt_t v, size_t &len)
pmt::make_f32vector
PMT_API pmt_t make_f32vector(size_t k, float fill)
pmt::dict_keys
PMT_API pmt_t dict_keys(pmt_t dict)
Return list of keys.
pmt::pmt_base::is_any
virtual bool is_any() const
Definition: pmt.h:64
pmt::cdr
PMT_API pmt_t cdr(const pmt_t &pair)
If pair is a pair, return the cdr of the pair, otherwise raise wrong_type.
pmt::make_rectangular
PMT_API pmt_t make_rectangular(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
pmt::vector_set
PMT_API void vector_set(pmt_t vector, size_t k, pmt_t obj)
Store obj in position k.
pmt::list_has
PMT_API bool list_has(pmt_t list, const pmt_t &item)
Return bool of list contains item.
pmt::read
PMT_API pmt_t read(std::istream &port)
pmt::make_u8vector
PMT_API pmt_t make_u8vector(size_t k, uint8_t fill)
pmt::pmt_base::is_uint64
virtual bool is_uint64() const
Definition: pmt.h:56
pmt::pmt_base::is_bool
virtual bool is_bool() const
Definition: pmt.h:52
pmt::is_integer
PMT_API bool is_integer(pmt_t x)
Return true if x is an integer number, else false.
pmt::from_uint64
PMT_API pmt_t from_uint64(uint64_t x)
Return the pmt value that represents the uint64 x.
gr
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29
pmt::pmt_base::is_f64vector
virtual bool is_f64vector() const
Definition: pmt.h:76
pmt::u16vector_ref
PMT_API uint16_t u16vector_ref(pmt_t v, size_t k)
pmt::is_null
PMT_API bool is_null(const pmt_t &x)
Return true if x is the empty list, otherwise return false.
pmt::make_blob
PMT_API pmt_t make_blob(const void *buf, size_t len)
Make a blob given a pointer and length in bytes.
pmt::cadr
PMT_API pmt_t cadr(pmt_t pair)
pmt::serialize_str
PMT_API std::string serialize_str(pmt_t obj)
Provide a simple string generating interface to pmt's serialize function.
pmt::member
PMT_API pmt_t member(pmt_t obj, pmt_t list)
Return the first sublist of list whose car is obj. If obj does not occur in list, then #f is returned...
pmt::is_true
PMT_API bool is_true(pmt_t obj)
Return false if obj is #f, else return true.
pmt::pmt_base::is_f32vector
virtual bool is_f32vector() const
Definition: pmt.h:75
pmt::f32vector_ref
PMT_API float f32vector_ref(pmt_t v, size_t k)
pmt::c32vector_elements
const PMT_API std::complex< float > * c32vector_elements(pmt_t v, size_t &len)
pmt::out_of_range
Definition: pmt.h:98
pmt::is_any
PMT_API bool is_any(pmt_t obj)
Return true if obj is an any.
pmt::from_long
PMT_API pmt_t from_long(long x)
Return the pmt value that represents the integer x.
pmt::pmt_base::is_u32vector
virtual bool is_u32vector() const
Definition: pmt.h:71
pmt
Definition: pmt.h:39
pmt::deserialize_str
PMT_API pmt_t deserialize_str(std::string str)
Provide a simple string generating interface to pmt's deserialize function.
pmt::pmt_base::is_u16vector
virtual bool is_u16vector() const
Definition: pmt.h:69
pmt::intern
PMT_API pmt_t intern(const std::string &s)
Alias for pmt_string_to_symbol.
pmt::dict_add
PMT_API pmt_t dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t &value)
Return a new dictionary with key associated with value.
pmt::dict_delete
PMT_API pmt_t dict_delete(const pmt_t &dict, const pmt_t &key)
Return a new dictionary with key removed.
pmt::s64vector_elements
const PMT_API int64_t * s64vector_elements(pmt_t v, size_t &len)
pmt::dict_values
PMT_API pmt_t dict_values(pmt_t dict)
Return list of values.
pmt::u64vector_set
PMT_API void u64vector_set(pmt_t v, size_t k, uint64_t x)
pmt::length
PMT_API size_t length(const pmt_t &v)
Return the number of elements in v.
pmt::pmt_base::is_uniform_vector
virtual bool is_uniform_vector() const
Definition: pmt.h:66
pmt::dict_items
PMT_API pmt_t dict_items(pmt_t dict)
Return list of (key . value) pairs.
pmt::init_u32vector
PMT_API pmt_t init_u32vector(size_t k, const uint32_t *data)
pmt::uniform_vector_writable_elements
PMT_API void * uniform_vector_writable_elements(pmt_t v, size_t &len)
pmt::init_c32vector
PMT_API pmt_t init_c32vector(size_t k, const std::complex< float > *data)
pmt::init_s8vector
PMT_API pmt_t init_s8vector(size_t k, const int8_t *data)
pmt::equal
PMT_API bool equal(const pmt_t &x, const pmt_t &y)
pmt::u16vector_set
PMT_API void u16vector_set(pmt_t v, size_t k, uint16_t x)
pmt::is_vector
PMT_API bool is_vector(pmt_t x)
Return true if x is a vector, otherwise false.
pmt::to_uint64
PMT_API uint64_t to_uint64(pmt_t x)
Convert pmt to uint64 if possible.
pmt::make_msg_accepter
PMT_API pmt_t make_msg_accepter(std::shared_ptr< gr::messages::msg_accepter > ma)
make a msg_accepter
pmt::list1
PMT_API pmt_t list1(const pmt_t &x1)
Return a list of length 1 containing x1.
pmt::c64vector_elements
const PMT_API std::complex< double > * c64vector_elements(pmt_t v, size_t &len)
pmt::u32vector_set
PMT_API void u32vector_set(pmt_t v, size_t k, uint32_t x)
pmt::u64vector_ref
PMT_API uint64_t u64vector_ref(pmt_t v, size_t k)
pmt::is_u64vector
PMT_API bool is_u64vector(pmt_t x)
pmt::make_s16vector
PMT_API pmt_t make_s16vector(size_t k, int16_t fill)
pmt::make_c64vector
PMT_API pmt_t make_c64vector(size_t k, std::complex< double > fill)
pmt::cons
PMT_API pmt_t cons(const pmt_t &x, const pmt_t &y)
Return a newly allocated pair whose car is x and whose cdr is y.
pmt::pmt_base::is_complex
virtual bool is_complex() const
Definition: pmt.h:58
pmt::c64vector_writable_elements
PMT_API std::complex< double > * c64vector_writable_elements(pmt_t v, size_t &len)
pmt::u16vector_writable_elements
PMT_API uint16_t * u16vector_writable_elements(pmt_t v, size_t &len)
pmt::assq
PMT_API pmt_t assq(pmt_t obj, pmt_t alist)
Find the first pair in alist whose car field is obj and return that pair.
pmt::msg_accepter_ref
PMT_API std::shared_ptr< gr::messages::msg_accepter > msg_accepter_ref(const pmt_t &obj)
Return underlying msg_accepter.
pmt::operator<<
PMT_API std::ostream & operator<<(std::ostream &os, pmt_t obj)
pmt::make_u64vector
PMT_API pmt_t make_u64vector(size_t k, uint64_t fill)
pmt::f64vector_elements
const PMT_API double * f64vector_elements(pmt_t v, size_t &len)
pmt::exception
Definition: pmt.h:86