diff options
author | Marcus Müller <marcus@hostalia.de> | 2014-04-12 17:04:54 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2014-04-12 17:07:08 +0200 |
commit | dbd2aee42a4bba767b8f1daf0801fd0aac304be7 (patch) | |
tree | d847c079025236e9698fce936e45080a09bd0867 | |
parent | 76970d54f3a6551751d481c63ea54c0794fc2591 (diff) |
pmt_io: adding string conversion for uniform vectors
Sadly, this needed expansion of unv_template, otherwise I'd have to
hand-write gengen-style code in pmt_io.cc
-rwxr-xr-x | gnuradio-runtime/lib/pmt/generate_unv.py | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt_int.h | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt_io.cc | 13 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/unv_template.cc.t | 6 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/unv_template.h.t | 1 |
5 files changed, 19 insertions, 3 deletions
diff --git a/gnuradio-runtime/lib/pmt/generate_unv.py b/gnuradio-runtime/lib/pmt/generate_unv.py index 7562df46f8..6218099fc1 100755 --- a/gnuradio-runtime/lib/pmt/generate_unv.py +++ b/gnuradio-runtime/lib/pmt/generate_unv.py @@ -76,6 +76,7 @@ includes = """ #endif #include <vector> #include <pmt/pmt.h> +#include <boost/lexical_cast.hpp> #include "pmt_int.h" """ diff --git a/gnuradio-runtime/lib/pmt/pmt_int.h b/gnuradio-runtime/lib/pmt/pmt_int.h index aceb7b74d9..25bcdb9d6b 100644 --- a/gnuradio-runtime/lib/pmt/pmt_int.h +++ b/gnuradio-runtime/lib/pmt/pmt_int.h @@ -238,6 +238,7 @@ public: virtual const void *uniform_elements(size_t &len) = 0; virtual void *uniform_writable_elements(size_t &len) = 0; virtual size_t length() const = 0; + virtual const std::string string_ref(size_t k) const { return std::string("FIXME"); } }; #include "pmt_unv_int.h" diff --git a/gnuradio-runtime/lib/pmt/pmt_io.cc b/gnuradio-runtime/lib/pmt/pmt_io.cc index 17bdee408f..acad8fc2ca 100644 --- a/gnuradio-runtime/lib/pmt/pmt_io.cc +++ b/gnuradio-runtime/lib/pmt/pmt_io.cc @@ -110,9 +110,16 @@ write(pmt_t obj, std::ostream &port) port << "#<dict>"; } else if (is_uniform_vector(obj)){ - // FIXME - // port << "#<uniform-vector " << obj << ">"; - port << "#<uniform-vector>"; + port << "#["; + size_t len = length(obj); + if (len) + { + pmt_uniform_vector *uv = dynamic_cast<pmt_uniform_vector*>(obj.get()); + port << uv->string_ref(0); + for (size_t i = 1; i < len; i++) + port << " " << uv->string_ref(i); + } + port << "]"; } else { error: diff --git a/gnuradio-runtime/lib/pmt/unv_template.cc.t b/gnuradio-runtime/lib/pmt/unv_template.cc.t index 8678894973..c8020e7de2 100644 --- a/gnuradio-runtime/lib/pmt/unv_template.cc.t +++ b/gnuradio-runtime/lib/pmt/unv_template.cc.t @@ -138,4 +138,10 @@ const std::vector< @TYPE@ > return _@TAG@vector(vector)->writable_elements(len); } +const std::string +pmt_@TAG@vector::string_ref(size_t k) const +{ + return boost::lexical_cast< std::string, @TYPE@ > (ref(k)); +} + } /* namespace pmt */ diff --git a/gnuradio-runtime/lib/pmt/unv_template.h.t b/gnuradio-runtime/lib/pmt/unv_template.h.t index 83ba0be0f4..cdf72d4eac 100644 --- a/gnuradio-runtime/lib/pmt/unv_template.h.t +++ b/gnuradio-runtime/lib/pmt/unv_template.h.t @@ -20,4 +20,5 @@ public: @TYPE@ *writable_elements(size_t &len); const void *uniform_elements(size_t &len); void *uniform_writable_elements(size_t &len); + virtual const std::string string_ref(size_t k) const; }; |