static PyObject * dummy_decode_command2(PyObject *self, PyObject *args) { PyObject *po = PyTuple_GetItem(args, 0); if (!PyFile_Check(po)) { PyErr_SetString(DummyError, "First argument should be a file object."); return NULL; } hu::FileInStream stream; FILE *handle = PyFile_AsFile(po); stream.open(handle); int code = deserializeInt(stream); std::string key; std::string value; deserializeString(key, stream); deserializeString(value, stream); PyObject* res = PyTuple_New(3); PyTuple_SET_ITEM(res, 0, PyInt_FromLong(code)); PyTuple_SET_ITEM(res, 1, PyString_FromStringAndSize(key.c_str(), key.size())); PyTuple_SET_ITEM(res, 2, PyString_FromStringAndSize(value.c_str(), value.size())); return res; }
inline PyObject* decode_item(char code, hu::InStream& stream) { try { switch(code) { case 's': deserializeString(_buffer, stream); return PyString_FromStringAndSize(_buffer.c_str(), _buffer.size()); case 'i': return PyInt_FromLong(deserializeInt(stream)); default: PyErr_SetString(DummyError, "Unknown decoding code."); return NULL; } } catch (hu::Error& e) { PyErr_SetString(DummyError, e.getMessage().c_str()); return NULL; } }
void onMessageEvent( const zeq::Event& event ) { BOOST_CHECK_EQUAL( deserializeString( event ), message ); }