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