summaryrefslogtreecommitdiff
path: root/src/pyutils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-04 11:41:58 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:38 -0400
commit96684b72ca367bfd4dbe2e45a9a66c56204eb533 (patch)
tree3e218d1048d5941baa1d1064bc2539ef2df55a45 /src/pyutils.h
parent93096b77f3c03b826c8857e4817ccd1bca52f9ee (diff)
downloadledger-96684b72ca367bfd4dbe2e45a9a66c56204eb533.tar.gz
ledger-96684b72ca367bfd4dbe2e45a9a66c56204eb533.tar.bz2
ledger-96684b72ca367bfd4dbe2e45a9a66c56204eb533.zip
Added code for converting ledger::string and boost::date_time to their
respective Python counterparts.
Diffstat (limited to 'src/pyutils.h')
-rw-r--r--src/pyutils.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pyutils.h b/src/pyutils.h
new file mode 100644
index 00000000..4ff33f8f
--- /dev/null
+++ b/src/pyutils.h
@@ -0,0 +1,22 @@
+#ifndef _PY_UTILS_H
+#define _PY_UTILS_H
+
+template<class T, class TfromPy>
+struct ObjFromPy {
+ ObjFromPy() {
+ boost::python::converter::registry::push_back
+ (&TfromPy::convertible,
+ &TfromPy::construct,
+ boost::python::type_id<T>());
+ }
+};
+
+template<class T, class TtoPy, class TfromPy>
+struct register_python_conversion {
+ register_python_conversion() {
+ boost::python::to_python_converter<T, TtoPy>();
+ ObjFromPy<T, TfromPy>();
+ }
+};
+
+#endif // _PY_UTILS_H