NCBI C++ ToolKit
rwstreambuf.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: rwstreambuf.cpp 102704 2024-06-27 18:45:39Z lavr $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Anton Lavrentiev
27  *
28  * File Description:
29  * Reader-writer based stream buffer
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbidbg.hpp>
35 #include <corelib/ncbiexpt.hpp>
36 #include <corelib/ncbi_limits.hpp>
38 #include <corelib/rwstream.hpp>
39 #include <corelib/error_codes.hpp>
40 
41 #define NCBI_USE_ERRCODE_X Corelib_StreamBuf
42 
43 
44 #define RWSTREAMBUF_HANDLE_EXCEPTIONS(call, subcode, message, action) \
45  /* Invoke 'action' only if an exception was [silently] caught */ \
46  switch (m_Flags & (fLogExceptions | fLeakExceptions)) { \
47  case fLeakExceptions: \
48  result = call; \
49  break; \
50  case 0: \
51  try { \
52  result = call; \
53  break; \
54  } \
55  catch (...) { \
56  } \
57  action; \
58  break; \
59  default: \
60  /* Exception logging (and maybe re-throwing) */ \
61  try { \
62  result = call; \
63  break; \
64  } \
65  catch (CException& e) { \
66  try { \
67  NCBI_REPORT_EXCEPTION_X(subcode, message, e); \
68  } catch (...) { \
69  } \
70  if (m_Flags & fLeakExceptions) \
71  throw; \
72  } \
73  catch (exception& e) { \
74  try { \
75  ERR_POST_X(subcode, Error \
76  << '[' << message \
77  << "] Exception: " << e.what()); \
78  } catch (...) { \
79  } \
80  if (m_Flags & fLeakExceptions) \
81  throw; \
82  } \
83  catch (...) { \
84  try { \
85  ERR_POST_X(subcode, Error \
86  << '[' << message << "] Unknown exception"); \
87  } catch (...) { \
88  } \
89  if (m_Flags & fLeakExceptions) \
90  throw; \
91  } \
92  action; \
93  break; \
94  } \
95  if (result != eRW_Success && result != eRW_NotImplemented \
96  && !(m_Flags & fNoStatusLog)) { \
97  bool trace = (result == eRW_Timeout || \
98  result == eRW_Eof ? true : false); \
99  ERR_POST_X(subcode, \
100  Message << (trace ? Trace : Info) << message \
101  << ": " << &g_RW_ResultToString(result)[4/*eRW_*/]); \
102  }
103 
104 
106 
107 
109 {
110  static const char* const kResultStr[eRW_Eof - eRW_NotImplemented + 1] = {
111  "eRW_NotImplemented",
112  "eRW_Success",
113  "eRW_Timeout",
114  "eRW_Error",
115  "eRW_Eof"
116  };
117 
119  return kResultStr[result - eRW_NotImplemented];
120 }
121 
122 static const streamsize kDefaultBufSize = 16384;
123 
124 
125 static inline EOwnership x_IfToOwnReader(const IReader* r, const IWriter* w,
127 {
128  const IReaderWriter* rw = dynamic_cast<const IReaderWriter*> (r);
129  if (!rw || rw != dynamic_cast<const IReaderWriter*> (w)) {
131  return eTakeOwnership;
132  } else {
133  if (f & CRWStreambuf::fOwnAll)
134  return eTakeOwnership;
135  }
136  return eNoOwnership;
137 }
138 
139 
140 static inline EOwnership x_IfToOwnWriter(const IReader* r, const IWriter* w,
142 {
143  const IReaderWriter* rw = dynamic_cast<const IReaderWriter*> (w);
144  if (!rw || rw != dynamic_cast<const IReaderWriter*> (r)) {
146  return eTakeOwnership;
147  } /* else IReader sets the ownership */
148  return eNoOwnership;
149 }
150 
151 
152 static inline bool x_CheckRW(const void* rw)
153 {
154  if ( rw )
155  return true;
156 #if !defined(NCBI_COMPILER_GCC) || NCBI_COMPILER_VERSION >= 700
157  // GCC C++ STL has a bug that sentry ctor does not include try/catch, so it
158  // leaks the exceptions instead of setting badbit as the standard requires.
159  THROW1_TRACE(IOS_BASE::failure, "eRW_NotImplemented");
160 #endif // !NCBI_COMPILER_GCC || NCBI_COMPILER_VERSION>=700
161  return false;
162 }
163 
164 
166  streamsize n,
167  CT_CHAR_TYPE* s,
169  : m_Flags(f),
170  m_Reader(rw, x_IfToOwnReader(rw, rw, f)),
171  m_Writer(rw, x_IfToOwnWriter(rw, rw, f)), m_pBuf(0),
172  x_GPos((CT_OFF_TYPE) 0), x_PPos((CT_OFF_TYPE) 0),
173  x_Eof(false), x_Err(false), x_ErrPos((CT_OFF_TYPE) 0)
174 {
175  setbuf(n && s ? s : 0,
176  n ? n : kDefaultBufSize << 1);
177 }
178 
179 
181  IWriter* w,
182  streamsize n,
183  CT_CHAR_TYPE* s,
185  : m_Flags(f),
186  m_Reader(r, x_IfToOwnReader(r, w, f)),
187  m_Writer(w, x_IfToOwnWriter(r, w, f)), m_pBuf(0),
188  x_GPos((CT_OFF_TYPE) 0), x_PPos((CT_OFF_TYPE) 0),
189  x_Eof(false), x_Err(false), x_ErrPos((CT_OFF_TYPE) 0)
190 {
191  setbuf(n && s ? s : 0,
192  n ? n : kDefaultBufSize << (m_Reader && m_Writer ? 1 : 0));
193 }
194 
195 
197 {
198  if ( !m_Reader ) {
199  _ASSERT(!gptr() && !egptr());
200  return eRW_Success;
201  }
202 
204  _ASSERT(egptr() >= gptr());
205  const CT_CHAR_TYPE* ptr = gptr();
206  size_t count = (size_t)(egptr() - ptr);
207  setg(0, 0, 0);
208  if ( count ) {
210  m_Reader->Pushback(ptr, count, m_pBuf),
211  14, "CRWStreambuf::Pushback(): IReader::Pushback()",
212  result = eRW_Error);
213  if (result == eRW_Error)
214  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
215  if (result == eRW_Success)
216  m_pBuf = 0;
217  x_Eof = false;
218  } else
220  return result;
221 }
222 
223 
225 {
226  try {
227  // Push any still unread data from the buffer back to the device
230  ERR_POST_X(13, "CRWStreambuf::~CRWStreambuf():"
231  " Read data pending");
232  }
233  // Flush only if data pending and no error
234  if (!x_Err || x_ErrPos != x_GetPPos())
235  x_Sync();
236  setp(0, 0);
237  } NCBI_CATCH_ALL_X(2, "Exception in ~CRWStreambuf() [IGNORED]");
238 
239  delete[] m_pBuf;
240 }
241 
242 
244 {
245  if (x_Pushback() != eRW_Success)
246  ERR_POST_X(3,Critical << "CRWStreambuf::setbuf(): Read data pending");
247  if (x_Sync() != 0)
248  ERR_POST_X(4,Critical << "CRWStreambuf::setbuf(): Write data pending");
249  setp(0, 0);
250 
251  delete[] m_pBuf;
252  m_pBuf = 0;
253 
254  size_t n = (size_t) m;
255  if ( !n ) {
256  if ( s ) {
257  // setbuf(s, 0);
258  _ASSERT(kDefaultBufSize > 1); // new[] to always follow, n > 1
259  n = (size_t) kDefaultBufSize << (m_Reader && m_Writer ? 1 : 0);
260  s = 0/*ignore*/;
261  } else
262  n = 1;
263  }
264  if ( !s )
265  s = n == 1 ? &x_Buf : (m_pBuf = new CT_CHAR_TYPE[n]);
266 
267  if ( m_Reader ) {
268  m_BufSize = n == 1 ? 1 : n >> (m_Reader && m_Writer ? 1 : 0);
269  m_ReadBuf = s;
270  } else {
271  m_BufSize = 0;
272  m_ReadBuf = 0;
273  }
274  setg(m_ReadBuf, m_ReadBuf, m_ReadBuf);
275 
276  if ( m_Writer )
277  m_WriteBuf = n == 1 ? 0 : s + m_BufSize;
278  else
279  m_WriteBuf = 0;
280  setp(m_WriteBuf, m_WriteBuf + (m_WriteBuf ? n - m_BufSize : 0));
281 
282  return this;
283 }
284 
285 
287 {
288  _ASSERT(CT_EQ_INT_TYPE(c, CT_EOF) || pptr() >= epptr());
289  _ASSERT(pbase() <= pptr() && pptr() <= epptr());
290 
291  if ( !x_CheckRW(m_Writer.get()) )
292  return CT_EOF;
293 
294  size_t n_written;
295  size_t n_towrite = (size_t)(pptr() - pbase());
296 
298 
299  if ( n_towrite ) {
300  // Send a buffer
301  do {
302  n_written = 0;
304  m_Writer->Write(pbase(), n_towrite, &n_written),
305  5, "CRWStreambuf::overflow(): IWriter::Write()",
306  (n_written = 0, result = eRW_Error));
307  _ASSERT(n_written <= n_towrite);
308  if ( !n_written ) {
310  break;
311  }
312  // Update buffer contents (get rid of the data just sent)
313  memmove(pbase(), pbase() + n_written, n_towrite - n_written);
314  x_PPos += (CT_OFF_TYPE) n_written;
315  pbump(-int(n_written));
316 
317  // Store a char
318  if ( !CT_EQ_INT_TYPE(c, CT_EOF) ) {
319  x_Err = false;
320  return sputc(CT_TO_CHAR_TYPE(c));
321  }
322  n_towrite -= n_written;
323  } while (n_towrite && result == eRW_Success);
324  if ( n_towrite ) {
326  x_Err = true;
327  x_ErrPos = x_GetPPos();
328  if (result == eRW_Error)
329  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
330  return CT_EOF;
331  }
332  } else if ( !CT_EQ_INT_TYPE(c, CT_EOF) ) {
333  // Send a char
335  n_written = 0;
337  m_Writer->Write(&b, 1, &n_written),
338  6, "CRWStreambuf::overflow(): IWriter::Write(1)",
339  (n_written = 0, result = eRW_Error));
340  _ASSERT(n_written <= 1);
341  if ( !n_written ) {
343  x_Err = true;
344  x_ErrPos = x_GetPPos();
345  if (result == eRW_Error)
346  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
347  return CT_EOF;
348  }
349  x_PPos += (CT_OFF_TYPE) 1;
350  x_Err = false;
351  return c;
352  }
353 
356  m_Writer->Flush(),
357  7, "CRWStreambuf::overflow(): IWriter::Flush()",
358  result = eRW_Error);
359  switch ( result ) {
360  case eRW_Eof:
361  case eRW_Error:
362  x_Err = true;
363  x_ErrPos = x_GetPPos();
364  if (result == eRW_Error)
365  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
366  return CT_EOF;
367  default:
368  break;
369  }
370  x_Err = false;
371  return CT_NOT_EOF(CT_EOF);
372 }
373 
374 
375 streamsize CRWStreambuf::xsputn(const CT_CHAR_TYPE* buf, streamsize m)
376 {
377  _ASSERT(pbase() <= pptr() && pptr() <= epptr());
378 
379  if (!x_CheckRW(m_Writer.get()) || m < 0)
380  return 0;
381 
383  size_t n = (size_t) m;
384  size_t n_written = 0;
385  size_t x_written;
386  x_Err = false;
387 
389 
390  do {
391  if ( pbase() ) {
392  if (n && pbase() + n < epptr()) {
393  // Would entirely fit into the buffer not causing an overflow
394  x_written = (size_t)(epptr() - pptr());
395  if (x_written > n)
396  x_written = n;
397  if ( x_written ) {
398  memcpy(pptr(), buf, x_written);
399  pbump(int(x_written));
400  n_written += x_written;
401  n -= x_written;
402  if ( !n )
403  return (streamsize) n_written;
404  buf += x_written;
405  }
406  }
407 
408  size_t x_towrite = (size_t)(pptr() - pbase());
409  if ( x_towrite ) {
410  x_written = 0;
412  m_Writer->Write(pbase(), x_towrite, &x_written),
413  8, "CRWStreambuf::xsputn(): IWriter::Write()",
414  (x_written = 0, result = eRW_Error));
415  _ASSERT(x_written <= x_towrite);
416  if ( !x_written ) {
418  x_Err = true;
419  x_ErrPos = x_GetPPos();
420  break;
421  }
422  memmove(pbase(), pbase() + x_written, x_towrite - x_written);
423  x_PPos += (CT_OFF_TYPE) x_written;
424  pbump(-int(x_written));
425  continue;
426  }
427  }
428 
429  x_written = 0;
431  m_Writer->Write(buf, n, &x_written),
432  9, "CRWStreambuf::xsputn(): IWriter::Write()",
433  (x_written = 0, result = eRW_Error));
434  _ASSERT(x_written <= n);
435  if (!x_written && n) {
437  x_Err = true;
438  x_ErrPos = x_GetPPos();
439  break;
440  }
441  x_PPos += (CT_OFF_TYPE) x_written;
442  n_written += x_written;
443  n -= x_written;
444  if ( !n )
445  return (streamsize) n_written;
446  buf += x_written;
447  } while (result == eRW_Success);
448 
449  _ASSERT(n && result != eRW_Success && x_Err);
450 
451  if ( pbase() ) {
452  x_written = (size_t)(epptr() - pptr());
453  if ( x_written ) {
454  if (x_written > n)
455  x_written = n;
456  memcpy(pptr(), buf, x_written);
457  n_written += x_written;
458  pbump(int(x_written));
459  }
460  }
461 
462  if (!n_written && result == eRW_Error)
463  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
464  return (streamsize) n_written;
465 }
466 
467 
469 {
470  _ASSERT(gptr() >= egptr());
471 
472  if ( !x_CheckRW(m_Reader.get()) )
473  return CT_EOF;
474 
475  // Flush output buffer, if tied up to it
476  if (!(m_Flags & fUntie) && x_Sync() != 0)
477  return CT_EOF;
478 
479  if (x_Eof)
480  return CT_EOF;
481 
482 #ifdef NCBI_COMPILER_MIPSPRO
483  if (m_MIPSPRO_ReadsomeGptrSetLevel && m_MIPSPRO_ReadsomeGptr != gptr())
484  return CT_EOF;
485  m_MIPSPRO_ReadsomeGptr = (CT_CHAR_TYPE*)(-1L);
486 #endif /*NCBI_COMPILER_MIPSPRO*/
487 
488  // Read from device
490  size_t n_read = 0;
493  m_Reader->Read(m_ReadBuf, m_BufSize, &n_read),
494  10, "CRWStreambuf::underflow(): IReader::Read()",
495  (n_read = 0, result = eRW_Error));
496  _ASSERT(n_read <= m_BufSize);
497  if ( !n_read ) {
499  switch ( result ) {
500  case eRW_Error:
501  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
502  break;
503  case eRW_Eof:
504  x_Eof = true;
505  break;
506  default:
507  break;
508  }
509  return CT_EOF;
510  }
511 
512  // Update input buffer with the data just read
513  x_GPos += (CT_OFF_TYPE) n_read;
514  setg(m_ReadBuf, m_ReadBuf, m_ReadBuf + n_read);
515 
516  return CT_TO_INT_TYPE(*m_ReadBuf);
517 }
518 
519 
520 streamsize CRWStreambuf::x_Read(CT_CHAR_TYPE* buf, streamsize m)
521 {
522  _ASSERT( m_Reader );
523 
524  // Flush output buffer, if tied up to it
525  if (!(m_Flags & fUntie) && x_Sync() != 0)
526  return 0;
527 
528  if (m < 0)
529  return 0;
530 
532  size_t n = (size_t) m;
533  size_t n_read;
534 
535  if ( n ) {
536  // First, read from the memory buffer
537  n_read = (size_t)(egptr() - gptr());
538  if (n_read > n)
539  n_read = n;
540  if (buf)
541  memcpy(buf, gptr(), n_read);
542  gbump(int(n_read));
543  n -= n_read;
544  if ( !n )
545  return (streamsize) n_read;
546  if (buf)
547  buf += n_read;
548  } else
549  n_read = 0;
550 
551  if ( x_Eof )
552  return (streamsize) n_read;
553 
555 
556  do {
557  // Next, read directly from the device
558  size_t x_toread = !buf || (n && n < m_BufSize) ? m_BufSize : n;
559  CT_CHAR_TYPE* x_buf = !buf || ( n < m_BufSize) ? m_ReadBuf : buf;
560  size_t x_read = 0;
561 
563  m_Reader->Read(x_buf, x_toread, &x_read),
564  11, "CRWStreambuf::xsgetn(): IReader::Read()",
565  (x_read = 0, result = eRW_Error));
566  _ASSERT(x_read <= x_toread);
567  if ( !x_read ) {
568  _ASSERT(!x_toread || result != eRW_Success);
569  break;
570  }
571  x_GPos += (CT_OFF_TYPE) x_read;
572  // Satisfy "usual backup condition", see standard: 27.5.2.4.3.13
573  if (x_buf == m_ReadBuf) {
574  size_t xx_read = x_read;
575  if (x_read > n)
576  x_read = n;
577  if (buf)
578  memcpy(buf, m_ReadBuf, x_read);
579  setg(m_ReadBuf, m_ReadBuf + x_read, m_ReadBuf + xx_read);
580  } else {
581  _ASSERT(x_read <= n);
582  size_t xx_read = x_read > m_BufSize ? m_BufSize : x_read;
583  memcpy(m_ReadBuf, buf + x_read - xx_read, xx_read);
584  setg(m_ReadBuf, m_ReadBuf + xx_read, m_ReadBuf + xx_read);
585  }
586  n_read += x_read;
587  if (result != eRW_Success)
588  break;
589  if (buf)
590  buf += x_read;
591  n -= x_read;
592  } while ( n );
593 
594  if (!n_read && result == eRW_Error)
595  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
596  else if (result == eRW_Eof)
597  x_Eof = true;
598 
599  return (streamsize) n_read;
600 }
601 
602 
603 streamsize CRWStreambuf::xsgetn(CT_CHAR_TYPE* buf, streamsize m)
604 {
605  _ASSERT(gptr() <= egptr());
606 
607  return x_CheckRW(m_Reader.get()) ? x_Read(buf, m) : 0;
608 }
609 
610 
611 streamsize CRWStreambuf::showmanyc(void)
612 {
613  _ASSERT(gptr() >= egptr());
614 
615  if ( !x_CheckRW(m_Reader.get()) )
616  return -1L;
617 
618  // Flush output buffer, if tied up to it
619  if (!(m_Flags & fUntie))
620  x_Sync();
621 
622  if ( x_Eof )
623  return 0;
624 
625  size_t count = 0;
629  12, "CRWStreambuf::showmanyc(): IReader::PendingCount()",
630  result = eRW_Error);
631  switch ( result ) {
632  case eRW_NotImplemented:
633  return 0;
634  case eRW_Success:
635  return count;
636  case eRW_Error:
637  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
638  default:
639  break;
640  }
641  return -1L;
642 }
643 
644 
646 {
648  return -1;
649  _ASSERT(pbase() == pptr());
650  return 0;
651 }
652 
653 
654 CT_POS_TYPE CRWStreambuf::seekoff(CT_OFF_TYPE off, IOS_BASE::seekdir whence,
655  IOS_BASE::openmode which)
656 {
657  if (whence == IOS_BASE::cur && off == 0) {
658  // tellg()/tellp() support
659  switch (which) {
660  case IOS_BASE::in:
661  return x_GetGPos();
662  case IOS_BASE::out:
663  return x_GetPPos();
664  default:
665  break;
666  }
667  } else if (which == IOS_BASE::in
668  && ((whence == IOS_BASE::cur && (off > 0)) ||
669  (whence == IOS_BASE::beg && (off -= x_GetGPos()) >= 0))){
670  if (m_Reader && x_Read(0, (streamsize) off) == (streamsize) off)
671  return x_GetGPos();
672  }
673  return (CT_POS_TYPE)((CT_OFF_TYPE)(-1L));
674 }
675 
676 
virtual streamsize xsgetn(CT_CHAR_TYPE *s, streamsize n)
virtual CT_POS_TYPE seekoff(CT_OFF_TYPE off, IOS_BASE::seekdir whence, IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out)
Only seekoff(0, IOS_BASE::cur, *) to obtain current position, and input skip-forward are permitted: s...
size_t m_BufSize
virtual CT_INT_TYPE overflow(CT_INT_TYPE c)
CT_CHAR_TYPE * m_WriteBuf
CT_CHAR_TYPE x_Buf
CT_POS_TYPE x_ErrPos
position of the _write_ error (if x_Err)
virtual CNcbiStreambuf * setbuf(CT_CHAR_TYPE *buf, streamsize buf_size)
Per the standard, setbuf(0, 0) makes I/O unbuffered.
@ fOwnReader
Own the underlying reader.
Definition: rwstreambuf.hpp:66
@ fOwnWriter
Own the underlying writer.
Definition: rwstreambuf.hpp:67
@ fUntie
Do not flush before reading.
Definition: rwstreambuf.hpp:69
int TFlags
Bitwise OR of EFlags.
Definition: rwstreambuf.hpp:74
CT_POS_TYPE x_GPos
get position [for istream::tellg()]
ERW_Result x_Pushback(void)
virtual ~CRWStreambuf()
int x_Sync(void)
virtual streamsize showmanyc(void)
CRWStreambuf(IReaderWriter *rw=0, streamsize buf_size=0, CT_CHAR_TYPE *buf=0, TFlags flags=0)
bool x_Err
whether there was a _write_ error
virtual int sync(void)
CT_POS_TYPE x_GetGPos(void)
CT_CHAR_TYPE * m_ReadBuf
bool x_Eof
whether at EOF
streamsize x_Read(CT_CHAR_TYPE *s, streamsize n)
CT_POS_TYPE x_GetPPos(void)
AutoPtr< IReader > m_Reader
AutoPtr< IWriter > m_Writer
virtual streamsize xsputn(const CT_CHAR_TYPE *buf, streamsize n)
virtual CT_INT_TYPE underflow(void)
CT_CHAR_TYPE * m_pBuf
CT_POS_TYPE x_PPos
put position [for ostream::tellp()]
A very basic data-read/write interface.
A very basic data-read interface.
A very basic data-write interface.
Abstract reader-writer interface classes.
std::ofstream out("events_result.xml")
main entry point for tests
static int failure
Definition: t0019.c:11
#define false
Definition: bool.h:36
static FILE * f
Definition: readconf.c:23
element_type * get(void) const
Get pointer.
Definition: ncbimisc.hpp:469
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
void Critical(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1203
#define NCBI_CATCH_ALL_X(err_subcode, message)
Definition: ncbiexpt.hpp:619
#define THROW1_TRACE(exception_class, exception_arg)
Throw trace.
Definition: ncbiexpt.hpp:417
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
ERW_Result
Result codes for I/O operations.
#define CT_OFF_TYPE
Definition: ncbistre.hpp:731
const char * g_RW_ResultToString(ERW_Result result)
virtual ERW_Result Flush(void)=0
Flush pending data (if any) down to the output device.
#define CT_TO_CHAR_TYPE
Definition: ncbistre.hpp:735
virtual ERW_Result PendingCount(size_t *count)=0
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
virtual ERW_Result Pushback(const void *buf, size_t count, void *del_ptr=0)
This method gets called by RStream buffer destructor to return buffered yet still unread (from the st...
virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)=0
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
#define CT_EOF
Definition: ncbistre.hpp:732
#define CT_TO_INT_TYPE
Definition: ncbistre.hpp:734
#define CT_INT_TYPE
Definition: ncbistre.hpp:728
virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read=0)=0
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
#define CT_EQ_INT_TYPE
Definition: ncbistre.hpp:736
#define CT_NOT_EOF
Definition: ncbistre.hpp:733
#define CT_POS_TYPE
Definition: ncbistre.hpp:730
#define CT_CHAR_TYPE
Definition: ncbistre.hpp:729
IO_PREFIX::streambuf CNcbiStreambuf
Portable alias for streambuf.
Definition: ncbistre.hpp:143
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Error
Unrecoverable error, no retry possible.
@ eRW_Success
Everything is okay, I/O completed.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
Definition of all error codes used in corelib (xncbi.lib).
char * buf
yy_size_t n
NCBI C++ auxiliary debug macros.
Defines NCBI C++ exception handling.
T max(T x_, T y_)
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define memmove(a, b, c)
#define count
Reader-writer based streams.
#define RWSTREAMBUF_HANDLE_EXCEPTIONS(call, subcode, message, action)
Definition: rwstreambuf.cpp:44
static bool x_CheckRW(const void *rw)
static const streamsize kDefaultBufSize
static EOwnership x_IfToOwnWriter(const IReader *r, const IWriter *w, CRWStreambuf::TFlags f)
static EOwnership x_IfToOwnReader(const IReader *r, const IWriter *w, CRWStreambuf::TFlags f)
#define _ASSERT
else result
Definition: token2.c:20
Modified on Fri Sep 20 14:58:30 2024 by modify_doxy.py rev. 669887