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