summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-27 22:38:43 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-27 22:38:43 +0000
commit00e9647a9ede540f2d567c19025278c25a87c830 (patch)
tree145f7fc92cfa0670e7da304b965d30f751ab1b14 /src/util.h
parent8c2f3517e868078b551bb01d975f2956cb692fbf (diff)
Various tweaks; work on read_dcp example.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index e26c7332..e79c0a0b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -86,6 +86,21 @@ extern std::string tm_to_string (struct tm *);
extern std::string utc_offset_to_string (int);
extern std::string ptime_to_string (boost::posix_time::ptime);
extern FILE * fopen_boost (boost::filesystem::path, std::string);
+
+template <class F, class T>
+std::list<boost::shared_ptr<T> >
+list_of_type (std::list<boost::shared_ptr<F> > const & from)
+{
+ std::list<boost::shared_ptr<T> > out;
+ for (typename std::list<boost::shared_ptr<F> >::const_iterator i = from.begin(); i != from.end(); ++i) {
+ boost::shared_ptr<T> check = boost::dynamic_pointer_cast<T> (*i);
+ if (check) {
+ out.push_back (check);
+ }
+ }
+
+ return out;
+}
}