commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/11: pmt_io: adding string conversion for


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/11: pmt_io: adding string conversion for uniform vectors
Date: Fri, 13 Jun 2014 22:44:32 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit dbd2aee42a4bba767b8f1daf0801fd0aac304be7
Author: Marcus Müller <address@hidden>
Date:   Sat Apr 12 17:04:54 2014 +0200

    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
---
 gnuradio-runtime/lib/pmt/generate_unv.py   |  1 +
 gnuradio-runtime/lib/pmt/pmt_int.h         |  1 +
 gnuradio-runtime/lib/pmt/pmt_io.cc         | 13 ++++++++++---
 gnuradio-runtime/lib/pmt/unv_template.cc.t |  6 ++++++
 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 7562df4..6218099 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 aceb7b7..25bcdb9 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 17bdee4..acad8fc 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 8678894..c8020e7 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 address@hidden@vector(vector)->writable_elements(len);
 }
 
+const std::string
address@hidden@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 83ba0be..cdf72d4 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;
 };



reply via email to

[Prev in Thread] Current Thread [Next in Thread]