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

Go to the SVN repository for this file.

1 #ifndef CORELIB___NCBISTRE__HPP
2 #define CORELIB___NCBISTRE__HPP
3 
4 /* $Id: ncbistre.hpp 99522 2023-04-12 16:41:34Z gouriano $
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: Denis Vakatov, Anton Lavrentiev
30  *
31  *
32  */
33 
34 /// @file ncbistre.hpp
35 /// NCBI C++ stream class wrappers for triggering between "new" and
36 /// "old" C++ stream libraries.
37 
38 
39 #include <corelib/ncbictype.hpp>
40 
41 /// Determine which iostream library to use, include appropriate
42 /// headers, and #define specific preprocessor variables.
43 /// The default is the new(template-based, std::) one.
44 
45 #if !defined(HAVE_IOSTREAM) && !defined(NCBI_USE_OLD_IOSTREAM)
46 # define NCBI_USE_OLD_IOSTREAM
47 #endif
48 
49 #if defined(HAVE_IOSTREAM_H) && defined(NCBI_USE_OLD_IOSTREAM)
50 # include <iostream.h>
51 # include <fstream.h>
52 # if defined(HAVE_STRSTREA_H)
53 # include <strstrea.h>
54 # else
55 # include <strstream.h>
56 # endif
57 # include <iomanip.h>
58 # define IO_PREFIX
59 # define IOS_BASE ::ios
60 # define IOS_PREFIX ::ios
61 # define PUBSYNC sync
62 # define PUBSEEKPOS seekpos
63 # define PUBSEEKOFF seekoff
64 
65 #elif defined(HAVE_IOSTREAM)
66 # if defined(NCBI_USE_OLD_IOSTREAM)
67 # undef NCBI_USE_OLD_IOSTREAM
68 # endif
69 # if defined(NCBI_COMPILER_GCC) || \
70  (defined(NCBI_COMPILER_ANY_CLANG) && defined(__GLIBCXX__))
71 // Don't bug us about including <strstream>.
72 # define _CPP_BACKWARD_BACKWARD_WARNING_H 1
73 # define _BACKWARD_BACKWARD_WARNING_H 1
74 # endif
75 # include <iostream>
76 # include <fstream>
77 # if defined(NCBI_COMPILER_ICC) && defined(__GNUC__) && !defined(__INTEL_CXXLIB_ICC)
78 # define _BACKWARD_BACKWARD_WARNING_H 1
79 # include <backward/strstream>
80 # else
81 #if 0
82 # include <strstream>
83 #else
84 #define NCBI_SHUN_OSTRSTREAM 1
85 #endif
86 # include <sstream>
87 # endif
88 # include <iomanip>
89 # define IO_PREFIX NCBI_NS_STD
90 # define IOS_BASE IO_PREFIX::ios_base
91 # define IOS_PREFIX IO_PREFIX::ios
92 
93 # ifdef NO_PUBSYNC
94 # define PUBSYNC sync
95 # define PUBSETBUF setbuf
96 # define PUBSEEKOFF seekoff
97 # define PUBSEEKPOS seekpos
98 # else
99 # define PUBSYNC pubsync
100 # define PUBSETBUF pubsetbuf
101 # define PUBSEEKOFF pubseekoff
102 # define PUBSEEKPOS pubseekpos
103 # endif
104 
105 # ifdef _LIBCPP_VERSION
106 # define NCBI_SHUN_OSTRSTREAM 1
107 # include <sstream>
108 # endif
109 
110 #else
111 # error "Neither <iostream> nor <iostream.h> can be found!"
112 #endif
113 
114 // Obsolete
115 #define SEEKOFF PUBSEEKOFF
116 
117 #include <stddef.h>
118 
119 
120 #define HTTP_EOL "\r\n"
121 
122 
123 // (BEGIN_NCBI_SCOPE must be followed by END_NCBI_SCOPE later in this file)
125 
126 /** @addtogroup Stream
127  *
128  * @{
129  */
130 
131 // I/O classes
132 
133 /// Portable alias for streampos.
134 typedef IO_PREFIX::streampos CNcbiStreampos;
135 
136 /// Portable alias for streamoff.
137 typedef IO_PREFIX::streamoff CNcbiStreamoff;
138 
139 /// Portable alias for ios.
140 typedef IO_PREFIX::ios CNcbiIos;
141 
142 /// Portable alias for streambuf.
143 typedef IO_PREFIX::streambuf CNcbiStreambuf;
144 
145 /// Portable alias for istream.
146 typedef IO_PREFIX::istream CNcbiIstream;
147 
148 /// Portable alias for ostream.
149 typedef IO_PREFIX::ostream CNcbiOstream;
150 
151 /// Portable alias for iostream.
152 typedef IO_PREFIX::iostream CNcbiIostream;
153 
154 
155 #ifndef NCBI_SHUN_OSTRSTREAM
156 
157 /// Portable alias for strstreambuf.
158 //typedef IO_PREFIX::strstreambuf CNcbiStrstreambuf;
159 
160 /// Portable alias for istrstream.
161 //typedef IO_PREFIX::istrstream CNcbiIstrstream;
162 
163 /// Portable alias for ostrstream.
164 //typedef IO_PREFIX::ostrstream CNcbiOstrstream;
165 
166 /// Portable alias for strstream.
167 //typedef IO_PREFIX::strstream CNcbiStrstream;
168 # define NCBI_STRSTREAM_INIT(p, l) (p), (l)
169 
170 class CNcbiIstrstream : public IO_PREFIX::istrstream
171 {
172 public:
173  typedef IO_PREFIX::istrstream _Mybase;
174 
175  explicit CNcbiIstrstream(const string& _Str)
176  : _Mybase(_Str.data(), _Str.size()) {
177  }
178 // [[deprecated("(const char*) constructor: review, maybe using string argument is better")]]
179  explicit CNcbiIstrstream(const char *_Ptr)
180  : _Mybase(_Ptr) {
181  }
182 
183  [[deprecated("(char*) constructor is deprecated, WILL BE REMOVED SOON")]]
184  explicit CNcbiIstrstream(char *_Ptr)
185  : _Mybase(_Ptr) {
186  }
187 #if !defined(NCBI_COMPILER_MSVC) || (NCBI_COMPILER_VERSION > 1916)
188  template<class T>
190 
192  [[deprecated("(char*, Tinteger) constructor is deprecated, WILL BE REMOVED SOON")]]
193  CNcbiIstrstream(char *_Ptr, TInteger _Count)
194  : _Mybase(_Ptr, _Count) {
195  }
197 // [[deprecated("(const char*, Tinteger) constructor is deprecated, consider using string argument instead")]]
198  CNcbiIstrstream(const char *_Ptr, TInteger _Count)
199  : _Mybase(_Ptr, _Count) {
200  }
201 #else
202  [[deprecated("(char*, streamsize) constructor is deprecated, WILL BE REMOVED SOON")]]
203  CNcbiIstrstream(char *_Ptr, streamsize _Count)
204  : _Mybase(_Ptr, (int)_Count) {
205  }
206  [[deprecated("(char*, size_t) constructor is deprecated, WILL BE REMOVED SOON")]]
207  CNcbiIstrstream(char *_Ptr, size_t _Count)
208  : _Mybase(_Ptr, (int)_Count) {
209  }
210  [[deprecated("(char*, int) constructor is deprecated, WILL BE REMOVED SOON")]]
211  CNcbiIstrstream(char *_Ptr, int _Count)
212  : _Mybase(_Ptr, _Count) {
213  }
214 // [[deprecated("(const char*, streamsize) constructor is deprecated, consider using string argument instead")]]
215  CNcbiIstrstream(const char *_Ptr, streamsize _Count)
216  : _Mybase(_Ptr, _Count) {
217  }
218 // [[deprecated("(const char*, size_t) constructor is deprecated, consider using string argument instead")]]
219  CNcbiIstrstream(const char *_Ptr, size_t _Count)
220  : _Mybase(_Ptr, _Count) {
221  }
222 // [[deprecated("(const char*, int) constructor is deprecated, consider using string argument instead")]]
223  CNcbiIstrstream(const char *_Ptr, int _Count)
224  : _Mybase(_Ptr, _Count) {
225  }
226 #endif
227 
228 #if 0
230  : _Mybase(std::move(_Right)) {
231  }
232  CNcbiIstrstream& operator=(CNcbiIstrstream&& _Right) {
233  _Mybase::operator=(std::move(_Right));
234  return (*this);
235  }
236 #endif
237 };
238 
239 template<typename _Base, IOS_BASE::openmode _DefMode>
240 class CNcbistrstream_Base : public _Base
241 {
242 public:
243  typedef _Base _Mybase;
245  : _Mybase() {
246  }
247 #if 0
248  CNcbistrstream_Base(const string& _Str, IOS_BASE::openmode _Mode = _DefMode)
249  : _Mybase( const_cast<char*>(_Str.data()), _Str.size(), _Mode) {
250  }
251 #endif
252 #if !defined(NCBI_COMPILER_MSVC) || (NCBI_COMPILER_VERSION > 1916)
253  template<class T>
255 
257  [[deprecated("(char*, Tinteger, ios::openmode) constructor is deprecated, WILL BE REMOVED SOON")]]
258  CNcbistrstream_Base(char *_Ptr, TInteger _Count, IOS_BASE::openmode _Mode = _DefMode)
259  : _Mybase(_Ptr, _Count, _Mode) {
260  }
261 #else
262  [[deprecated("(char*, streamsize, ios::openmode) constructor is deprecated, WILL BE REMOVED SOON")]]
263  CNcbistrstream_Base(char *_Ptr, streamsize _Count, IOS_BASE::openmode _Mode = _DefMode)
264  : _Mybase(_Ptr, _Count, _Mode) {
265  }
266  [[deprecated("(char*, size_t, ios::openmode) constructor is deprecated, WILL BE REMOVED SOON")]]
267  CNcbistrstream_Base(char *_Ptr, size_t _Count, IOS_BASE::openmode _Mode = _DefMode)
268  : _Mybase(_Ptr, _Count, _Mode) {
269  }
270  [[deprecated("(char*, int, ios::openmode) constructor is deprecated, WILL BE REMOVED SOON")]]
271  CNcbistrstream_Base(char *_Ptr, int _Count, IOS_BASE::openmode _Mode = _DefMode)
272  : _Mybase(_Ptr, _Count, _Mode) {
273  }
274 #endif
275 
276 #if 0
278  : _Mybase(std::move(_Right)) {
279  }
280  CNcbistrstream_Base& operator=(CNcbistrstream_Base&& _Right) {
281  _Mybase::operator=(std::move(_Right));
282  return (*this);
283  }
284 #endif
285 };
288 #if defined(NCBI_COMPILER_MSVC)
291 #endif
292 
293 #else // NCBI_SHUN_OSTRSTREAM
294 
295 #if 1
296 //typedef IO_PREFIX::stringbuf CNcbiStrstreambuf;
297 typedef IO_PREFIX::istringstream CNcbiIstrstream;
298 typedef IO_PREFIX::ostringstream CNcbiOstrstream;
299 typedef IO_PREFIX::stringstream CNcbiStrstream;
300 # define NCBI_STRSTREAM_INIT(p, l) string(p, l)
301 #else
302 # define NCBI_STRSTREAM_INIT(p, l) (p), (l)
303 template<typename _Base, IOS_BASE::openmode _DefMode>
304 class CNcbistrstream_Base : public _Base
305 {
306 public:
307  typedef _Base _Mybase;
308  explicit CNcbistrstream_Base(IOS_BASE::openmode _Mode = _DefMode)
309  : _Mybase(_Mode) {
310  }
311  explicit CNcbistrstream_Base(const string& _Str, IOS_BASE::openmode _Mode = _DefMode)
312  : _Mybase(_Str, _Mode) {
313  }
314 
315 #if !defined(NCBI_COMPILER_MSVC) || (NCBI_COMPILER_VERSION > 1916)
316  template<class T>
317  using enable_if_integral = typename std::enable_if<std::is_integral<T>::value>;
318 
319 #if 0
321  [[deprecated("(const char*, Tinteger, ios::openmode) constructor is deprecated, use string argument instead")]]
322  CNcbistrstream_Base(const char *_Ptr, TInteger _Count, IOS_BASE::openmode _Mode = _DefMode)
323  : _Mybase(string(_Ptr, _Count), _Mode) {
324  }
325 #else
327  CNcbistrstream_Base(const char *_Ptr, TInteger _Count, IOS_BASE::openmode _Mode = _DefMode) = delete;
328 #endif
329 #else
330  [[deprecated("(const char*, streamsize, ios::openmode) constructor is deprecated, use string argument instead")]]
331  CNcbistrstream_Base(const char* s, streamsize n, IOS_BASE::openmode _Mode = _DefMode)
332  : _Mybase(string(s,n), _Mode) {
333  }
334  [[deprecated("(const char*, size_t, ios::openmode) constructor is deprecated, use string argument instead")]]
335  CNcbistrstream_Base(const char* s, size_t n, IOS_BASE::openmode _Mode = _DefMode)
336  : _Mybase(string(s,n), _Mode) {
337  }
338  [[deprecated("(const char*, int, ios::openmode) constructor is deprecated, use string argument instead")]]
339  CNcbistrstream_Base(const char* s, int n, IOS_BASE::openmode _Mode = _DefMode)
340  : _Mybase(string(s,n), _Mode) {
341  }
342 #endif
343 
344  template< typename TInteger>
345  CNcbistrstream_Base(char* s, TInteger n) = delete;
346  template< typename TInteger>
347  CNcbistrstream_Base(char* s, TInteger n, IOS_BASE::openmode _Mode) = delete;
348 
349 #if 0
351  : _Mybase(std::move(_Right)) {
352  }
353  CNcbistrstream_Base& operator=(CNcbistrstream_Base&& _Right) {
354  _Mybase::operator=(std::move(_Right));
355  return (*this);
356  }
357 #endif
358 };
362 #if defined(NCBI_COMPILER_MSVC) && (!defined(NCBI_DLL_BUILD) || defined(NCBI_CORE_EXPORTS))
366 #endif
367 #endif
368 
369 #endif // NCBI_SHUN_OSTRSTREAM
370 
371 
372 /// Portable alias for filebuf.
373 typedef IO_PREFIX::filebuf CNcbiFilebuf;
374 
375 
376 #if defined(NCBI_OS_MSWIN) && defined(_UNICODE)
377 // this is helper method for fstream classes only
378 // do not use it elsewhere
380 wstring ncbi_Utf8ToWstring(const char *utf8);
381 
382 class CNcbiIfstream : public IO_PREFIX::ifstream
383 {
384 public:
385  CNcbiIfstream( ) {
386  }
387  explicit CNcbiIfstream(
388  const char *_Filename,
389  IOS_BASE::openmode _Mode = IOS_BASE::in,
390  int _Prot = (int)IOS_BASE::_Openprot
391  ) : IO_PREFIX::ifstream(
392  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot) {
393  }
394  explicit CNcbiIfstream(
395  const string& _Filename,
396  IOS_BASE::openmode _Mode = IOS_BASE::in,
397  int _Prot = (int)IOS_BASE::_Openprot
398  ) : CNcbiIfstream(_Filename.c_str(), _Mode, _Prot) {
399  }
400  explicit CNcbiIfstream(
401  const wchar_t *_Filename,
402  IOS_BASE::openmode _Mode = IOS_BASE::in,
403  int _Prot = (int)IOS_BASE::_Openprot
404  ) : IO_PREFIX::ifstream(_Filename,_Mode,_Prot) {
405  }
406  explicit CNcbiIfstream(
407  const wstring& _Filename,
408  IOS_BASE::openmode _Mode = IOS_BASE::in,
409  int _Prot = (int)IOS_BASE::_Openprot
410  ) : CNcbiIfstream(_Filename.c_str(),_Mode,_Prot) {
411  }
412 
413  void open(
414  const char *_Filename,
415  IOS_BASE::openmode _Mode = IOS_BASE::in,
416  int _Prot = (int)IOS_BASE::_Openprot) {
417  IO_PREFIX::ifstream::open(
418  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot);
419  }
420  void open(
421  const string& _Filename,
422  IOS_BASE::openmode _Mode = IOS_BASE::in,
423  int _Prot = (int)IOS_BASE::_Openprot) {
424  CNcbiIfstream::open(_Filename.c_str(), _Mode, _Prot);
425  }
426  void open(const wchar_t *_Filename,
427  IOS_BASE::openmode _Mode = IOS_BASE::in,
428  int _Prot = (int)ios_base::_Openprot) {
429  IO_PREFIX::ifstream::open(_Filename,_Mode,_Prot);
430  }
431  void open(const wstring& _Filename,
432  IOS_BASE::openmode _Mode = IOS_BASE::in,
433  int _Prot = (int)ios_base::_Openprot) {
434  CNcbiIfstream::open(_Filename.c_str(), _Mode, _Prot);
435  }
436 };
437 #else
438 /// Portable alias for ifstream.
439 typedef IO_PREFIX::ifstream CNcbiIfstream;
440 #endif
441 
442 #if defined(NCBI_OS_MSWIN) && defined(_UNICODE)
443 class CNcbiOfstream : public IO_PREFIX::ofstream
444 {
445 public:
446  CNcbiOfstream( ) {
447  }
448  explicit CNcbiOfstream(
449  const char *_Filename,
450  IOS_BASE::openmode _Mode = IOS_BASE::out,
451  int _Prot = (int)IOS_BASE::_Openprot
452  ) : IO_PREFIX::ofstream(
453  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot) {
454  }
455  explicit CNcbiOfstream(
456  const string& _Filename,
457  IOS_BASE::openmode _Mode = IOS_BASE::out,
458  int _Prot = (int)IOS_BASE::_Openprot
459  ) : CNcbiOfstream(_Filename.c_str(), _Mode, _Prot) {
460  }
461  explicit CNcbiOfstream(
462  const wchar_t *_Filename,
463  IOS_BASE::openmode _Mode = IOS_BASE::out,
464  int _Prot = (int)IOS_BASE::_Openprot
465  ) : IO_PREFIX::ofstream(_Filename,_Mode,_Prot) {
466  }
467  explicit CNcbiOfstream(
468  const wstring& _Filename,
469  IOS_BASE::openmode _Mode = IOS_BASE::out,
470  int _Prot = (int)IOS_BASE::_Openprot
471  ) : CNcbiOfstream(_Filename.c_str(),_Mode,_Prot) {
472  }
473 
474  void open(
475  const char *_Filename,
476  IOS_BASE::openmode _Mode = IOS_BASE::out,
477  int _Prot = (int)IOS_BASE::_Openprot) {
478  IO_PREFIX::ofstream::open(
479  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot);
480  }
481  void open(
482  const string& _Filename,
483  IOS_BASE::openmode _Mode = IOS_BASE::out,
484  int _Prot = (int)IOS_BASE::_Openprot) {
485  CNcbiOfstream::open(_Filename.c_str(), _Mode, _Prot);
486  }
487  void open(const wchar_t *_Filename,
488  IOS_BASE::openmode _Mode = IOS_BASE::out,
489  int _Prot = (int)IOS_BASE::_Openprot) {
490  IO_PREFIX::ofstream::open(_Filename,_Mode,_Prot);
491  }
492  void open(const wstring& _Filename,
493  IOS_BASE::openmode _Mode = IOS_BASE::out,
494  int _Prot = (int)IOS_BASE::_Openprot) {
495  CNcbiOfstream::open(_Filename.c_str(), _Mode, _Prot);
496  }
497 };
498 #else
499 /// Portable alias for ofstream.
500 typedef IO_PREFIX::ofstream CNcbiOfstream;
501 #endif
502 
503 #if defined(NCBI_OS_MSWIN) && defined(_UNICODE)
504 class CNcbiFstream : public IO_PREFIX::fstream
505 {
506 public:
507  CNcbiFstream( ) {
508  }
509  explicit CNcbiFstream(
510  const char *_Filename,
511  IOS_BASE::openmode _Mode = IOS_BASE::in | IOS_BASE::out,
512  int _Prot = (int)IOS_BASE::_Openprot
513  ) : IO_PREFIX::fstream(
514  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot) {
515  }
516  explicit CNcbiFstream(
517  const wchar_t *_Filename,
518  IOS_BASE::openmode _Mode = IOS_BASE::in | IOS_BASE::out,
519  int _Prot = (int)IOS_BASE::_Openprot
520  ) : IO_PREFIX::fstream(_Filename,_Mode,_Prot) {
521  }
522 
523  void open(
524  const char *_Filename,
525  IOS_BASE::openmode _Mode = IOS_BASE::in | IOS_BASE::out,
526  int _Prot = (int)IOS_BASE::_Openprot) {
527  IO_PREFIX::fstream::open(
528  ncbi_Utf8ToWstring(_Filename).c_str(), _Mode, _Prot);
529  }
530  void open(const wchar_t *_Filename,
531  IOS_BASE::openmode _Mode = IOS_BASE::in | IOS_BASE::out,
532  int _Prot = (int)ios_base::_Openprot) {
533  IO_PREFIX::fstream::open(_Filename,_Mode,_Prot);
534  }
535 };
536 #else
537 /// Portable alias for fstream.
538 typedef IO_PREFIX::fstream CNcbiFstream;
539 #endif
540 
541 // Standard I/O streams
542 #define NcbiCin IO_PREFIX::cin
543 #define NcbiCout IO_PREFIX::cout
544 #define NcbiCerr IO_PREFIX::cerr
545 #define NcbiClog IO_PREFIX::clog
546 
547 // I/O manipulators (the list may be incomplete)
548 #define NcbiEndl IO_PREFIX::endl
549 #define NcbiEnds IO_PREFIX::ends
550 #define NcbiFlush IO_PREFIX::flush
551 
552 #define NcbiDec IO_PREFIX::dec
553 #define NcbiHex IO_PREFIX::hex
554 #define NcbiOct IO_PREFIX::oct
555 #define NcbiWs IO_PREFIX::ws
556 
557 #define NcbiFixed IO_PREFIX::fixed
558 #define NcbiScientific IO_PREFIX::scientific
559 
560 #define NcbiSetbase IO_PREFIX::setbase
561 #define NcbiResetiosflags IO_PREFIX::resetiosflags
562 #define NcbiSetiosflags IO_PREFIX::setiosflags
563 #define NcbiSetfill IO_PREFIX::setfill
564 #define NcbiSetprecision IO_PREFIX::setprecision
565 #define NcbiSetw IO_PREFIX::setw
566 
567 // I/O state
568 #define NcbiGoodbit IOS_PREFIX::goodbit
569 #define NcbiEofbit IOS_PREFIX::eofbit
570 #define NcbiFailbit IOS_PREFIX::failbit
571 #define NcbiBadbit IOS_PREFIX::badbit
572 #define NcbiHardfail IOS_PREFIX::hardfail
573 
574 
575 /// Platform-specific EndOfLine
577 extern const char* Endl(void);
578 
579 /// Read from "is" to "str" up to the delimiter symbol "delim" (or EOF)
581 extern CNcbiIstream& NcbiGetline(CNcbiIstream& is, string& str, char delim,
582  string::size_type* count = NULL);
583 
584 /// Read from "is" to "str" up to any symbol contained within "delims" (or EOF)
585 /// @note
586 /// Special case -- if two different delimiters are back to back and in the
587 /// same order as in delims, treat them as a single delimiter. E.g. "\r\n"
588 /// will handle mixed DOS/MAC/UNIX line endings such as "\r", "\n" and "\r\n".
591  const string& delims,
592  string::size_type* count = NULL);
593 
594 /// Read from "is" to "str" the next line
595 /// (taking into account platform specifics of End-of-Line)
598  string::size_type* count = NULL);
599 
600 
601 /// Copy the entire contents of stream "is" to stream "os".
602 /// @return
603 /// "true" if the operation was successful, i.e. "is" had been read entirely
604 /// with all of its _available_ contents (including none) written to "os";
605 /// "false" if either extraction from "is" or insertion into "os" failed.
606 ///
607 /// The call may throw exceptions only if they are enabled on the respective
608 /// stream(s).
609 ///
610 /// @note The call is an extension to the standard
611 /// ostream& ostream::operator<<(streambuf*),
612 /// which severely lacks error checking (esp. for partial write failures).
613 ///
614 /// @note Input ("is") stream state is not always asserted accurately: in
615 /// particular, upon successful completion "is.eof()" may not necessarily be
616 /// true; or, in case of fatal read errors "is" may not have its "is.bad()"
617 /// state set (however, the return code should still be "false" to properly
618 /// indicate the copy failure in this case).
619 ///
620 /// @attention This call (as well as the mentioned STL counterpart) provides
621 /// only the mechanism of delivering data to the destination stream(buf) "os";
622 /// and a successful return result does not generally guarantee that the data
623 /// have yet reached the physical destination. Other "os"-specific API must be
624 /// performed to assure the data integrity at the receiving device: such as
625 /// checking for errors after doing a "close()" (if "os" is an ofstream, for
626 /// example). For instance, uploading into the Toolkit FTP stream must be
627 /// finalized with a read for the byte count delivered; otherwise, it may not
628 /// work correctly.
629 /// @sa
630 /// CConn_IOStream, NcbiStreamCopyStart, NcbiStreamCopyThrow
632 extern bool NcbiStreamCopy(CNcbiOstream& os, CNcbiIstream& is);
633 
634 
635 /// Same as NcbiStreamCopy() but throws an CCoreException when copy fails.
636 /// @sa
637 /// NcbiStreamCopy, NcbiStreamCopyHead, CCoreException
639 extern void NcbiStreamCopyThrow(CNcbiOstream& os, CNcbiIstream& is);
640 
641 
642 /// Similar to NcbiStreamCopyThrow() but copies (and consumes) only the
643 /// specified number of bytes (and bypasses operator<< altogether). In
644 /// the event of write failure, the number of bytes consumed may fall
645 /// anywhere between the number of bytes written and the target count,
646 /// inclusive. If the input stream has less data than requested, copies
647 /// what it can, sets that stream's eof and fail flags, and returns
648 /// normally; if anything else goes wrong, throws an exception in
649 /// addition to setting appropriate flags (and copying what it can).
650 /// @sa
651 /// NcbiStreamCopy, NcbiStreamCopyThrow, CCoreException
654  string::size_type count);
655 
656 
657 /// Input the entire contents of an istream into a string (NULL causes drain).
658 /// "is" gets its failbit set if nothing was extracted from it; and gets its
659 /// eofbit (w/o failbit) set if the stream has reached an EOF condition.
660 ///
661 /// @param pos
662 /// Where in "*s" to begin saving data (ignored when "s" == NULL).
663 /// @return
664 /// Size of copied data if the operation was successful (i.e. "is" had
665 /// reached EOF), 0 otherwise.
666 /// @note
667 /// If "s" != NULL, then "s->size() >= pos" always upon return.
668 /// @sa
669 /// NcbiStreamCopy
671 extern size_t NcbiStreamToString(string* s, CNcbiIstream& is, size_t pos = 0);
672 
673 
674 /// Compare stream contents in binary form.
675 ///
676 /// @param is1
677 /// First stream to compare.
678 /// @param is2
679 /// Second stream to compare.
680 /// @return
681 /// TRUE if streams content is equal; FALSE otherwise.
683 extern bool NcbiStreamCompare(CNcbiIstream& is1, CNcbiIstream& is2);
684 
685 /// Mode to compare streams in text form.
687  /// Skip end-of-line characters ('\r' and '\n')
689  ///< Skip white spaces (in terms of isspace(), including end-of-line)
691 };
692 
693 /// Compare stream contents in text form.
694 ///
695 /// @param is1
696 /// First stream to compare.
697 /// @param is2
698 /// Second stream to compare.
699 /// @param mode
700 /// Type of white space characters to ignore.
701 /// @param buf_size
702 /// Size of buffer to read stream.
703 /// Zero value means using default buffer size.
704 /// @return
705 /// TRUE if streams content is equal; FALSE otherwise.
707 extern bool NcbiStreamCompareText(CNcbiIstream& is1, CNcbiIstream& is2,
708  ECompareTextMode mode, size_t buf_size = 0);
709 
710 /// Compare stream content with string in text form.
711 ///
712 /// @param is
713 /// Stream to compare.
714 /// @param str
715 /// String to compare.
716 /// @param mode
717 /// Type of white space characters to ignore.
718 /// @param buf_size
719 /// Size of buffer to read stream.
720 /// Zero value means using default buffer size.
721 /// @return
722 /// TRUE if stream and string content is equal; FALSE otherwise.
724 extern bool NcbiStreamCompareText(CNcbiIstream& is, const string& str,
725  ECompareTextMode mode, size_t buf_size = 0);
726 
727 
728 # define CT_INT_TYPE NCBI_NS_STD::char_traits<char>::int_type
729 # define CT_CHAR_TYPE NCBI_NS_STD::char_traits<char>::char_type
730 # define CT_POS_TYPE NCBI_NS_STD::char_traits<char>::pos_type
731 # define CT_OFF_TYPE NCBI_NS_STD::char_traits<char>::off_type
732 # define CT_EOF NCBI_NS_STD::char_traits<char>::eof()
733 # define CT_NOT_EOF NCBI_NS_STD::char_traits<char>::not_eof
734 # define CT_TO_INT_TYPE NCBI_NS_STD::char_traits<char>::to_int_type
735 # define CT_TO_CHAR_TYPE NCBI_NS_STD::char_traits<char>::to_char_type
736 # define CT_EQ_INT_TYPE NCBI_NS_STD::char_traits<char>::eq_int_type
737 
738 
739 #ifdef NCBI_COMPILER_MIPSPRO
740 /// Special workaround for MIPSPro 1-byte look-ahead issues
741 class CMIPSPRO_ReadsomeTolerantStreambuf : public CNcbiStreambuf
742 {
743 public:
744  /// NB: Do not use these two ugly, weird, ad-hoc methods, ever!!!
745  void MIPSPRO_ReadsomeBegin(void)
746  {
747  if (!m_MIPSPRO_ReadsomeGptrSetLevel++)
748  m_MIPSPRO_ReadsomeGptr = gptr();
749  }
750  void MIPSPRO_ReadsomeEnd (void)
751  {
752  --m_MIPSPRO_ReadsomeGptrSetLevel;
753  }
754 protected:
755  CMIPSPRO_ReadsomeTolerantStreambuf() : m_MIPSPRO_ReadsomeGptrSetLevel(0) {}
756 
757  const CT_CHAR_TYPE* m_MIPSPRO_ReadsomeGptr;
758  unsigned int m_MIPSPRO_ReadsomeGptrSetLevel;
759 };
760 #endif // NCBI_COMPILER_MIPSPRO
761 
762 
763 /// Convert stream position to 64-bit int
764 ///
765 /// On most systems stream position is a structure,
766 /// this function converts it to plain numeric value.
767 ///
768 /// @sa NcbiInt8ToStreampos
769 ///
770 inline
772 {
773  return (CT_OFF_TYPE)(stream_pos - (CT_POS_TYPE)((CT_OFF_TYPE)0));
774 }
775 
776 
777 /// Convert plain numeric stream position (offset) into
778 /// stream position usable with STL stream library.
779 ///
780 /// @sa NcbiStreamposToInt8
781 inline
783 {
784  return (CT_POS_TYPE)((CT_OFF_TYPE) 0) + (CT_OFF_TYPE)(pos);
785 }
786 
787 
788 /// CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string
789 /// Sample usage:
790 /*
791 string GetString(void)
792 {
793  CNcbiOstrstream out;
794  out << "some text";
795  return CNcbiOstrstreamToString(out);
796 }
797 */
798 /// Note: there is no need to terminate with '\0' char ("ends");
799 /// there is no need to explicitly "unfreeze" the "out" stream.
800 
802 {
805 public:
807  : m_Out(out)
808  {
809  }
810  operator string(void) const;
811 private:
813 
815 };
816 
819 
820 inline
822 {
823 #ifdef NCBI_SHUN_OSTRSTREAM
824  return NcbiStreamposToInt8(oss.tellp());
825 #else
826  return oss.pcount();
827 #endif
828 }
829 
830 inline
832 {
833  return GetOssSize(oss) == 0;
834 }
835 
836 /// Utility class for automatic conversion of strings to all uppercase letters.
837 /// Sample usage:
838 /// out << "Original: \"" << str << '"' << endl;
839 /// out << "Uppercase: \"" << Upcase(str) << '"' << endl;
840 
842 {
843 public:
844  explicit CUpcaseStringConverter(const string& s) : m_String(s) { }
845  const string& m_String;
846 };
847 
849 {
850 public:
851  explicit CUpcaseCharPtrConverter(const char* s) : m_String(s) { }
852  const char* m_String;
853 };
854 
855 
856 /// Utility class for automatic conversion of strings to all lowercase letters.
857 /// Sample usage:
858 /// out << "Original: \"" << str << '"' << endl;
859 /// out << "Lowercase: \"" << Locase(str) << '"' << endl;
860 
862 {
863 public:
864  explicit CLocaseStringConverter(const string& s) : m_String(s) { }
865  const string& m_String;
866 };
867 
869 {
870 public:
871  explicit CLocaseCharPtrConverter(const char* s) : m_String(s) { }
872  const char* m_String;
873 };
874 
875 
876 /// Utility class for automatic conversion of strings (that may contain
877 /// non-graphical characters) to a safe "printable" form.
878 /// The safe printable form utilizes '\'-quoted special sequences, as well
879 /// as either contracted or full 3-digit octal representation of non-printable
880 /// characters, always making sure there is no ambiguity in the string
881 /// interpretation (so that if the printed form is used back in a C program,
882 /// it will be equivalent to the original string).
883 /// Sample usage:
884 /// out << "Printable: \"" << Printable(str) << '"' << endl;
885 
887 {
888 public:
889  explicit CPrintableStringConverter(const string& s) : m_String(s) { }
890  const string& m_String;
891 };
892 
894 {
895 public:
896  explicit CPrintableCharPtrConverter(const char* s) : m_String(s) { }
897  const char* m_String;
898 };
899 
900 
901 /* @} */
902 
903 
904 /// Convert one single character to a "printable" form.
905 /// A "printable" form is one of well-known C-style backslash-quoted sequences
906 /// ('\0', '\a', '\b', '\f', '\n', '\r', '\t', '\v', '\\', '\'', '\"'),
907 /// or '\xXX' for other non-printable characters (per isprint()), or a
908 /// graphical representation of 'c' as an ASCII character.
909 /// @note *DO NOT USE* to convert strings! Because of the '\xXX' notation,
910 /// such conversions can result in ambiguity (e.g. "\xAAA" is a valid
911 /// _single_-character string per the standard).
913 NCBI_XNCBI_EXPORT extern string Printable(char c);
914 
915 
916 inline
917 char Upcase(char c)
918 {
919  return static_cast<char>(toupper((unsigned char) c));
920 }
921 
922 inline
924 {
925  return CUpcaseStringConverter(s);
926 }
927 
928 inline
930 {
931  return CUpcaseCharPtrConverter(s);
932 }
933 
934 inline
935 char Locase(char c)
936 {
937  return static_cast<char>(tolower((unsigned char) c));
938 }
939 
940 inline
942 {
943  return CLocaseStringConverter(s);
944 }
945 
946 inline
948 {
949  return CLocaseCharPtrConverter(s);
950 }
951 
952 inline
954 {
955  return CPrintableStringConverter(s);
956 }
957 
958 inline
960 {
961  return CPrintableCharPtrConverter(s);
962 }
963 
966 
969 
972 
975 
978 
981 
982 
983 /////////////////////////////////////////////////////////////////////////////
984 ///
985 /// Helper functions to read plain-text data streams.
986 /// It understands Byte Order Mark (BOM) and converts the input if needed.
987 ///
988 /// See clause 13.6 in
989 /// http://www.unicode.org/unicode/uni2book/ch13.pdf
990 /// and also
991 /// http://unicode.org/faq/utf_bom.html#BOM
992 ///
993 /// @sa ReadIntoUtf8, GetTextEncodingForm
995  /// Stream has no BOM.
997  /// Stream has no BOM.
999  /// Stream has no BOM.
1001  /// Stream has UTF8 BOM.
1003  /// Stream has UTF16 BOM. Byte order is native for this OS
1005  /// Stream has UTF16 BOM. Byte order is nonnative for this OS
1007 };
1008 
1009 
1010 /// How to read the text if the encoding form is not known (i.e. passed
1011 /// "eEncodingForm_Unknown" and the stream does not have BOM too)
1012 ///
1013 /// @sa ReadIntoUtf8
1015  /// Read the text "as is" (raw octal data). The read data can then
1016  /// be accessed using the regular std::string API (rather than the
1017  /// CStringUTF8 one).
1019 
1020  /// Try to guess the text's encoding form.
1021  ///
1022  /// @note
1023  /// In this case the encoding is a guesswork, which is not necessarily
1024  /// correct. If the guess is wrong then the data may be distorted on
1025  /// read. Use CStringUTF8::IsValid() to verify that guess. If it
1026  /// does not verify, then the read data can be accessed using the
1027  /// regular std::string API (rather than the CStringUTF8 one).
1029 };
1030 
1031 
1032 /// Read all input data from stream and try convert it into UTF8 string.
1033 ///
1034 /// @param input
1035 /// Input text stream
1036 /// @param result
1037 /// UTF8 string (but it can be a raw octet string if the encoding is unknown)
1038 /// @param what_if_no_bom
1039 /// What to do if the 'encoding_form' is passed "eEncodingForm_Unknown" and
1040 /// the BOM is not detected in the stream
1041 /// @return
1042 /// The encoding as detected based on the BOM
1043 /// ("eEncodingForm_Unknown" if there was no BOM).
1048  EEncodingForm encoding_form = eEncodingForm_Unknown,
1049  EReadUnknownNoBOM what_if_no_bom = eNoBOM_GuessEncoding
1050 );
1051 
1052 
1053 /// Whether to discard BOM or to keep it in the input stream
1054 ///
1055 /// @sa GetTextEncodingForm
1057  eBOM_Discard, ///< Discard the read BOM bytes
1058  eBOM_Keep ///< Push the read BOM bytes back into the input stream
1059 };
1060 
1061 
1062 /// Detect if the stream has BOM.
1063 ///
1064 /// @param input
1065 /// Input stream
1066 /// @param discard_bom
1067 /// Whether to discard the read BOM bytes or to push them back to the stream
1068 ///
1069 /// NOTE: If the function needs to push back more than one char then it uses
1070 /// CStreamUtils::Pushback().
1071 /// @sa CStreamUtils::Pushback()
1074 
1075 
1076 /// Byte Order Mark helper class to use in serialization
1077 ///
1078 /// @sa GetTextEncodingForm
1080 {
1081 public:
1083  : m_EncodingForm(eEncodingForm_Unknown) {
1084  }
1085 
1087  : m_EncodingForm(encodingForm) {
1088  }
1089 
1091  return m_EncodingForm;
1092  }
1093  void SetEncodingForm(EEncodingForm encodingForm) {
1094  m_EncodingForm = encodingForm;
1095  }
1096 private:
1098 };
1099 
1100 
1101 /// Write Byte Order Mark into output stream
1103 
1104 
1105 /// Read Byte Order Mark, if present, from input stream
1106 ///
1107 /// @note
1108 /// If BOM is found, stream position advances,
1109 /// otherwise, stream position remains unchanged
1110 ///
1111 /// @sa GetTextEncodingForm
1112 inline
1115  return str;
1116 }
1117 
1118 #include <corelib/ncbi_base64.h>
1119 
1120 
1122 
1123 
1124 // Provide formatted I/O of standard C++ "string" by "old-fashioned" IOSTREAMs
1125 // NOTE: these must have been inside the _NCBI_SCOPE and without the
1126 // "ncbi::" and "std::" prefixes, but there is some bug in SunPro 5.0...
1127 #if defined(NCBI_USE_OLD_IOSTREAM)
1132 #endif // NCBI_USE_OLD_IOSTREAM
1133 
1134 
1135 #endif /* NCBISTRE__HPP */
Byte Order Mark helper class to use in serialization.
Definition: ncbistre.hpp:1080
Utility class for automatic conversion of strings to all lowercase letters.
Definition: ncbistre.hpp:862
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
Utility class for automatic conversion of strings (that may contain non-graphical characters) to a sa...
Definition: ncbistre.hpp:887
Utility class for automatic conversion of strings to all uppercase letters.
Definition: ncbistre.hpp:842
std::ofstream out("events_result.xml")
main entry point for tests
static int type
Definition: getdata.c:31
static const char * str(char *buf, int n)
Definition: stats.c:84
char data[12]
Definition: iconv.c:80
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_DEPRECATED
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
std::string CStringUTF8
Definition: ncbistl.hpp:254
void NcbiStreamCopyThrow(CNcbiOstream &os, CNcbiIstream &is)
Same as NcbiStreamCopy() but throws an CCoreException when copy fails.
Definition: ncbistre.cpp:225
char Locase(char c)
Definition: ncbistre.hpp:935
CNcbiIstrstream(const char *_Ptr)
Definition: ncbistre.hpp:179
CNcbiIstream & NcbiGetlineEOL(CNcbiIstream &is, string &str, string::size_type *count=NULL)
Read from "is" to "str" the next line (taking into account platform specifics of End-of-Line)
#define CT_OFF_TYPE
Definition: ncbistre.hpp:731
Int8 NcbiStreamposToInt8(NCBI_NS_STD::char_traits< char >::pos_type stream_pos)
Convert stream position to 64-bit int.
Definition: ncbistre.hpp:771
void NcbiStreamCopyHead(CNcbiOstream &os, CNcbiIstream &is, string::size_type count)
Similar to NcbiStreamCopyThrow() but copies (and consumes) only the specified number of bytes (and by...
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
bool IsOssEmpty(CNcbiOstrstream &oss)
Definition: ncbistre.hpp:831
EEncodingForm
Helper functions to read plain-text data streams.
Definition: ncbistre.hpp:994
CNcbiOstream & operator<<(CNcbiOstream &out, const CNcbiOstrstreamToString &s)
Definition: ncbistre.cpp:443
string Printable(char c)
Convert one single character to a "printable" form.
Definition: ncbistre.cpp:505
EEncodingForm GetTextEncodingForm(CNcbiIstream &input, EBOMDiscard discard_bom)
Detect if the stream has BOM.
Definition: ncbistre.cpp:782
CNcbiIstream & NcbiGetline(CNcbiIstream &is, string &str, char delim, string::size_type *count=NULL)
Read from "is" to "str" up to the delimiter symbol "delim" (or EOF)
const string & m_String
Definition: ncbistre.hpp:845
CPrintableCharPtrConverter(const char *s)
Definition: ncbistre.hpp:896
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
CNcbiIstrstream(char *_Ptr)
Definition: ncbistre.hpp:184
const char * m_String
Definition: ncbistre.hpp:852
IO_PREFIX::istrstream _Mybase
Definition: ncbistre.hpp:173
IO_PREFIX::iostream CNcbiIostream
Portable alias for iostream.
Definition: ncbistre.hpp:152
CByteOrderMark(EEncodingForm encodingForm)
Definition: ncbistre.hpp:1086
EBOMDiscard
Whether to discard BOM or to keep it in the input stream.
Definition: ncbistre.hpp:1056
const string & m_String
Definition: ncbistre.hpp:865
bool NcbiStreamCompare(CNcbiIstream &is1, CNcbiIstream &is2)
Compare stream contents in binary form.
Definition: ncbistre.cpp:356
const string & m_String
Definition: ncbistre.hpp:890
Int8 GetOssSize(CNcbiOstrstream &oss)
Definition: ncbistre.hpp:821
CNcbiIstream & operator>>(CNcbiIstream &str, CByteOrderMark &bom)
Read Byte Order Mark, if present, from input stream.
Definition: ncbistre.hpp:1113
const char * Endl(void)
Platform-specific EndOfLine.
Definition: ncbistre.cpp:184
typename std::enable_if< std::is_integral< T >::value > enable_if_integral
Definition: ncbistre.hpp:254
CNcbiOstrstreamToString(CNcbiOstrstream &out)
Definition: ncbistre.hpp:806
CNcbistrstream_Base< IO_PREFIX::strstream, IOS_BASE::in|IOS_BASE::out > CNcbiStrstream
Definition: ncbistre.hpp:287
CNcbistrstream_Base< IO_PREFIX::ostrstream, IOS_BASE::out > CNcbiOstrstream
Definition: ncbistre.hpp:286
ECompareTextMode
Mode to compare streams in text form.
Definition: ncbistre.hpp:686
CNcbistrstream_Base(char *_Ptr, TInteger _Count, IOS_BASE::openmode _Mode=_DefMode)
Definition: ncbistre.hpp:258
CUpcaseStringConverter(const string &s)
Definition: ncbistre.hpp:844
CLocaseStringConverter(const string &s)
Definition: ncbistre.hpp:864
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
CNcbiIstrstream(const string &_Str)
Definition: ncbistre.hpp:175
CNcbiIstrstream(const char *_Ptr, TInteger _Count)
Definition: ncbistre.hpp:198
IO_PREFIX::ios CNcbiIos
Portable alias for ios.
Definition: ncbistre.hpp:140
EEncodingForm ReadIntoUtf8(CNcbiIstream &input, CStringUTF8 *result, EEncodingForm encoding_form=eEncodingForm_Unknown, EReadUnknownNoBOM what_if_no_bom=eNoBOM_GuessEncoding)
Read all input data from stream and try convert it into UTF8 string.
Definition: ncbistre.cpp:650
EEncodingForm m_EncodingForm
Definition: ncbistre.hpp:1097
IO_PREFIX::streamoff CNcbiStreamoff
Portable alias for streamoff.
Definition: ncbistre.hpp:137
CByteOrderMark(void)
Definition: ncbistre.hpp:1082
CNcbiOstrstreamToString(const CNcbiOstrstreamToString &)
void SetEncodingForm(EEncodingForm encodingForm)
Definition: ncbistre.hpp:1093
CLocaseCharPtrConverter(const char *s)
Definition: ncbistre.hpp:871
char Upcase(char c)
Definition: ncbistre.hpp:917
CUpcaseCharPtrConverter(const char *s)
Definition: ncbistre.hpp:851
CNcbiIstrstream(char *_Ptr, TInteger _Count)
Definition: ncbistre.hpp:193
#define CT_POS_TYPE
Definition: ncbistre.hpp:730
CNcbiOstrstream & m_Out
Definition: ncbistre.hpp:814
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
NCBI_NS_STD::char_traits< char >::pos_type NcbiInt8ToStreampos(Int8 pos)
Convert plain numeric stream position (offset) into stream position usable with STL stream library.
Definition: ncbistre.hpp:782
typename std::enable_if< std::is_integral< T >::value > enable_if_integral
Definition: ncbistre.hpp:189
#define CT_CHAR_TYPE
Definition: ncbistre.hpp:729
bool NcbiStreamCopy(CNcbiOstream &os, CNcbiIstream &is)
Copy the entire contents of stream "is" to stream "os".
Definition: ncbistre.cpp:211
IO_PREFIX::streambuf CNcbiStreambuf
Portable alias for streambuf.
Definition: ncbistre.hpp:143
IO_PREFIX::streampos CNcbiStreampos
Portable alias for streampos.
Definition: ncbistre.hpp:134
EReadUnknownNoBOM
How to read the text if the encoding form is not known (i.e.
Definition: ncbistre.hpp:1014
const char * m_String
Definition: ncbistre.hpp:872
IO_PREFIX::filebuf CNcbiFilebuf
Portable alias for filebuf.
Definition: ncbistre.hpp:373
IO_PREFIX::fstream CNcbiFstream
Portable alias for fstream.
Definition: ncbistre.hpp:538
bool NcbiStreamCompareText(CNcbiIstream &is1, CNcbiIstream &is2, ECompareTextMode mode, size_t buf_size=0)
Compare stream contents in text form.
Definition: ncbistre.cpp:394
size_t NcbiStreamToString(string *s, CNcbiIstream &is, size_t pos=0)
Input the entire contents of an istream into a string (NULL causes drain).
Definition: ncbistre.cpp:296
CPrintableStringConverter(const string &s)
Definition: ncbistre.hpp:889
EEncodingForm GetEncodingForm(void) const
Definition: ncbistre.hpp:1090
@ eEncodingForm_Utf16Foreign
Stream has UTF16 BOM. Byte order is nonnative for this OS.
Definition: ncbistre.hpp:1006
@ eEncodingForm_Utf8
Stream has UTF8 BOM.
Definition: ncbistre.hpp:1002
@ eEncodingForm_ISO8859_1
Stream has no BOM.
Definition: ncbistre.hpp:998
@ eEncodingForm_Windows_1252
Stream has no BOM.
Definition: ncbistre.hpp:1000
@ eEncodingForm_Unknown
Stream has no BOM.
Definition: ncbistre.hpp:996
@ eEncodingForm_Utf16Native
Stream has UTF16 BOM. Byte order is native for this OS.
Definition: ncbistre.hpp:1004
@ eBOM_Keep
Push the read BOM bytes back into the input stream.
Definition: ncbistre.hpp:1058
@ eBOM_Discard
Discard the read BOM bytes.
Definition: ncbistre.hpp:1057
@ eCompareText_IgnoreEol
Skip end-of-line characters ('\r' and ' ')
Definition: ncbistre.hpp:688
@ eCompareText_IgnoreWhiteSpace
Definition: ncbistre.hpp:690
@ eNoBOM_GuessEncoding
Try to guess the text's encoding form.
Definition: ncbistre.hpp:1028
@ eNoBOM_RawRead
Read the text "as is" (raw octal data).
Definition: ncbistre.hpp:1018
#define NCBI_XNCBI_EXPORT
Definition: ncbi_export.h:1283
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
static int input()
yy_size_t n
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Catch attempts to call ctype functions with bad types.
int tolower(Uchar c)
Definition: ncbictype.hpp:72
int toupper(Uchar c)
Definition: ncbictype.hpp:73
std::istream & in(std::istream &in_, double &x_)
static BOOL utf8
Definition: pcregrep.c:199
else result
Definition: token2.c:20
Modified on Mon May 27 04:38:41 2024 by modify_doxy.py rev. 669887