Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # distutils: language = c++
- # distutils: sources = ../src/writer.cc ../src/reader.cc ../src/exception.cc
- from libcpp cimport bool
- cdef extern from "writer.hpp" namespace "szn::logfile":
- cdef cppclass Writer:
- Writer(const char*, const size_t, const bool) except +
- void write(const char*, const size_t) except +
- void close()
- void sync()
- cdef class PyWriter:
- cdef Writer * thisptr
- def __cinit__(self, file_path, checkpoint_size=1024, create_index=True):
- cdef const char* c_file_path = file_path
- cdef size_t c_checkpoint_size = checkpoint_size
- cdef bool c_create_index = create_index
- self.thisptr = new Writer(c_file_path, c_checkpoint_size,
- c_create_index)
- def write(self, data):
- cdef const char* c_data = data
- cdef size_t c_data_size = len(data)
- self.thisptr.write(c_data, c_data_size)
- def close(self):
- self.thisptr.close()
- def sync(self):
- self.thisptr.sync()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement