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

Go to the SVN repository for this file.

1 /* $Id: rwstreambuf.cpp 89676 2020-04-15 15:10:29Z 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(pbase() <= pptr() && pptr() <= epptr());
289 
290  if ( !x_CheckRW(m_Writer.get()) )
291  return CT_EOF;
292 
293  size_t n_written;
294  size_t n_towrite = (size_t)(pptr() - pbase());
295 
297 
298  if ( n_towrite ) {
299  // Send a buffer
300  do {
301  n_written = 0;
303  m_Writer->Write(pbase(), n_towrite, &n_written),
304  5, "CRWStreambuf::overflow(): IWriter::Write()",
305  (n_written = 0, result = eRW_Error));
306  _ASSERT(n_written <= n_towrite);
307  if ( !n_written ) {
309  break;
310  }
311  // Update buffer content (get rid of the data just sent)
312  memmove(pbase(), pbase() + n_written, n_towrite - n_written);
313  x_PPos += (CT_OFF_TYPE) n_written;
314  pbump(-int(n_written));
315 
316  // Store a char
317  if ( !CT_EQ_INT_TYPE(c, CT_EOF) ) {
318  x_Err = false;
319  return sputc(CT_TO_CHAR_TYPE(c));
320  }
321  n_towrite -= n_written;
322  } while (n_towrite && result == eRW_Success);
323  if ( n_towrite ) {
325  x_Err = true;
326  x_ErrPos = x_GetPPos();
327  if (result == eRW_Error)
328  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
329  return CT_EOF;
330  }
331  } else if ( !CT_EQ_INT_TYPE(c, CT_EOF) ) {
332  // Send a char
334  n_written = 0;
336  m_Writer->Write(&b, 1, &n_written),
337  6, "CRWStreambuf::overflow(): IWriter::Write(1)",
338  (n_written = 0, result = eRW_Error));
339  _ASSERT(n_written <= 1);
340  if ( !n_written ) {
342  x_Err = true;
343  x_ErrPos = x_GetPPos();
344  if (result == eRW_Error)
345  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
346  return CT_EOF;
347  }
348  x_PPos += (CT_OFF_TYPE) 1;
349  x_Err = false;
350  return c;
351  }
352 
355  m_Writer->Flush(),
356  7, "CRWStreambuf::overflow(): IWriter::Flush()",
357  result = eRW_Error);
358  switch ( result ) {
359  case eRW_Eof:
360  case eRW_Error:
361  x_Err = true;
362  x_ErrPos = x_GetPPos();
363  if (result == eRW_Error)
364  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
365  return CT_EOF;
366  default:
367  break;
368  }
369  x_Err = false;
370  return CT_NOT_EOF(CT_EOF);
371 }
372 
373 
374 streamsize CRWStreambuf::xsputn(const CT_CHAR_TYPE* buf, streamsize m)
375 {
376  _ASSERT(pbase() <= pptr() && pptr() <= epptr());
377 
378  if (!x_CheckRW(m_Writer.get()) || m < 0)
379  return 0;
380 
382  size_t n = (size_t) m;
383  size_t n_written = 0;
384  size_t x_written;
385  x_Err = false;
386 
388 
389  do {
390  if ( pbase() ) {
391  if (n && pbase() + n < epptr()) {
392  // Would entirely fit into the buffer not causing an overflow
393  x_written = (size_t)(epptr() - pptr());
394  if (x_written > n)
395  x_written = n;
396  if ( x_written ) {
397  memcpy(pptr(), buf, x_written);
398  pbump(int(x_written));
399  n_written += x_written;
400  n -= x_written;
401  if ( !n )
402  return (streamsize) n_written;
403  buf += x_written;
404  }
405  }
406 
407  size_t x_towrite = (size_t)(pptr() - pbase());
408  if ( x_towrite ) {
409  x_written = 0;
411  m_Writer->Write(pbase(), x_towrite, &x_written),
412  8, "CRWStreambuf::xsputn(): IWriter::Write()",
413  (x_written = 0, result = eRW_Error));
414  _ASSERT(x_written <= x_towrite);
415  if ( !x_written ) {
417  x_Err = true;
418  x_ErrPos = x_GetPPos();
419  break;
420  }
421  memmove(pbase(), pbase() + x_written, x_towrite - x_written);
422  x_PPos += (CT_OFF_TYPE) x_written;
423  pbump(-int(x_written));
424  continue;
425  }
426  }
427 
428  x_written = 0;
430  m_Writer->Write(buf, n, &x_written),
431  9, "CRWStreambuf::xsputn(): IWriter::Write()",
432  (x_written = 0, result = eRW_Error));
433  _ASSERT(x_written <= n);
434  if (!x_written && n) {
436  x_Err = true;
437  x_ErrPos = x_GetPPos();
438  break;
439  }
440  x_PPos += (CT_OFF_TYPE) x_written;
441  n_written += x_written;
442  n -= x_written;
443  if ( !n )
444  return (streamsize) n_written;
445  buf += x_written;
446  } while (result == eRW_Success);
447 
448  _ASSERT(n && result != eRW_Success && x_Err);
449 
450  if ( pbase() ) {
451  x_written = (size_t)(epptr() - pptr());
452  if ( x_written ) {
453  if (x_written > n)
454  x_written = n;
455  memcpy(pptr(), buf, x_written);
456  n_written += x_written;
457  pbump(int(x_written));
458  }
459  }
460 
461  if (!n_written && result == eRW_Error)
462  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
463  return (streamsize) n_written;
464 }
465 
466 
468 {
469  _ASSERT(gptr() >= egptr());
470 
471  if ( !x_CheckRW(m_Reader.get()) )
472  return CT_EOF;
473 
474  // Flush output buffer, if tied up to it
475  if (!(m_Flags & fUntie) && x_Sync() != 0)
476  return CT_EOF;
477 
478  if (x_Eof)
479  return CT_EOF;
480 
481 #ifdef NCBI_COMPILER_MIPSPRO
482  if (m_MIPSPRO_ReadsomeGptrSetLevel && m_MIPSPRO_ReadsomeGptr != gptr())
483  return CT_EOF;
484  m_MIPSPRO_ReadsomeGptr = (CT_CHAR_TYPE*)(-1L);
485 #endif /*NCBI_COMPILER_MIPSPRO*/
486 
487  // Read from device
489  size_t n_read = 0;
492  m_Reader->Read(m_ReadBuf, m_BufSize, &n_read),
493  10, "CRWStreambuf::underflow(): IReader::Read()",
494  (n_read = 0, result = eRW_Error));
495  _ASSERT(n_read <= m_BufSize);
496  if ( !n_read ) {
498  switch ( result ) {
499  case eRW_Error:
500  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
501  break;
502  case eRW_Eof:
503  x_Eof = true;
504  break;
505  default:
506  break;
507  }
508  return CT_EOF;
509  }
510 
511  // Update input buffer with the data just read
512  x_GPos += (CT_OFF_TYPE) n_read;
513  setg(m_ReadBuf, m_ReadBuf, m_ReadBuf + n_read);
514 
515  return CT_TO_INT_TYPE(*m_ReadBuf);
516 }
517 
518 
519 streamsize CRWStreambuf::x_Read(CT_CHAR_TYPE* buf, streamsize m)
520 {
521  _ASSERT( m_Reader );
522 
523  // Flush output buffer, if tied up to it
524  if (!(m_Flags & fUntie) && x_Sync() != 0)
525  return 0;
526 
527  if (m < 0)
528  return 0;
529 
531  size_t n = (size_t) m;
532  size_t n_read;
533 
534  if ( n ) {
535  // First, read from the memory buffer
536  n_read = (size_t)(egptr() - gptr());
537  if (n_read > n)
538  n_read = n;
539  if (buf)
540  memcpy(buf, gptr(), n_read);
541  gbump(int(n_read));
542  n -= n_read;
543  if ( !n )
544  return (streamsize) n_read;
545  if (buf)
546  buf += n_read;
547  } else
548  n_read = 0;
549 
550  if ( x_Eof )
551  return (streamsize) n_read;
552 
554 
555  do {
556  // Next, read directly from the device
557  size_t x_toread = !buf || (n && n < m_BufSize) ? m_BufSize : n;
558  CT_CHAR_TYPE* x_buf = !buf || ( n < m_BufSize) ? m_ReadBuf : buf;
559  size_t x_read = 0;
560 
562  m_Reader->Read(x_buf, x_toread, &x_read),
563  11, "CRWStreambuf::xsgetn(): IReader::Read()",
564  (x_read = 0, result = eRW_Error));
565  _ASSERT(x_read <= x_toread);
566  if ( !x_read ) {
567  _ASSERT(!x_toread || result != eRW_Success);
568  break;
569  }
570  x_GPos += (CT_OFF_TYPE) x_read;
571  // Satisfy "usual backup condition", see standard: 27.5.2.4.3.13
572  if (x_buf == m_ReadBuf) {
573  size_t xx_read = x_read;
574  if (x_read > n)
575  x_read = n;
576  if (buf)
577  memcpy(buf, m_ReadBuf, x_read);
578  setg(m_ReadBuf, m_ReadBuf + x_read, m_ReadBuf + xx_read);
579  } else {
580  _ASSERT(x_read <= n);
581  size_t xx_read = x_read > m_BufSize ? m_BufSize : x_read;
582  memcpy(m_ReadBuf, buf + x_read - xx_read, xx_read);
583  setg(m_ReadBuf, m_ReadBuf + xx_read, m_ReadBuf + xx_read);
584  }
585  n_read += x_read;
586  if (result != eRW_Success)
587  break;
588  if (buf)
589  buf += x_read;
590  n -= x_read;
591  } while ( n );
592 
593  if (!n_read && result == eRW_Error)
594  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
595  else if (result == eRW_Eof)
596  x_Eof = true;
597 
598  return (streamsize) n_read;
599 }
600 
601 
602 streamsize CRWStreambuf::xsgetn(CT_CHAR_TYPE* buf, streamsize m)
603 {
604  _ASSERT(egptr() >= gptr());
605 
606  return x_CheckRW(m_Reader.get()) ? x_Read(buf, m) : 0;
607 }
608 
609 
610 streamsize CRWStreambuf::showmanyc(void)
611 {
612  _ASSERT(gptr() >= egptr());
613 
614  if ( !x_CheckRW(m_Reader.get()) )
615  return -1L;
616 
617  // Flush output buffer, if tied up to it
618  if (!(m_Flags & fUntie))
619  x_Sync();
620 
621  if ( x_Eof )
622  return 0;
623 
624  size_t count = 0;
627  m_Reader->PendingCount(&count),
628  12, "CRWStreambuf::showmanyc(): IReader::PendingCount()",
629  result = eRW_Error);
630  switch ( result ) {
631  case eRW_NotImplemented:
632  return 0;
633  case eRW_Success:
634  return count;
635  case eRW_Error:
636  THROW1_TRACE(IOS_BASE::failure, "eRW_Error");
637  default:
638  break;
639  }
640  return -1L;
641 }
642 
643 
645 {
647  return -1;
648  _ASSERT(pbase() == pptr());
649  return 0;
650 }
651 
652 
653 CT_POS_TYPE CRWStreambuf::seekoff(CT_OFF_TYPE off, IOS_BASE::seekdir whence,
654  IOS_BASE::openmode which)
655 {
656  if (whence == IOS_BASE::cur && off == 0) {
657  // tellg()/tellp() support
658  switch (which) {
659  case IOS_BASE::in:
660  return x_GetGPos();
661  case IOS_BASE::out:
662  return x_GetPPos();
663  default:
664  break;
665  }
666  } else if (which == IOS_BASE::in
667  && ((whence == IOS_BASE::cur && (off > 0)) ||
668  (whence == IOS_BASE::beg && (off -= x_GetGPos()) >= 0))){
669  if (m_Reader && x_Read(0, (streamsize) off) == (streamsize) off)
670  return x_GetGPos();
671  }
672  return (CT_POS_TYPE)((CT_OFF_TYPE)(-1L));
673 }
674 
675 
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
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_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define memmove(a, b, c)
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 Wed May 15 15:07:01 2024 by modify_doxy.py rev. 669887