summaryrefslogtreecommitdiffstats
path: root/dcoppython/shell/marshaller.h
diff options
context:
space:
mode:
Diffstat (limited to 'dcoppython/shell/marshaller.h')
-rw-r--r--dcoppython/shell/marshaller.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/dcoppython/shell/marshaller.h b/dcoppython/shell/marshaller.h
new file mode 100644
index 00000000..920afb05
--- /dev/null
+++ b/dcoppython/shell/marshaller.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Julian Rockey *
+ * linux@jrockey.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#ifndef __marshaller_h__
+#define __marshaller_h__
+
+#include <qmap.h>
+#include <Python.h>
+#include <qstring.h>
+
+class QDataStream;
+
+namespace PythonDCOP {
+// class Marshaller;
+ class PCOPType;
+
+ class Marshaller {
+ public:
+ Marshaller();
+ ~Marshaller();
+ bool marshal(const PCOPType &type, PyObject *obj, QDataStream &str) const
+ { return marsh_private(type,obj,&str); }
+ bool canMarshal(const PCOPType &type, PyObject *obj) const
+ { return marsh_private(type,obj,NULL); }
+ bool marshalList(const PCOPType &list_type, PyObject *obj, QDataStream *str) const;
+ PyObject *demarshal(const PCOPType &type, QDataStream &str) const
+ { return demarsh_private(type, &str); }
+ PyObject *demarshalList(const PCOPType &list_type, QDataStream *str) const;
+ bool marshalDict(const PCOPType &key_type, const PCOPType &value_type,
+ PyObject *obj, QDataStream *str) const;
+ PyObject *demarshalDict(const PCOPType &key_type,
+ const PCOPType &value_type,
+ QDataStream *str) const;
+ static Marshaller *instance() { return m_instance; }
+ protected:
+ QMap<QString,bool(*)(PyObject*,QDataStream*)> m_marsh_funcs;
+ QMap<QString,PyObject*(*)(QDataStream*)> m_demarsh_funcs;
+
+ static Marshaller *m_instance;
+
+ void initFuncs();
+ private:
+ bool marsh_private(const PCOPType &type,
+ PyObject *obj,
+ QDataStream *str) const;
+ PyObject *demarsh_private(const PCOPType &type,
+ QDataStream *str) const;
+
+
+
+ };
+
+// bool marshall_bool(PyObject *obj, QDataStream *str);
+// bool marshall_int(PyObject *obj, QDataStream *str);
+// bool marshall_uint(PyObject *obj, QDataStream *str);
+// bool marshall_double(PyObject *obj, QDataStream *str);
+// bool marshall_QByteArray(PyObject *obj, QDataStream *str);
+// bool marshall_QString(PyObject *obj, QDataStream *str);
+// bool marshall_QCString(PyObject *obj, QDataStream *str);
+
+
+}
+
+#endif