3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
8 * Instructions for generating and building the extension:
10 * 1. swig -c++ -Wall -python -I../../../include -o fileobj_usage_wrap.cpp fileobj_usage.i
12 * 2. python setup.py build
16 * \example fileobj_usage.i
18 * A simple SWIG interface for a Python extension module that shows the
19 * mds_utils::python::FileObj usage.
21 * \remarks Here I've used SWIG for convenience only. The
22 * mds_utils::python::FileObj class does not impose you
28 // Include the following interface files for having the proper typemaps
29 %include "mds_utils/python/fileobj.i"
32 #include <mds_utils/python/conversion.hpp>
33 #include <mds_utils/python/fileobj.hpp>
36 namespace mdspy = mds_utils::python;
42 double read_double(mds_utils::python::FileObj fobj) {
50 ifs.read(reinterpret_cast<char*>(&val),sizeof(double));
57 void write_double(mds_utils::python::FileObj fobj,double val) {
63 ofs.write(reinterpret_cast<char*>(const_cast<double*>(&val)),sizeof(double));