NCBI C++ ToolKit
stream.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef UTIL_COMPRESS__STREAM__HPP
2 #define UTIL_COMPRESS__STREAM__HPP
3 
4 /* $Id: stream.hpp 98046 2022-09-22 17:57:22Z ivanov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Vladimir Ivanov
30  *
31  * File Description: CCompression based C++ I/O streams
32  *
33  */
34 
36 
37 
38 /** @addtogroup CompressionStreams
39  *
40  * @{
41  */
42 
43 
45 
46 
47 //////////////////////////////////////////////////////////////////////////////
48 //
49 // CCompression based stream classes
50 //
51 //////////////////////////////////////////////////////////////////////////////
52 //
53 // All CCompression based streams uses a "stream processors" that works as
54 // adapters between current stream's I/O interface and a some other stream,
55 // specified in the constructor. Any stream processor can implement either
56 // compression or decompression.
57 
58 // On reading from stream, data will be read from the underlying stream,
59 // processed by "read stream processor", and next processed data will be
60 // carried to called process.
61 // Also, all data written into CCompression[IO]Stream stream will be processed
62 // using "write stream processor" and further written into underlying stream.
63 //
64 // Note:
65 // Notice that generally the input/output stream you pass to
66 // CCompression[IO]Stream class constructor must be in binary mode, because
67 // the compressed data always is binary (decompressed data also can be
68 // binary) and the conversions which happen in the text mode will corrupt it.
69 //
70 // Note:
71 // CCompression[IO]Stream class objects must be finalized after use.
72 // Only after finalization all data put into stream will be processed
73 // for sure. By default finalization is done in the class destructor,
74 // however it is better to call it directly by using Finalize() method.
75 // This allow to check result and be sure that you read/write all necessary
76 // data. You cannot do this if Finalize() is called in the destructor
77 // automatically. After finalization you can only read from the stream
78 // (if it is derived from istream). If you don't read that some data
79 // can be lost there.
80 //
81 // Note:
82 // The compression streams write nothing into the output if no input data
83 // has provided. This can be especially important for cases where
84 // the output data should have any header/footer (like .gz files for example).
85 // So, for empty input, you will have an empty output, that may not be acceptable
86 // to external tools like gunzip and etc.
87 //
88 // Note:
89 // There is one special aspect of the output stream classes (CCompression[I]OStream).
90 // You should avoid flushing an output buffer if not necessary to get
91 // a better compression ratio. Basically, the compression algorithms works
92 // on blocks of data. They waits until a block is full and then compresses it.
93 // As long as you only feed data to the stream without flushing it works
94 // as expected. If you flush the stream, you force a premature end of the data block.
95 // This will cause a worse compression ratio.
96 //
97 // Accordingly, the using input stream with compression usually have worse
98 // compression than output stream with compression. Because a stream needs
99 // to flush data from compressor very often. Increasing compressor buffer
100 // size can to amend this situation.
101 //
102 
103 
104 // Forward declaration
106 
107 
108 //////////////////////////////////////////////////////////////////////////////
109 //
110 // CCompressionStream - base stream class
111 //
112 
114 {
115 public:
116  /// Stream processing direction.
117  enum EDirection {
118  eRead, ///< Reading from stream
119  eWrite, ///< Writing into stream
120  eReadWrite ///< eRead + eWrite
121  };
122 
123  /// Which of the objects (passed in the constructor) should be
124  /// deleted on this object's destruction.
125  /// NOTE: if the reader and writer are in fact one object, it will
126  /// not be deleted twice.
127  enum EOwnership {
128  fOwnStream = (1<<1), ///< Delete the underlying I/O stream.
129  fOwnReader = (1<<2), ///< Delete the reader.
130  fOwnWriter = (1<<3), ///< Delete the writer.
131  fOwnProcessor = fOwnReader + fOwnWriter,
132  fOwnAll = fOwnStream + fOwnProcessor
133  };
134  typedef int TOwnership; ///< Bitwise OR of EOwnership.
135 
136  /// Constructor
137  ///
138  /// If read/write stream processor is 0 (NULL), that read/write operations
139  /// on this stream will be unsuccessful.
142  CCompressionStreamProcessor* write_sp,
143  TOwnership ownership = 0);
144 
145  /// Destructor
146  virtual ~CCompressionStream(void);
147 
148  /// Finalize stream's compression/decompression process for read/write.
149  /// This function just calls a streambuf Finalize().
150  virtual void Finalize(CCompressionStream::EDirection dir =
152 
153 protected:
154  /// Default constructor.
155  ///
156  /// Default constructor allow to create stream with specific
157  /// characteristics later, not necessary in the constructor.
158  /// Can be used in derived classes.
159  /// @sa Create()
160  CCompressionStream(void);
161 
162  /// Create stream with specific characteristics later,
163  /// not necessary in the constructor.
164  /// Do nothing, if stream is already initialized.
165  void Create(CNcbiIos& stream,
167  CCompressionStreamProcessor* write_sp,
168  TOwnership ownership = 0);
169 
170 protected:
171  /// Get status of last compression/decompression stream operation.
173  /// Get error code and description of last compressor/decompressor stream operation.
174  /// Return TRUE if information obtained successfully.
175  bool x_GetError(CCompressionStream::EDirection dir,
176  int& status, string& description);
177  /// Return number of processed bytes.
178  size_t x_GetProcessedSize(CCompressionStream::EDirection dir);
179  /// Return number of output bytes.
180  size_t x_GetOutputSize(CCompressionStream::EDirection dir);
181 
182 
183 protected:
184  CNcbiIos* m_Stream; ///< Underlying stream.
185  CCompressionStreambuf* m_StreamBuf; ///< Stream buffer.
186  CCompressionStreamProcessor* m_Reader; ///< Read processor.
187  CCompressionStreamProcessor* m_Writer; ///< Write processor.
188  TOwnership m_Ownership; ///< Bitwise OR of EOwnership.
189 
190 private:
191  /// Private copy constructor to prohibit copy.
193  /// Private assignment operator to prohibit assignment.
195 };
196 
197 
198 
199 //////////////////////////////////////////////////////////////////////////////
200 //
201 // CCompressionStreamProcessor class
202 //
203 // Container class for storing a stream's processor read/write info.
204 //
205 
207 {
208 public:
209  /// If to delete the used compression processor in the destructor.
211  eDelete, ///< Do delete processor object.
212  eNoDelete ///< Do not delete processor object.
213  };
214 
215  /// Stream processor state.
216  enum EState {
217  eInit, ///< Init() is done, but no data to process.
218  eActive, ///< Processor ready to read/write.
219  eFinalize, ///< Finalize() already done, but End() not yet.
220  eDone ///< End() done, processor cannot process data.
221  };
222 
223  /// Constructor.
225  CCompressionProcessor* processor,
226  EDeleteProcessor need_delete = eNoDelete,
227  streamsize in_bufsize = kCompressionDefaultBufSize,
228  streamsize out_bufsize = kCompressionDefaultBufSize
229  );
230 
231  /// Destructor.
232  virtual ~CCompressionStreamProcessor(void);
233 
234  /// (Re)Initialize stream processor.
235  void Init(void);
236 
237  /// Get stream processor's status
238  bool IsOkay(void) const {
239  return m_Processor && m_Processor->IsBusy() && m_State != eDone;
240  }
241 
242  /// Return a pointer to currently used stream processor.
243  /// Can be used mostly for setting advanced compression-specific parameters
244  /// for stream compressors/decompressors from the upper level code.
246  return m_Processor;
247  }
248 
249 private:
250  CCompressionProcessor* m_Processor; ///< (De)compression processor.
251  CT_CHAR_TYPE* m_InBuf; ///< Buffer of unprocessed data.
252  streamsize m_InBufSize; ///< Unprocessed data buffer size.
253  CT_CHAR_TYPE* m_OutBuf; ///< Buffer of processed data.
254  streamsize m_OutBufSize; ///< Processed data buffer size.
255  CT_CHAR_TYPE* m_Begin; ///< Begin and end of the pre/post
256  CT_CHAR_TYPE* m_End; ///< processed data in the buffer.
257  EDeleteProcessor m_NeedDelete; ///< m_Processor auto-deleting flag.
259  m_LastStatus; ///< Last compressor status.
260  EState m_State; ///< Stream processor state.
261 
262  // Friend classes
263  friend class CCompressionStream;
264  friend class CCompressionStreambuf;
265 
266 private:
267  /// Private copy constructor to prohibit copy.
269  /// Private assignment operator to prohibit assignment.
271 };
272 
273 
274 
275 //////////////////////////////////////////////////////////////////////////////
276 //
277 // I/O stream classes
278 //
279 
281  public CCompressionStream
282 {
283 public:
285  CCompressionStreamProcessor* stream_processor,
286  TOwnership ownership = 0)
287  : CNcbiIstream(0),
288  CCompressionStream(stream, stream_processor, 0, ownership)
289  {}
290 
291  /// Get status of last compression/decompression stream operation.
294  }
295  /// Get error code and description of last compressor/decompressor stream operation.
296  /// Return TRUE if information obtained successfully.
297  bool GetError(int& status, string& description) {
298  return CCompressionStream::x_GetError(eRead, status, description);
299  }
300  /// Get total number of bytes processed by "stream_processor".
301  /// This method don't count bytes cached in the internal buffers
302  /// and waiting to be compressed/decompressed. Usually, only after
303  /// stream finalization by Finalize() it will be equal a number of
304  /// bytes read from underlying stream.
305  size_t GetProcessedSize(void) {
307  };
308  /// Get total number of bytes, that "stream_processor" returns.
309  /// This method don't equal a number of bytes read from stream.
310  /// Some data can be still cashed in the internal buffer.
311  /// Usually, only after stream finalization by Finalize() it
312  /// will be equal a size of decompressed data in underlying stream.
313  size_t GetOutputSize(void) {
315  };
316  /// Auxiliary method to read from stream.
317  /// Read up to "len" bytes from the stream into the buffer "buf".
318  /// Returning value less than "n" mean EOF or error, check stream state bits for details.
319  /// @note Allow to read more than 4GB, that regular read() cannot handle on some platforms.
320  size_t Read(void* buf, size_t len);
321 
322 protected:
323  /// Default constructor.
324  ///
325  /// Default constructor allow to create stream with specific
326  /// characteristics later. Can be used in derived classes.
327  /// @sa CCompressionStream, Create()
329 
330  /// Create stream with specific characteristics.
331  /// Do nothing, if stream is already created.
332  /// @sa CCompressionStream
333  void Create(CNcbiIos& stream,
334  CCompressionStreamProcessor* stream_processor,
335  TOwnership ownership = 0)
336  {
337  CCompressionStream::Create(stream, stream_processor, 0, ownership);
338  }
339 
340 private:
341  /// Define this method to avoid compiler warnings only.
342  void Create(CNcbiIos& /*stream*/,
343  CCompressionStreamProcessor* /*read_sp*/,
344  CCompressionStreamProcessor* /*write_sp*/,
345  TOwnership ownership = 0);
346 
347  /// Disable operator<<(bool)
348  void operator<<(bool) const;
349 };
350 
351 
353  public CCompressionStream
354 {
355 public:
357  CCompressionStreamProcessor* stream_processor,
358  TOwnership ownership = 0)
359  : CNcbiOstream(0),
360  CCompressionStream(stream, 0, stream_processor, ownership)
361  {}
362 
363  /// Get status of last compression/decompression stream operation.
365  return CCompressionStream::x_GetStatus(eWrite);
366  }
367  /// Get error code and description of last compressor/decompressor stream operation.
368  /// Return TRUE if information obtained successfully.
369  bool GetError(int& status, string& description) {
370  return CCompressionStream::x_GetError(eWrite, status, description);
371  }
372  /// Get total number of bytes processed by "stream_processor".
373  /// This method don't count bytes cached in the internal buffers
374  /// and waiting to be compressed/decompressed. Usually, only after
375  /// stream finalization by Finalize() it will be equal a number of
376  /// bytes written into stream.
377  size_t GetProcessedSize(void) {
379  };
380  /// Get total number of bytes, that "stream_processor" returns.
381  /// This method don't equal a number of bytes written to underlying
382  /// stream, some data can be still cashed in the internal buffer
383  /// for better I/O performance. Usually, only after stream
384  /// finalization by Finalize() these numvbers will be equal.
385  size_t GetOutputSize(void) {
387  };
388  /// Finalize stream's compression/decompression process for read/write.
389  /// This function just calls a streambuf Finalize().
391  if ( m_StreamBuf ) {
393  flush();
394  }
395  };
396  /// Auxiliary method to write into stream.
397  /// Write up "len" bytes from the buffer "buf" into the stream.
398  /// Returning value less than "n" mean error, check stream state bits for details.
399  /// @note Allow to write more than 4GB, that regular write() cannot handle on some platforms.
400  size_t Write(const void* buf, size_t len);
401 
402 protected:
403  /// Default constructor.
404  ///
405  /// Default constructor allow to create stream with specific
406  /// characteristics later, not necessary in the constructor.
407  /// Can be used in derived classes.
408  /// @sa CCompressionStream, Create()
410 
411  /// Create stream with specific characteristics later,
412  /// not necessary in the constructor.
413  /// Do nothing, if stream is already initialized.
414  /// @sa CCompressionStream
415  void Create(CNcbiIos& stream,
416  CCompressionStreamProcessor* stream_processor,
417  TOwnership ownership = 0)
418  {
419  CCompressionStream::Create(stream, 0, stream_processor, ownership);
420  }
421 
422 private:
423  /// Define this method to avoid compiler warnings only.
424  void Create(CNcbiIos& /*stream*/,
425  CCompressionStreamProcessor* /*read_sp*/,
426  CCompressionStreamProcessor* /*write_sp*/,
427  TOwnership ownership = 0);
428 
429  /// Disable operator>>(bool)
430  void operator>>(bool) const;
431 };
432 
433 
435  public CCompressionStream
436 {
437 public:
440  CCompressionStreamProcessor* write_sp,
441  TOwnership ownership = 0)
442  : CNcbiIostream(0),
443  CCompressionStream(stream, read_sp, write_sp, ownership)
444  { }
445 
446  /// Get status of last compression/decompression stream operation.
450  }
451  /// Get error code and description of last compressor/decompressor stream operation.
452  /// Return TRUE if information obtained successfully.
454  int& status, string& description) {
455  return CCompressionStream::x_GetError(dir, status, description);
456  }
457  /// Get total number of bytes processed by specified "stream_processor".
458  /// @sa CCompressionIStream, CCompressionOStream
461  };
462  /// Get total number of bytes, that "stream_processor" returns.
463  /// @sa CCompressionIStream, CCompressionOStream
466  };
467  /// Finalize stream's compression/decompression process for read/write.
468  /// This function just calls a streambuf Finalize().
470  if ( m_StreamBuf ) {
472  flush();
473  }
474  };
475  /// Auxiliary method to read from stream.
476  /// Read up to "len" bytes from the stream into the buffer "buf".
477  /// Returning value less than "n" mean EOF or error, check stream state bits for details.
478  /// @note Allow to read more than 4GB, that regular read() cannot handle on some platforms.
479  size_t Read(void* buf, size_t len);
480 
481  /// Auxiliary method to write into stream.
482  /// Write up "len" bytes from the buffer "buf" into the stream.
483  /// Returning value less than "n" mean error, check stream state bits for details.
484  /// @note Allow to write more than 4GB, that regular write() cannot handle on some platforms.
485  size_t Write(const void* buf, size_t len);
486 
487 protected:
488  /// Default constructor.
489  ///
490  /// Default constructor allow to create stream with specific
491  /// characteristics later, not necessary in the constructor.
492  /// Can be used in derived classes.
493  /// @sa CCompressionStream, Create()
495 };
496 
497 
498 
499 /////////////////////////////////////////////////////////////////////////////
500 ///
501 /// CTransparentProcessor -- memory-copy processor
502 ///
503 /// Do not perform any compression/decompression, just copy data from input
504 /// buffer to output buffer. Can be used as adapter to work with uncompressed
505 /// data in compression streams.
506 /// Used in CTransparentStreamCompressor.
507 /// @sa CCompressionProcessor, CTransparentStreamProcessor
508 
510 {
511 public:
513  virtual ~CTransparentProcessor(void);
514  virtual bool AllowEmptyData() const { return true; }
515 
516 protected:
517  virtual EStatus Init (void);
518  virtual EStatus Process(const char* in_buf, size_t in_len,
519  char* out_buf, size_t out_size,
520  /* out */ size_t* in_avail,
521  /* out */ size_t* out_avail);
522  virtual EStatus Flush (char* out_buf, size_t out_size,
523  /* out */ size_t* out_avail);
524  virtual EStatus Finish (char* out_buf, size_t out_size,
525  /* out */ size_t* out_avail);
526  virtual EStatus End (int abandon = 0);
527 };
528 
529 
530 //////////////////////////////////////////////////////////////////////////////
531 ///
532 /// CTransparentStreamProcessor -- stream processor to copy data "as is".
533 ///
534 /// See util/compress/stream.hpp for details of stream processing.
535 /// @sa CCompressionStreamProcessor, CTransparentProcessor
536 
539 {
540 public:
541  /// Full constructor
543  streamsize in_bufsize,
544  streamsize out_bufsize
545  )
547  new CTransparentProcessor(), eDelete, in_bufsize, out_bufsize)
548  {}
549  /// Conventional constructor
552  new CTransparentProcessor(),
554  {}
555 };
556 
557 
559 
560 
561 /* @} */
562 
563 #endif /* UTIL_COMPRESS__STREAM__HPP */
EStatus
CTransparentProcessor – memory-copy processor.
Definition: stream.hpp:510
CTransparentStreamProcessor – stream processor to copy data "as is".
Definition: stream.hpp:539
static void Init(void)
Definition: cursor6.c:76
CT_CHAR_TYPE * m_OutBuf
Buffer of processed data.
Definition: stream.hpp:253
virtual void Finalize(CCompressionStream::EDirection dir=CCompressionStream::eWrite)
Finalize stream's compression/decompression process for read/write.
Definition: stream.hpp:390
CCompressionStreambuf * m_StreamBuf
Stream buffer.
Definition: stream.hpp:185
CCompressionStreamProcessor * m_Writer
Write processor.
Definition: stream.hpp:187
void operator<<(bool) const
Disable operator<<(bool)
bool x_GetError(CCompressionStream::EDirection dir, int &status, string &description)
Get error code and description of last compressor/decompressor stream operation.
Definition: stream.cpp:203
CCompressionStreamProcessor * m_Reader
Read processor.
Definition: stream.hpp:186
virtual bool AllowEmptyData() const
Return TRUE if fAllowEmptyData flag is set for this compression.
Definition: stream.hpp:514
bool GetError(int &status, string &description)
Get error code and description of last compressor/decompressor stream operation.
Definition: stream.hpp:297
TOwnership m_Ownership
Bitwise OR of EOwnership.
Definition: stream.hpp:188
CTransparentProcessor(void)
Definition: stream.hpp:512
EState m_State
Stream processor state.
Definition: stream.hpp:260
void Create(CNcbiIos &, CCompressionStreamProcessor *, CCompressionStreamProcessor *, TOwnership ownership=0)
Define this method to avoid compiler warnings only.
CCompressionIOStream(void)
Default constructor.
Definition: stream.hpp:494
virtual void Finalize(CCompressionStream::EDirection dir=CCompressionStream::eReadWrite)
Finalize stream's compression/decompression process for read/write.
Definition: stream.hpp:469
CCompressionProcessor::EStatus GetStatus(void)
Get status of last compression/decompression stream operation.
Definition: stream.hpp:292
size_t GetProcessedSize(CCompressionStream::EDirection dir)
Get total number of bytes processed by specified "stream_processor".
Definition: stream.hpp:459
void Create(CNcbiIos &stream, CCompressionStreamProcessor *stream_processor, TOwnership ownership=0)
Create stream with specific characteristics later, not necessary in the constructor.
Definition: stream.hpp:415
CCompressionIStream(CNcbiIos &stream, CCompressionStreamProcessor *stream_processor, TOwnership ownership=0)
Definition: stream.hpp:284
EDeleteProcessor
If to delete the used compression processor in the destructor.
Definition: stream.hpp:210
size_t GetProcessedSize(void)
Get total number of bytes processed by "stream_processor".
Definition: stream.hpp:377
size_t GetOutputSize(CCompressionStream::EDirection dir)
Get total number of bytes, that "stream_processor" returns.
Definition: stream.hpp:464
CCompressionIStream(void)
Default constructor.
Definition: stream.hpp:328
size_t GetProcessedSize(void)
Get total number of bytes processed by "stream_processor".
Definition: stream.hpp:305
CCompressionProcessor * GetProcessor(void) const
Return a pointer to currently used stream processor.
Definition: stream.hpp:245
CCompressionProcessor::EStatus GetStatus(CCompressionStream::EDirection dir)
Get status of last compression/decompression stream operation.
Definition: stream.hpp:448
size_t GetOutputSize(void)
Get total number of bytes, that "stream_processor" returns.
Definition: stream.hpp:385
CCompressionOStream(CNcbiIos &stream, CCompressionStreamProcessor *stream_processor, TOwnership ownership=0)
Definition: stream.hpp:356
size_t x_GetProcessedSize(CCompressionStream::EDirection dir)
Return number of processed bytes.
Definition: stream.cpp:225
streamsize m_OutBufSize
Processed data buffer size.
Definition: stream.hpp:254
CT_CHAR_TYPE * m_Begin
Begin and end of the pre/post.
Definition: stream.hpp:255
CCompressionProcessor::EStatus x_GetStatus(CCompressionStream::EDirection dir)
Get status of last compression/decompression stream operation.
Definition: stream.cpp:193
void Create(CNcbiIos &, CCompressionStreamProcessor *, CCompressionStreamProcessor *, TOwnership ownership=0)
Define this method to avoid compiler warnings only.
void Create(CNcbiIos &stream, CCompressionStreamProcessor *read_sp, CCompressionStreamProcessor *write_sp, TOwnership ownership=0)
Create stream with specific characteristics later, not necessary in the constructor.
Definition: stream.cpp:123
bool GetError(int &status, string &description)
Get error code and description of last compressor/decompressor stream operation.
Definition: stream.hpp:369
CNcbiIos * m_Stream
Underlying stream.
Definition: stream.hpp:184
size_t GetOutputSize(void)
Get total number of bytes, that "stream_processor" returns.
Definition: stream.hpp:313
CTransparentStreamProcessor(streamsize in_bufsize, streamsize out_bufsize)
Full constructor.
Definition: stream.hpp:542
void operator>>(bool) const
Disable operator>>(bool)
bool GetError(CCompressionStream::EDirection dir, int &status, string &description)
Get error code and description of last compressor/decompressor stream operation.
Definition: stream.hpp:453
virtual void Finalize(CCompressionStream::EDirection dir=CCompressionStream::eReadWrite)
Finalize stream's compression/decompression process for read/write.
Definition: stream.cpp:177
CTransparentStreamProcessor(void)
Conventional constructor.
Definition: stream.hpp:550
CCompressionStream(const CCompressionStream &)
Private copy constructor to prohibit copy.
CCompressionProcessor::EStatus m_LastStatus
Last compressor status.
Definition: stream.hpp:259
CCompressionProcessor * m_Processor
(De)compression processor.
Definition: stream.hpp:250
CCompressionStreamProcessor(const CCompressionStreamProcessor &)
Private copy constructor to prohibit copy.
CCompressionOStream(void)
Default constructor.
Definition: stream.hpp:409
streamsize m_InBufSize
Unprocessed data buffer size.
Definition: stream.hpp:252
bool IsOkay(void) const
Get stream processor's status.
Definition: stream.hpp:238
CCompressionIOStream(CNcbiIos &stream, CCompressionStreamProcessor *read_sp, CCompressionStreamProcessor *write_sp, TOwnership ownership=0)
Definition: stream.hpp:438
EDeleteProcessor m_NeedDelete
m_Processor auto-deleting flag.
Definition: stream.hpp:257
CCompressionProcessor::EStatus GetStatus(void)
Get status of last compression/decompression stream operation.
Definition: stream.hpp:364
EDirection
Stream processing direction.
Definition: stream.hpp:117
CT_CHAR_TYPE * m_InBuf
Buffer of unprocessed data.
Definition: stream.hpp:251
EOwnership
Which of the objects (passed in the constructor) should be deleted on this object's destruction.
Definition: stream.hpp:127
size_t x_GetOutputSize(CCompressionStream::EDirection dir)
Return number of output bytes.
Definition: stream.cpp:235
void Create(CNcbiIos &stream, CCompressionStreamProcessor *stream_processor, TOwnership ownership=0)
Create stream with specific characteristics.
Definition: stream.hpp:333
int TOwnership
Bitwise OR of EOwnership.
Definition: stream.hpp:134
CT_CHAR_TYPE * m_End
processed data in the buffer.
Definition: stream.hpp:256
@ eActive
Processor ready to read/write.
Definition: stream.hpp:218
@ eFinalize
Finalize() already done, but End() not yet.
Definition: stream.hpp:219
@ eInit
Init() is done, but no data to process.
Definition: stream.hpp:217
@ eDelete
Do delete processor object.
Definition: stream.hpp:211
@ eWrite
Writing into stream.
Definition: stream.hpp:119
@ eRead
Reading from stream.
Definition: stream.hpp:118
@ eReadWrite
eRead + eWrite
Definition: stream.hpp:120
const streamsize kCompressionDefaultBufSize
Default compression I/O stream buffer size.
Definition: compress.hpp:111
EStatus
Type of the result of all basic functions.
Definition: compress.hpp:467
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:60
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:55
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
IO_PREFIX::iostream CNcbiIostream
Portable alias for iostream.
Definition: ncbistre.hpp:152
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
IO_PREFIX::ios CNcbiIos
Portable alias for ios.
Definition: ncbistre.hpp:140
#define CT_CHAR_TYPE
Definition: ncbistre.hpp:729
virtual void Process(SOCK sock)=0
Runs asynchronously (from a separate thread) for each request.
char * buf
int len
@ eRead
Definition: ns_types.hpp:56
NCBI_XUTIL_EXPORT
Parameter to control printing diagnostic message about conversion of static array data from a differe...
Definition: static_set.hpp:72
Modified on Fri Sep 20 14:58:14 2024 by modify_doxy.py rev. 669887