⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbistre.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: ncbistre.hpp,v $ * PRODUCTION Revision 1000.4  2004/06/01 19:08:14  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.40 * PRODUCTION * =========================================================================== */#ifndef CORELIB___NCBISTRE__HPP#define CORELIB___NCBISTRE__HPP/*  $Id: ncbistre.hpp,v 1000.4 2004/06/01 19:08:14 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Author:  Denis Vakatov * * *//// @file ncbistre.hpp/// NCBI C++ stream class wrappers for triggering between "new" and/// "old" C++ stream libraries.#include <corelib/ncbistl.hpp>/// Determine which iostream library to use, include appropriate/// headers, and #define specific preprocessor variables./// The default is the new(template-based, std::) one.#if !defined(HAVE_IOSTREAM)  &&  !defined(NCBI_USE_OLD_IOSTREAM)#  define NCBI_USE_OLD_IOSTREAM#endif#if defined(HAVE_IOSTREAM_H)  &&  defined(NCBI_USE_OLD_IOSTREAM)#  include <iostream.h>#  include <fstream.h>#  if defined(HAVE_STRSTREA_H)#    include <strstrea.h>#  else#    include <strstream.h>#  endif#  include <iomanip.h>#  define IO_PREFIX#  define IOS_BASE      ::ios#  define IOS_PREFIX    ::ios#  define PUBSYNC       sync#  define PUBSEEKPOS    seekpos#  define PUBSEEKOFF    seekoff#elif defined(HAVE_IOSTREAM)#  if defined(NCBI_USE_OLD_IOSTREAM)#    undef NCBI_USE_OLD_IOSTREAM#  endif#  if defined(NCBI_COMPILER_GCC)#    if NCBI_COMPILER_VERSION < 300#      define NO_PUBSYNC#    elif NCBI_COMPILER_VERSION >= 310// Don't bug us about including <strstream>.#      define _CPP_BACKWARD_BACKWARD_WARNING_H 1#      define _BACKWARD_BACKWARD_WARNING_H 1#    endif#  endif#  include <iostream>#  include <fstream>#  include <strstream>#  include <iomanip>#  if defined(HAVE_NO_STD)#    define IO_PREFIX#  else#    define IO_PREFIX   NCBI_NS_STD#  endif#  if defined HAVE_NO_IOS_BASE#    define IOS_BASE    IO_PREFIX::ios#  else#    define IOS_BASE    IO_PREFIX::ios_base#  endif#  define IOS_PREFIX    IO_PREFIX::ios#  ifdef NO_PUBSYNC#    define PUBSYNC     sync#    define PUBSEEKOFF  seekoff#    define PUBSEEKPOS  seekpos#  else#    define PUBSYNC     pubsync#    define PUBSEEKOFF  pubseekoff#    define PUBSEEKPOS  pubseekpos#  endif#else#  error "Neither <iostream> nor <iostream.h> can be found!"#endif// obsolete#define SEEKOFF         PUBSEEKOFF#include <string>// (BEGIN_NCBI_SCOPE must be followed by END_NCBI_SCOPE later in this file)BEGIN_NCBI_SCOPE/** @addtogroup Stream * * @{ */// I/O classes/// Portable alias for streampos.typedef IO_PREFIX::streampos     CNcbiStreampos;/// Portable alias for streamoff.typedef IO_PREFIX::streamoff     CNcbiStreamoff;/// Portable alias for ios.typedef IO_PREFIX::ios           CNcbiIos;/// Portable alias for streambuf.typedef IO_PREFIX::streambuf     CNcbiStreambuf;/// Portable alias for istream.typedef IO_PREFIX::istream       CNcbiIstream;/// Portable alias for ostream.typedef IO_PREFIX::ostream       CNcbiOstream;/// Portable alias for iostream.typedef IO_PREFIX::iostream      CNcbiIostream;/// Portable alias for strstreambuf.typedef IO_PREFIX::strstreambuf  CNcbiStrstreambuf;/// Portable alias for istrstream.typedef IO_PREFIX::istrstream    CNcbiIstrstream;/// Portable alias for ostrstream.typedef IO_PREFIX::ostrstream    CNcbiOstrstream;/// Portable alias for strstream.typedef IO_PREFIX::strstream     CNcbiStrstream;/// Portable alias for filebuf.typedef IO_PREFIX::filebuf       CNcbiFilebuf;#ifdef NCBI_COMPILER_MSVC#  if _MSC_VER >= 1200  &&  _MSC_VER < 1300class CNcbiIfstream : public IO_PREFIX::ifstream{public:    CNcbiIfstream() : m_Fp(0)    {    }    explicit CNcbiIfstream(const char* s,                           IOS_BASE::openmode mode = IOS_BASE::in)    {        fastopen(s, mode);    }    void fastopen(const char* s, IOS_BASE::openmode mode = IOS_BASE::in)    {        if (is_open()  ||  !(m_Fp = __Fiopen(s, mode | in)))            setstate(failbit);        else            (void) new (rdbuf()) basic_filebuf<char, char_traits<char> >(m_Fp);    }    virtual ~CNcbiIfstream(void)    {        if (m_Fp)            fclose(m_Fp);    }private:    FILE* m_Fp;};#  else/// Portable alias for ifstream.typedef IO_PREFIX::ifstream      CNcbiIfstream;#  endif#else/// Portable alias for ifstream.typedef IO_PREFIX::ifstream      CNcbiIfstream;#endif#ifdef NCBI_COMPILER_MSVC#  if _MSC_VER >= 1200  &&  _MSC_VER < 1300class CNcbiOfstream : public IO_PREFIX::ofstream{public:    CNcbiOfstream() : m_Fp(0)    {    }    explicit CNcbiOfstream(const char* s,                           IOS_BASE::openmode mode = IOS_BASE::out)    {        fastopen(s, mode);    }    void fastopen(const char* s, IOS_BASE::openmode mode = IOS_BASE::out)    {        if (is_open()  ||  !(m_Fp = __Fiopen(s, mode | out)))            setstate(failbit);        else            (void) new (rdbuf()) basic_filebuf<char, char_traits<char> >(m_Fp);    }    virtual ~CNcbiOfstream(void)    {        if (m_Fp)            fclose(m_Fp);    }private:    FILE* m_Fp;};#  else/// Portable alias for ofstream.typedef IO_PREFIX::ofstream      CNcbiOfstream;#  endif#else/// Portable alias for ofstream.typedef IO_PREFIX::ofstream      CNcbiOfstream;#endif#ifdef NCBI_COMPILER_MSVC#  if _MSC_VER >= 1200  &&  _MSC_VER < 1300class CNcbiFstream : public IO_PREFIX::fstream{public:    CNcbiFstream() : m_Fp(0)    {    }    explicit CNcbiFstream(const char* s,                          IOS_BASE::openmode                          mode = IOS_BASE::in | IOS_BASE::out)    {        fastopen(s, mode);    }    void fastopen(const char* s, IOS_BASE::openmode                  mode = IOS_BASE::in | IOS_BASE::out)    {        if (is_open()  ||  !(m_Fp = __Fiopen(s, mode)))            setstate(failbit);        else            (void) new (rdbuf()) basic_filebuf<char, char_traits<char> >(m_Fp);    }    virtual ~CNcbiFstream(void)    {        if (m_Fp)            fclose(m_Fp);    }private:    FILE* m_Fp;};#  else/// Portable alias for fstream.typedef IO_PREFIX::fstream       CNcbiFstream;#  endif#else/// Portable alias for fstream.typedef IO_PREFIX::fstream       CNcbiFstream;#endif// Standard I/O streams#define NcbiCin                  IO_PREFIX::cin#define NcbiCout                 IO_PREFIX::cout#define NcbiCerr                 IO_PREFIX::cerr#define NcbiClog                 IO_PREFIX::clog// I/O manipulators#define NcbiEndl                 IO_PREFIX::endl#define NcbiEnds                 IO_PREFIX::ends#define NcbiFlush                IO_PREFIX::flush#define NcbiDec                  IO_PREFIX::dec#define NcbiHex                  IO_PREFIX::hex#define NcbiOct                  IO_PREFIX::oct#define NcbiWs                   IO_PREFIX::ws#define NcbiSetbase              IO_PREFIX::setbase#define NcbiResetiosflags        IO_PREFIX::resetiosflags#define NcbiSetiosflags          IO_PREFIX::setiosflags#define NcbiSetfill              IO_PREFIX::setfill#define NcbiSetprecision         IO_PREFIX::setprecision#define NcbiSetw                 IO_PREFIX::setw// I/O state#define NcbiGoodbit              IOS_PREFIX::goodbit#define NcbiEofbit               IOS_PREFIX::eofbit#define NcbiFailbit              IOS_PREFIX::failbit#define NcbiBadbit               IOS_PREFIX::badbit#define NcbiHardfail             IOS_PREFIX::hardfail// Platform-specific EndOfLineNCBI_XNCBI_EXPORTextern const char* Endl(void);// Read from "is" to "str" up to the delimiter symbol "delim"(or EOF)NCBI_XNCBI_EXPORTextern CNcbiIstream& NcbiGetline(CNcbiIstream& is, string& str, char delim);// Read from "is" to "str" the next line // (taking into account platform specifics of End-of-Line)NCBI_XNCBI_EXPORTextern CNcbiIstream& NcbiGetlineEOL(CNcbiIstream& is, string& str);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -