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