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