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