GNU Radio 3.2.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006,2009 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_PMT_H 00024 #define INCLUDED_PMT_H 00025 00026 #include <boost/shared_ptr.hpp> 00027 #include <boost/any.hpp> 00028 #include <complex> 00029 #include <string> 00030 #include <stdint.h> 00031 #include <iosfwd> 00032 #include <stdexcept> 00033 00034 /*! 00035 * This file defines a polymorphic type and the operations on it. 00036 * 00037 * It draws heavily on the idea of scheme and lisp data types. 00038 * The interface parallels that in Guile 1.8, with the notable 00039 * exception that these objects are transparently reference counted. 00040 */ 00041 00042 /*! 00043 * \brief base class of all pmt types 00044 */ 00045 class pmt_base; 00046 00047 /*! 00048 * \brief typedef for shared pointer (transparent reference counting). 00049 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 00050 */ 00051 typedef boost::shared_ptr<pmt_base> pmt_t; 00052 00053 00054 class pmt_exception : public std::logic_error 00055 { 00056 public: 00057 pmt_exception(const std::string &msg, pmt_t obj); 00058 }; 00059 00060 class pmt_wrong_type : public pmt_exception 00061 { 00062 public: 00063 pmt_wrong_type(const std::string &msg, pmt_t obj); 00064 }; 00065 00066 class pmt_out_of_range : public pmt_exception 00067 { 00068 public: 00069 pmt_out_of_range(const std::string &msg, pmt_t obj); 00070 }; 00071 00072 class pmt_notimplemented : public pmt_exception 00073 { 00074 public: 00075 pmt_notimplemented(const std::string &msg, pmt_t obj); 00076 }; 00077 00078 /* 00079 * ------------------------------------------------------------------------ 00080 * Booleans. Two constants, #t and #f. 00081 * 00082 * In predicates, anything that is not #f is considered true. 00083 * I.e., there is a single false value, #f. 00084 * ------------------------------------------------------------------------ 00085 */ 00086 extern const pmt_t PMT_T; //< \#t : boolean true constant 00087 extern const pmt_t PMT_F; //< \#f : boolean false constant 00088 00089 //! Return true if obj is \#t or \#f, else return false. 00090 bool pmt_is_bool(pmt_t obj); 00091 00092 //! Return false if obj is \#f, else return true. 00093 bool pmt_is_true(pmt_t obj); 00094 00095 //! Return true if obj is \#f, else return true. 00096 bool pmt_is_false(pmt_t obj); 00097 00098 //! Return \#f is val is false, else return \#t. 00099 pmt_t pmt_from_bool(bool val); 00100 00101 //! Return true if val is PMT_T, return false when val is PMT_F, 00102 // else raise wrong_type exception. 00103 bool pmt_to_bool(pmt_t val); 00104 00105 /* 00106 * ------------------------------------------------------------------------ 00107 * Symbols 00108 * ------------------------------------------------------------------------ 00109 */ 00110 00111 //! Return true if obj is a symbol, else false. 00112 bool pmt_is_symbol(pmt_t obj); 00113 00114 //! Return the symbol whose name is \p s. 00115 pmt_t pmt_string_to_symbol(const std::string &s); 00116 00117 //! Alias for pmt_string_to_symbol 00118 pmt_t pmt_intern(const std::string &s); 00119 00120 00121 /*! 00122 * If \p is a symbol, return the name of the symbol as a string. 00123 * Otherwise, raise the wrong_type exception. 00124 */ 00125 const std::string pmt_symbol_to_string(pmt_t sym); 00126 00127 /* 00128 * ------------------------------------------------------------------------ 00129 * Numbers: we support integer, real and complex 00130 * ------------------------------------------------------------------------ 00131 */ 00132 00133 //! Return true if obj is any kind of number, else false. 00134 bool pmt_is_number(pmt_t obj); 00135 00136 /* 00137 * ------------------------------------------------------------------------ 00138 * Integers 00139 * ------------------------------------------------------------------------ 00140 */ 00141 00142 //! Return true if \p x is an integer number, else false 00143 bool pmt_is_integer(pmt_t x); 00144 00145 //! Return the pmt value that represents the integer \p x. 00146 pmt_t pmt_from_long(long x); 00147 00148 /*! 00149 * \brief Convert pmt to long if possible. 00150 * 00151 * When \p x represents an exact integer that fits in a long, 00152 * return that integer. Else raise an exception, either wrong_type 00153 * when x is not an exact integer, or out_of_range when it doesn't fit. 00154 */ 00155 long pmt_to_long(pmt_t x); 00156 00157 /* 00158 * ------------------------------------------------------------------------ 00159 * Reals 00160 * ------------------------------------------------------------------------ 00161 */ 00162 00163 /* 00164 * \brief Return true if \p obj is a real number, else false. 00165 */ 00166 bool pmt_is_real(pmt_t obj); 00167 00168 //! Return the pmt value that represents double \p x. 00169 pmt_t pmt_from_double(double x); 00170 00171 /*! 00172 * \brief Convert pmt to double if possible. 00173 * 00174 * Returns the number closest to \p val that is representable 00175 * as a double. The argument \p val must be a real or integer, otherwise 00176 * a wrong_type exception is raised. 00177 */ 00178 double pmt_to_double(pmt_t x); 00179 00180 /* 00181 * ------------------------------------------------------------------------ 00182 * Complex 00183 * ------------------------------------------------------------------------ 00184 */ 00185 00186 /*! 00187 * \brief return true if \p obj is a complex number, false otherwise. 00188 */ 00189 bool pmt_is_complex(pmt_t obj); 00190 00191 //! Return a complex number constructed of the given real and imaginary parts. 00192 pmt_t pmt_make_rectangular(double re, double im); 00193 00194 /*! 00195 * If \p z is complex, real or integer, return the closest complex<double>. 00196 * Otherwise, raise the wrong_type exception. 00197 */ 00198 std::complex<double> pmt_to_complex(pmt_t z); 00199 00200 /* 00201 * ------------------------------------------------------------------------ 00202 * Pairs 00203 * ------------------------------------------------------------------------ 00204 */ 00205 00206 extern const pmt_t PMT_NIL; //< the empty list 00207 00208 //! Return true if \p x is the empty list, otherwise return false. 00209 bool pmt_is_null(pmt_t x); 00210 00211 //! Return true if \p obj is a pair, else false. 00212 bool pmt_is_pair(pmt_t obj); 00213 00214 //! Return a newly allocated pair whose car is \p x and whose cdr is \p y. 00215 pmt_t pmt_cons(pmt_t x, pmt_t y); 00216 00217 //! If \p pair is a pair, return the car of the \p pair, otherwise raise wrong_type. 00218 pmt_t pmt_car(pmt_t pair); 00219 00220 //! If \p pair is a pair, return the cdr of the \p pair, otherwise raise wrong_type. 00221 pmt_t pmt_cdr(pmt_t pair); 00222 00223 //! Stores \p value in the car field of \p pair. 00224 void pmt_set_car(pmt_t pair, pmt_t value); 00225 00226 //! Stores \p value in the cdr field of \p pair. 00227 void pmt_set_cdr(pmt_t pair, pmt_t value); 00228 00229 pmt_t pmt_caar(pmt_t pair); 00230 pmt_t pmt_cadr(pmt_t pair); 00231 pmt_t pmt_cdar(pmt_t pair); 00232 pmt_t pmt_cddr(pmt_t pair); 00233 pmt_t pmt_caddr(pmt_t pair); 00234 pmt_t pmt_cadddr(pmt_t pair); 00235 00236 /* 00237 * ------------------------------------------------------------------------ 00238 * Vectors 00239 * 00240 * These vectors can hold any kind of objects. Indexing is zero based. 00241 * ------------------------------------------------------------------------ 00242 */ 00243 00244 //! Return true if \p x is a vector, othewise false. 00245 bool pmt_is_vector(pmt_t x); 00246 00247 //! Make a vector of length \p k, with initial values set to \p fill 00248 pmt_t pmt_make_vector(size_t k, pmt_t fill); 00249 00250 /*! 00251 * Return the contents of position \p k of \p vector. 00252 * \p k must be a valid index of \p vector. 00253 */ 00254 pmt_t pmt_vector_ref(pmt_t vector, size_t k); 00255 00256 //! Store \p obj in position \p k. 00257 void pmt_vector_set(pmt_t vector, size_t k, pmt_t obj); 00258 00259 //! Store \p fill in every position of \p vector 00260 void pmt_vector_fill(pmt_t vector, pmt_t fill); 00261 00262 /*! 00263 * <pre> 00264 * ------------------------------------------------------------------------ 00265 * Uniform Numeric Vectors 00266 * 00267 * A uniform numeric vector is a vector whose elements are all of single 00268 * numeric type. pmt offers uniform numeric vectors for signed and 00269 * unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of 00270 * floating point values, and complex floating-point numbers of these 00271 * two sizes. Indexing is zero based. 00272 * 00273 * The names of the functions include these tags in their names: 00274 * 00275 * u8 unsigned 8-bit integers 00276 * s8 signed 8-bit integers 00277 * u16 unsigned 16-bit integers 00278 * s16 signed 16-bit integers 00279 * u32 unsigned 32-bit integers 00280 * s32 signed 32-bit integers 00281 * u64 unsigned 64-bit integers 00282 * s64 signed 64-bit integers 00283 * f32 the C++ type float 00284 * f64 the C++ type double 00285 * c32 the C++ type complex<float> 00286 * c64 the C++ type complex<double> 00287 * ------------------------------------------------------------------------ 00288 * </pre> 00289 */ 00290 00291 //! true if \p x is any kind of uniform numeric vector 00292 bool pmt_is_uniform_vector(pmt_t x); 00293 00294 bool pmt_is_u8vector(pmt_t x); 00295 bool pmt_is_s8vector(pmt_t x); 00296 bool pmt_is_u16vector(pmt_t x); 00297 bool pmt_is_s16vector(pmt_t x); 00298 bool pmt_is_u32vector(pmt_t x); 00299 bool pmt_is_s32vector(pmt_t x); 00300 bool pmt_is_u64vector(pmt_t x); 00301 bool pmt_is_s64vector(pmt_t x); 00302 bool pmt_is_f32vector(pmt_t x); 00303 bool pmt_is_f64vector(pmt_t x); 00304 bool pmt_is_c32vector(pmt_t x); 00305 bool pmt_is_c64vector(pmt_t x); 00306 00307 pmt_t pmt_make_u8vector(size_t k, uint8_t fill); 00308 pmt_t pmt_make_s8vector(size_t k, int8_t fill); 00309 pmt_t pmt_make_u16vector(size_t k, uint16_t fill); 00310 pmt_t pmt_make_s16vector(size_t k, int16_t fill); 00311 pmt_t pmt_make_u32vector(size_t k, uint32_t fill); 00312 pmt_t pmt_make_s32vector(size_t k, int32_t fill); 00313 pmt_t pmt_make_u64vector(size_t k, uint64_t fill); 00314 pmt_t pmt_make_s64vector(size_t k, int64_t fill); 00315 pmt_t pmt_make_f32vector(size_t k, float fill); 00316 pmt_t pmt_make_f64vector(size_t k, double fill); 00317 pmt_t pmt_make_c32vector(size_t k, std::complex<float> fill); 00318 pmt_t pmt_make_c64vector(size_t k, std::complex<double> fill); 00319 00320 pmt_t pmt_init_u8vector(size_t k, const uint8_t *data); 00321 pmt_t pmt_init_s8vector(size_t k, const int8_t *data); 00322 pmt_t pmt_init_u16vector(size_t k, const uint16_t *data); 00323 pmt_t pmt_init_s16vector(size_t k, const int16_t *data); 00324 pmt_t pmt_init_u32vector(size_t k, const uint32_t *data); 00325 pmt_t pmt_init_s32vector(size_t k, const int32_t *data); 00326 pmt_t pmt_init_u64vector(size_t k, const uint64_t *data); 00327 pmt_t pmt_init_s64vector(size_t k, const int64_t *data); 00328 pmt_t pmt_init_f32vector(size_t k, const float *data); 00329 pmt_t pmt_init_f64vector(size_t k, const double *data); 00330 pmt_t pmt_init_c32vector(size_t k, const std::complex<float> *data); 00331 pmt_t pmt_init_c64vector(size_t k, const std::complex<double> *data); 00332 00333 uint8_t pmt_u8vector_ref(pmt_t v, size_t k); 00334 int8_t pmt_s8vector_ref(pmt_t v, size_t k); 00335 uint16_t pmt_u16vector_ref(pmt_t v, size_t k); 00336 int16_t pmt_s16vector_ref(pmt_t v, size_t k); 00337 uint32_t pmt_u32vector_ref(pmt_t v, size_t k); 00338 int32_t pmt_s32vector_ref(pmt_t v, size_t k); 00339 uint64_t pmt_u64vector_ref(pmt_t v, size_t k); 00340 int64_t pmt_s64vector_ref(pmt_t v, size_t k); 00341 float pmt_f32vector_ref(pmt_t v, size_t k); 00342 double pmt_f64vector_ref(pmt_t v, size_t k); 00343 std::complex<float> pmt_c32vector_ref(pmt_t v, size_t k); 00344 std::complex<double> pmt_c64vector_ref(pmt_t v, size_t k); 00345 00346 void pmt_u8vector_set(pmt_t v, size_t k, uint8_t x); //< v[k] = x 00347 void pmt_s8vector_set(pmt_t v, size_t k, int8_t x); 00348 void pmt_u16vector_set(pmt_t v, size_t k, uint16_t x); 00349 void pmt_s16vector_set(pmt_t v, size_t k, int16_t x); 00350 void pmt_u32vector_set(pmt_t v, size_t k, uint32_t x); 00351 void pmt_s32vector_set(pmt_t v, size_t k, int32_t x); 00352 void pmt_u64vector_set(pmt_t v, size_t k, uint64_t x); 00353 void pmt_s64vector_set(pmt_t v, size_t k, int64_t x); 00354 void pmt_f32vector_set(pmt_t v, size_t k, float x); 00355 void pmt_f64vector_set(pmt_t v, size_t k, double x); 00356 void pmt_c32vector_set(pmt_t v, size_t k, std::complex<float> x); 00357 void pmt_c64vector_set(pmt_t v, size_t k, std::complex<double> x); 00358 00359 // Return const pointers to the elements 00360 00361 const void *pmt_uniform_vector_elements(pmt_t v, size_t &len); //< works with any; len is in bytes 00362 00363 const uint8_t *pmt_u8vector_elements(pmt_t v, size_t &len); //< len is in elements 00364 const int8_t *pmt_s8vector_elements(pmt_t v, size_t &len); //< len is in elements 00365 const uint16_t *pmt_u16vector_elements(pmt_t v, size_t &len); //< len is in elements 00366 const int16_t *pmt_s16vector_elements(pmt_t v, size_t &len); //< len is in elements 00367 const uint32_t *pmt_u32vector_elements(pmt_t v, size_t &len); //< len is in elements 00368 const int32_t *pmt_s32vector_elements(pmt_t v, size_t &len); //< len is in elements 00369 const uint64_t *pmt_u64vector_elements(pmt_t v, size_t &len); //< len is in elements 00370 const int64_t *pmt_s64vector_elements(pmt_t v, size_t &len); //< len is in elements 00371 const float *pmt_f32vector_elements(pmt_t v, size_t &len); //< len is in elements 00372 const double *pmt_f64vector_elements(pmt_t v, size_t &len); //< len is in elements 00373 const std::complex<float> *pmt_c32vector_elements(pmt_t v, size_t &len); //< len is in elements 00374 const std::complex<double> *pmt_c64vector_elements(pmt_t v, size_t &len); //< len is in elements 00375 00376 // Return non-const pointers to the elements 00377 00378 void *pmt_uniform_vector_writable_elements(pmt_t v, size_t &len); //< works with any; len is in bytes 00379 00380 uint8_t *pmt_u8vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00381 int8_t *pmt_s8vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00382 uint16_t *pmt_u16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00383 int16_t *pmt_s16vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00384 uint32_t *pmt_u32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00385 int32_t *pmt_s32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00386 uint64_t *pmt_u64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00387 int64_t *pmt_s64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00388 float *pmt_f32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00389 double *pmt_f64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00390 std::complex<float> *pmt_c32vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00391 std::complex<double> *pmt_c64vector_writable_elements(pmt_t v, size_t &len); //< len is in elements 00392 00393 /* 00394 * ------------------------------------------------------------------------ 00395 * Dictionary (a.k.a associative array, hash, map) 00396 * ------------------------------------------------------------------------ 00397 */ 00398 00399 //! Return true if \p obj is a dictionary 00400 bool pmt_is_dict(pmt_t obj); 00401 00402 //! make an empty dictionary 00403 pmt_t pmt_make_dict(); 00404 00405 //! dict[key] = value 00406 void pmt_dict_set(pmt_t dict, pmt_t key, pmt_t value); 00407 00408 //! Return true if \p key exists in \p dict 00409 bool pmt_dict_has_key(pmt_t dict, pmt_t key); 00410 00411 //! If \p key exists in \p dict, return associated value; otherwise return \p not_found. 00412 pmt_t pmt_dict_ref(pmt_t dict, pmt_t key, pmt_t not_found); 00413 00414 //! Return list of (key . value) pairs 00415 pmt_t pmt_dict_items(pmt_t dict); 00416 00417 //! Return list of keys 00418 pmt_t pmt_dict_keys(pmt_t dict); 00419 00420 //! Return list of values 00421 pmt_t pmt_dict_values(pmt_t dict); 00422 00423 /* 00424 * ------------------------------------------------------------------------ 00425 * Any (wraps boost::any -- can be used to wrap pretty much anything) 00426 * 00427 * Cannot be serialized or used across process boundaries. 00428 * See http://www.boost.org/doc/html/any.html 00429 * ------------------------------------------------------------------------ 00430 */ 00431 00432 //! Return true if \p obj is an any 00433 bool pmt_is_any(pmt_t obj); 00434 00435 //! make an any 00436 pmt_t pmt_make_any(const boost::any &any); 00437 00438 //! Return underlying boost::any 00439 boost::any pmt_any_ref(pmt_t obj); 00440 00441 //! Store \p any in \p obj 00442 void pmt_any_set(pmt_t obj, const boost::any &any); 00443 00444 00445 /* 00446 * ------------------------------------------------------------------------ 00447 * General functions 00448 * ------------------------------------------------------------------------ 00449 */ 00450 00451 //! Return true if x and y are the same object; otherwise return false. 00452 bool pmt_eq(pmt_t x, pmt_t y); 00453 00454 /*! 00455 * \brief Return true if x and y should normally be regarded as the same object, else false. 00456 * 00457 * <pre> 00458 * eqv returns true if: 00459 * x and y are the same object. 00460 * x and y are both \#t or both \#f. 00461 * x and y are both symbols and their names are the same. 00462 * x and y are both numbers, and are numerically equal. 00463 * x and y are both the empty list (nil). 00464 * x and y are pairs or vectors that denote same location in store. 00465 * </pre> 00466 */ 00467 bool pmt_eqv(pmt_t x, pmt_t y); 00468 00469 /*! 00470 * pmt_equal recursively compares the contents of pairs and vectors, 00471 * applying pmt_eqv on other objects such as numbers and symbols. 00472 * pmt_equal may fail to terminate if its arguments are circular data 00473 * structures. 00474 */ 00475 bool pmt_equal(pmt_t x, pmt_t y); 00476 00477 00478 //! Return the number of elements in v 00479 size_t pmt_length(pmt_t v); 00480 00481 /*! 00482 * \brief Find the first pair in \p alist whose car field is \p obj 00483 * and return that pair. 00484 * 00485 * \p alist (for "association list") must be a list of pairs. If no pair 00486 * in \p alist has \p obj as its car then \#f is returned. 00487 * Uses pmt_eq to compare \p obj with car fields of the pairs in \p alist. 00488 */ 00489 pmt_t pmt_assq(pmt_t obj, pmt_t alist); 00490 00491 /*! 00492 * \brief Find the first pair in \p alist whose car field is \p obj 00493 * and return that pair. 00494 * 00495 * \p alist (for "association list") must be a list of pairs. If no pair 00496 * in \p alist has \p obj as its car then \#f is returned. 00497 * Uses pmt_eqv to compare \p obj with car fields of the pairs in \p alist. 00498 */ 00499 pmt_t pmt_assv(pmt_t obj, pmt_t alist); 00500 00501 /*! 00502 * \brief Find the first pair in \p alist whose car field is \p obj 00503 * and return that pair. 00504 * 00505 * \p alist (for "association list") must be a list of pairs. If no pair 00506 * in \p alist has \p obj as its car then \#f is returned. 00507 * Uses pmt_equal to compare \p obj with car fields of the pairs in \p alist. 00508 */ 00509 pmt_t pmt_assoc(pmt_t obj, pmt_t alist); 00510 00511 /*! 00512 * \brief Apply \p proc element-wise to the elements of list and returns 00513 * a list of the results, in order. 00514 * 00515 * \p list must be a list. The dynamic order in which \p proc is 00516 * applied to the elements of \p list is unspecified. 00517 */ 00518 pmt_t pmt_map(pmt_t proc(pmt_t), pmt_t list); 00519 00520 /*! 00521 * \brief reverse \p list. 00522 * 00523 * \p list must be a proper list. 00524 */ 00525 pmt_t pmt_reverse(pmt_t list); 00526 00527 /*! 00528 * \brief destructively reverse \p list. 00529 * 00530 * \p list must be a proper list. 00531 */ 00532 pmt_t pmt_reverse_x(pmt_t list); 00533 00534 /*! 00535 * \brief (acons x y a) == (cons (cons x y) a) 00536 */ 00537 inline static pmt_t 00538 pmt_acons(pmt_t x, pmt_t y, pmt_t a) 00539 { 00540 return pmt_cons(pmt_cons(x, y), a); 00541 } 00542 00543 /*! 00544 * \brief locates \p nth element of \n list where the car is the 'zeroth' element. 00545 */ 00546 pmt_t pmt_nth(size_t n, pmt_t list); 00547 00548 /*! 00549 * \brief returns the tail of \p list that would be obtained by calling 00550 * cdr \p n times in succession. 00551 */ 00552 pmt_t pmt_nthcdr(size_t n, pmt_t list); 00553 00554 /*! 00555 * \brief Return the first sublist of \p list whose car is \p obj. 00556 * If \p obj does not occur in \p list, then \#f is returned. 00557 * pmt_memq use pmt_eq to compare \p obj with the elements of \p list. 00558 */ 00559 pmt_t pmt_memq(pmt_t obj, pmt_t list); 00560 00561 /*! 00562 * \brief Return the first sublist of \p list whose car is \p obj. 00563 * If \p obj does not occur in \p list, then \#f is returned. 00564 * pmt_memv use pmt_eqv to compare \p obj with the elements of \p list. 00565 */ 00566 pmt_t pmt_memv(pmt_t obj, pmt_t list); 00567 00568 /*! 00569 * \brief Return the first sublist of \p list whose car is \p obj. 00570 * If \p obj does not occur in \p list, then \#f is returned. 00571 * pmt_member use pmt_equal to compare \p obj with the elements of \p list. 00572 */ 00573 pmt_t pmt_member(pmt_t obj, pmt_t list); 00574 00575 /*! 00576 * \brief Return true if every element of \p list1 appears in \p list2, and false otherwise. 00577 * Comparisons are done with pmt_eqv. 00578 */ 00579 bool pmt_subsetp(pmt_t list1, pmt_t list2); 00580 00581 /*! 00582 * \brief Return a list of length 1 containing \p x1 00583 */ 00584 pmt_t pmt_list1(pmt_t x1); 00585 00586 /*! 00587 * \brief Return a list of length 2 containing \p x1, \p x2 00588 */ 00589 pmt_t pmt_list2(pmt_t x1, pmt_t x2); 00590 00591 /*! 00592 * \brief Return a list of length 3 containing \p x1, \p x2, \p x3 00593 */ 00594 pmt_t pmt_list3(pmt_t x1, pmt_t x2, pmt_t x3); 00595 00596 /*! 00597 * \brief Return a list of length 4 containing \p x1, \p x2, \p x3, \p x4 00598 */ 00599 pmt_t pmt_list4(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4); 00600 00601 /*! 00602 * \brief Return a list of length 5 containing \p x1, \p x2, \p x3, \p x4, \p x5 00603 */ 00604 pmt_t pmt_list5(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5); 00605 00606 /*! 00607 * \brief Return a list of length 6 containing \p x1, \p x2, \p x3, \p x4, \p 00608 * x5, \p x6 00609 */ 00610 pmt_t pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6); 00611 00612 /*! 00613 * \brief Return \p list with \p item added to it. 00614 */ 00615 pmt_t pmt_list_add(pmt_t list, pmt_t item); 00616 00617 00618 /* 00619 * ------------------------------------------------------------------------ 00620 * read / write 00621 * ------------------------------------------------------------------------ 00622 */ 00623 extern const pmt_t PMT_EOF; //< The end of file object 00624 00625 //! return true if obj is the EOF object, otherwise return false. 00626 bool pmt_is_eof_object(pmt_t obj); 00627 00628 /*! 00629 * read converts external representations of pmt objects into the 00630 * objects themselves. Read returns the next object parsable from 00631 * the given input port, updating port to point to the first 00632 * character past the end of the external representation of the 00633 * object. 00634 * 00635 * If an end of file is encountered in the input before any 00636 * characters are found that can begin an object, then an end of file 00637 * object is returned. The port remains open, and further attempts 00638 * to read will also return an end of file object. If an end of file 00639 * is encountered after the beginning of an object's external 00640 * representation, but the external representation is incomplete and 00641 * therefore not parsable, an error is signaled. 00642 */ 00643 pmt_t pmt_read(std::istream &port); 00644 00645 /*! 00646 * Write a written representation of \p obj to the given \p port. 00647 */ 00648 void pmt_write(pmt_t obj, std::ostream &port); 00649 00650 /*! 00651 * Return a string representation of \p obj. 00652 * This is the same output as would be generated by pmt_write. 00653 */ 00654 std::string pmt_write_string(pmt_t obj); 00655 00656 00657 std::ostream& operator<<(std::ostream &os, pmt_t obj); 00658 00659 00660 /* 00661 * ------------------------------------------------------------------------ 00662 * portable byte stream representation 00663 * ------------------------------------------------------------------------ 00664 */ 00665 /*! 00666 * \brief Write portable byte-serial representation of \p obj to \p sink 00667 */ 00668 bool pmt_serialize(pmt_t obj, std::streambuf &sink); 00669 00670 /*! 00671 * \brief Create obj from portable byte-serial representation 00672 */ 00673 pmt_t pmt_deserialize(std::streambuf &source); 00674 00675 00676 void pmt_dump_sizeof(); // debugging 00677 00678 #endif /* INCLUDED_PMT_H */