def __next__(self): """ get next message from the buffer. """ self.state, size = vsb.ReadNextMessage(self.handle, self.message, self.size) if self.state == vsb.eSuccess: return VSBMessage(self.message, vsb.GetEDP(self.message), size) elif self.state == vsb.eEndOfFile: vsb.ReadClose(self.handle) raise StopIteration() elif self.state == vsb.eError: raise ValueError(self.get_error_message()) elif self.state == vsb.eBufferToSmall: vsb.VSBIOFree(self.message) self.message = vsb.VSBIOMalloc(size) self.size = size return self.__next__()
def __del__(self): vsb.VSBIOFree(self.message) if self.state != vsb.eEndOfFile: vsb.ReadClose(self.handle)