GNU Radio C++ API Reference 3.10.12.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
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/*!
641 * \brief Make a dictionary from an existing mapping type.
642 * The constraint for this to work is the ability for the map_t to iterate over [key,
643 * value] pairs, that is, to be able to be used in a
644 *
645 * <pre>for(const auto& [key, val] : prototype)</pre>
646 *
647 * loop.
648 */
649template <typename map_t>
650pmt_t dict_from_mapping(const map_t& prototype)
651{
652 pmt_t protodict = make_dict();
653 for (const auto& [key, value] : prototype) {
654 protodict = dict_add(protodict, key, value);
655 }
656 return protodict;
657}
658
659//! Return a new dictionary with \p key associated with \p value.
660PMT_API pmt_t dict_add(const pmt_t& dict, const pmt_t& key, const pmt_t& value);
661
662//! Return a new dictionary with \p key removed.
663PMT_API pmt_t dict_delete(const pmt_t& dict, const pmt_t& key);
664
665//! Return true if \p key exists in \p dict
666PMT_API bool dict_has_key(const pmt_t& dict, const pmt_t& key);
667
668//! If \p key exists in \p dict, return associated value; otherwise return \p not_found.
669PMT_API pmt_t dict_ref(const pmt_t& dict, const pmt_t& key, const pmt_t& not_found);
670
671//! Return list of (key . value) pairs
673
674//! Return list of keys
676
677//! Return a new dictionary \p dict1 with k=>v pairs from \p dict2 added.
678PMT_API pmt_t dict_update(const pmt_t& dict1, const pmt_t& dict2);
679
680//! Return list of values
682
683/*
684 * ------------------------------------------------------------------------
685 * Any (wraps boost::any -- can be used to wrap pretty much anything)
686 *
687 * Cannot be serialized or used across process boundaries.
688 * See http://www.boost.org/doc/html/any.html
689 * ------------------------------------------------------------------------
690 */
691
692//! Return true if \p obj is an any
694
695//! make an any
696PMT_API pmt_t make_any(const boost::any& any);
697
698//! Return underlying boost::any
699PMT_API boost::any any_ref(pmt_t obj);
700
701//! Store \p any in \p obj
702PMT_API void any_set(pmt_t obj, const boost::any& any);
703
704
705/*
706 * ------------------------------------------------------------------------
707 * msg_accepter -- pmt representation of pmt::msg_accepter
708 * ------------------------------------------------------------------------
709 */
710//! Return true if \p obj is a msg_accepter
712
713//! make a msg_accepter
714PMT_API pmt_t make_msg_accepter(std::shared_ptr<gr::messages::msg_accepter> ma);
715
716//! Return underlying msg_accepter
717PMT_API std::shared_ptr<gr::messages::msg_accepter> msg_accepter_ref(const pmt_t& obj);
718
719/*
720 * ------------------------------------------------------------------------
721 * General functions
722 * ------------------------------------------------------------------------
723 */
724
725/*!
726 * Returns true if the object is a PDU meaning:
727 * the object is a pair
728 * the car is a dictionary type object (including an empty dict)
729 * the cdr is a uniform vector of any type
730 */
731PMT_API bool is_pdu(const pmt_t& obj);
732
733//! Return true if x and y are the same object; otherwise return false.
734PMT_API bool eq(const pmt_t& x, const pmt_t& y);
735
736/*!
737 * \brief Return true if x and y should normally be regarded as the same object, else
738 * false.
739 *
740 * <pre>
741 * eqv returns true if:
742 * x and y are the same object.
743 * x and y are both \#t or both \#f.
744 * x and y are both symbols and their names are the same.
745 * x and y are both numbers, and are numerically equal.
746 * x and y are both the empty list (nil).
747 * x and y are pairs or vectors that denote same location in store.
748 * </pre>
749 */
750PMT_API bool eqv(const pmt_t& x, const pmt_t& y);
751
752/*!
753 * pmt::equal recursively compares the contents of pairs and vectors,
754 * applying pmt::eqv on other objects such as numbers and symbols.
755 * pmt::equal may fail to terminate if its arguments are circular data
756 * structures.
757 */
758PMT_API bool equal(const pmt_t& x, const pmt_t& y);
759
760
761//! Return the number of elements in v
762PMT_API size_t length(const pmt_t& v);
763
764/*!
765 * \brief Find the first pair in \p alist whose car field is \p obj
766 * and return that pair.
767 *
768 * \p alist (for "association list") must be a list of pairs. If no pair
769 * in \p alist has \p obj as its car then \#f is returned.
770 * Uses pmt::eq to compare \p obj with car fields of the pairs in \p alist.
771 */
773
774/*!
775 * \brief Find the first pair in \p alist whose car field is \p obj
776 * and return that pair.
777 *
778 * \p alist (for "association list") must be a list of pairs. If no pair
779 * in \p alist has \p obj as its car then \#f is returned.
780 * Uses pmt::eqv to compare \p obj with car fields of the pairs in \p alist.
781 */
783
784/*!
785 * \brief Find the first pair in \p alist whose car field is \p obj
786 * and return that pair.
787 *
788 * \p alist (for "association list") must be a list of pairs. If no pair
789 * in \p alist has \p obj as its car then \#f is returned.
790 * Uses pmt::equal to compare \p obj with car fields of the pairs in \p alist.
791 */
793
794/*!
795 * \brief Apply \p proc element-wise to the elements of list and returns
796 * a list of the results, in order.
797 *
798 * \p list must be a list. The dynamic order in which \p proc is
799 * applied to the elements of \p list is unspecified.
800 */
801PMT_API pmt_t map(pmt_t proc(const pmt_t&), pmt_t list);
802
803/*!
804 * \brief reverse \p list.
805 *
806 * \p list must be a proper list.
807 */
809
810/*!
811 * \brief destructively reverse \p list.
812 *
813 * \p list must be a proper list.
814 */
816
817/*!
818 * \brief (acons x y a) == (cons (cons x y) a)
819 */
820inline static pmt_t acons(pmt_t x, pmt_t y, pmt_t a) { return dcons(cons(x, y), a); }
821
822/*!
823 * \brief locates \p nth element of \n list where the car is the 'zeroth' element.
824 */
825PMT_API pmt_t nth(size_t n, pmt_t list);
826
827/*!
828 * \brief returns the tail of \p list that would be obtained by calling
829 * cdr \p n times in succession.
830 */
831PMT_API pmt_t nthcdr(size_t n, pmt_t list);
832
833/*!
834 * \brief Return the first sublist of \p list whose car is \p obj.
835 * If \p obj does not occur in \p list, then \#f is returned.
836 * pmt::memq use pmt::eq to compare \p obj with the elements of \p list.
837 */
839
840/*!
841 * \brief Return the first sublist of \p list whose car is \p obj.
842 * If \p obj does not occur in \p list, then \#f is returned.
843 * pmt::memv use pmt::eqv to compare \p obj with the elements of \p list.
844 */
846
847/*!
848 * \brief Return the first sublist of \p list whose car is \p obj.
849 * If \p obj does not occur in \p list, then \#f is returned.
850 * pmt::member use pmt::equal to compare \p obj with the elements of \p list.
851 */
853
854/*!
855 * \brief Return true if every element of \p list1 appears in \p list2, and false
856 * otherwise. Comparisons are done with pmt::eqv.
857 */
859
860/*!
861 * \brief Return a list of length 1 containing \p x1
862 */
864
865/*!
866 * \brief Return a list of length 2 containing \p x1, \p x2
867 */
868PMT_API pmt_t list2(const pmt_t& x1, const pmt_t& x2);
869
870/*!
871 * \brief Return a list of length 3 containing \p x1, \p x2, \p x3
872 */
873PMT_API pmt_t list3(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3);
874
875/*!
876 * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4
877 */
878PMT_API pmt_t list4(const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4);
879
880/*!
881 * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p x5
882 */
884 const pmt_t& x1, const pmt_t& x2, const pmt_t& x3, const pmt_t& x4, const pmt_t& x5);
885
886/*!
887 * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p
888 * x5, \p x6
889 */
891 const pmt_t& x2,
892 const pmt_t& x3,
893 const pmt_t& x4,
894 const pmt_t& x5,
895 const pmt_t& x6);
896
897/*!
898 * \brief Return \p list with \p item added to it.
899 */
900PMT_API pmt_t list_add(pmt_t list, const pmt_t& item);
901
902/*!
903 * \brief Return \p list with \p item removed from it.
904 */
905PMT_API pmt_t list_rm(pmt_t list, const pmt_t& item);
906
907/*!
908 * \brief Return bool of \p list contains \p item
909 */
910PMT_API bool list_has(pmt_t list, const pmt_t& item);
911
912
913/*
914 * ------------------------------------------------------------------------
915 * read / write
916 * ------------------------------------------------------------------------
917 */
918
919//! return true if obj is the EOF object, otherwise return false.
921
922/*!
923 * read converts external representations of pmt objects into the
924 * objects themselves. Read returns the next object parsable from
925 * the given input port, updating port to point to the first
926 * character past the end of the external representation of the
927 * object.
928 *
929 * If an end of file is encountered in the input before any
930 * characters are found that can begin an object, then an end of file
931 * object is returned. The port remains open, and further attempts
932 * to read will also return an end of file object. If an end of file
933 * is encountered after the beginning of an object's external
934 * representation, but the external representation is incomplete and
935 * therefore not parsable, an error is signaled.
936 */
937PMT_API pmt_t read(std::istream& port);
938
939/*!
940 * Write a written representation of \p obj to the given \p port.
941 */
942PMT_API void write(pmt_t obj, std::ostream& port);
943
944/*!
945 * Return a string representation of \p obj.
946 * This is the same output as would be generated by pmt::write.
947 */
948PMT_API std::string write_string(pmt_t obj);
949
950
951PMT_API std::ostream& operator<<(std::ostream& os, pmt_t obj);
952
953/*!
954 * \brief Write pmt string representation to stdout.
955 */
957
958
959/*
960 * ------------------------------------------------------------------------
961 * portable byte stream representation
962 * ------------------------------------------------------------------------
963 */
964/*!
965 * \brief Write portable byte-serial representation of \p obj to \p sink
966 */
967PMT_API bool serialize(pmt_t obj, std::streambuf& sink);
968
969/*!
970 * \brief Create obj from portable byte-serial representation
971 */
972PMT_API pmt_t deserialize(std::streambuf& source);
973
974
975PMT_API void dump_sizeof(); // debugging
976
977/*!
978 * \brief Provide a simple string generating interface to pmt's serialize function
979 */
980PMT_API std::string serialize_str(pmt_t obj);
981
982/*!
983 * \brief Provide a simple string generating interface to pmt's deserialize function
984 */
986
987/*!
988 * \brief Provide a comparator function object to allow pmt use in stl types
989 */
991{
992public:
993 bool operator()(pmt::pmt_t const& p1, pmt::pmt_t const& p2) const
994 {
995 return pmt::eqv(p1, p2) ? false : p1.get() > p2.get();
996 }
997};
998
999} /* namespace pmt */
1000
1001#include <pmt/pmt_sugar.h>
1002
1003#endif /* INCLUDED_PMT_H */
Definition alist.h:33
Provide a comparator function object to allow pmt use in stl types.
Definition pmt.h:991
bool operator()(pmt::pmt_t const &p1, pmt::pmt_t const &p2) const
Definition pmt.h:993
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
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_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:650
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:820
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