summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2014-06-13 14:41:50 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2014-06-13 14:41:50 -0700
commitf5aafacd7416822cd0ec7017dd9604cfdb1533dc (patch)
tree05c7c448ee6f593abf3d6831445a063325a03d12
parentf3fbf453e08a490d6c610658ad6394e308c2a14e (diff)
parentdbd2aee42a4bba767b8f1daf0801fd0aac304be7 (diff)
Merge remote-tracking branch 'mmueller/pmt_io_uniform_vector_to_string'
Conflicts: gnuradio-runtime/lib/pmt/pmt_int.h
-rwxr-xr-xgnuradio-runtime/lib/pmt/generate_unv.py1
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_int.h1
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_io.cc13
-rw-r--r--gnuradio-runtime/lib/pmt/unv_template.cc.t6
-rw-r--r--gnuradio-runtime/lib/pmt/unv_template.h.t1
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 ca90c5a475..49bde52063 100644
--- a/gnuradio-runtime/lib/pmt/pmt_int.h
+++ b/gnuradio-runtime/lib/pmt/pmt_int.h
@@ -239,6 +239,7 @@ public:
virtual void *uniform_writable_elements(size_t &len) = 0;
virtual size_t length() const = 0;
virtual size_t itemsize() const = 0;
+ virtual const std::string string_ref(size_t k) const { return std::string("not implemented"); }
};
#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 93ca684463..ab5c163570 100644
--- a/gnuradio-runtime/lib/pmt/unv_template.h.t
+++ b/gnuradio-runtime/lib/pmt/unv_template.h.t
@@ -21,4 +21,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;
};