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

📄 fileutil.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: fileutil.hpp,v $ * PRODUCTION Revision 1000.0  2003/10/29 17:36:07  gouriano * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.14 * PRODUCTION * =========================================================================== */#ifndef FILEUTIL_HPP#define FILEUTIL_HPP/*  $Id: fileutil.hpp,v 1000.0 2003/10/29 17:36:07 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: Eugene Vasilchenko** File Description:*   Several file utility functions/classes.*/#include <corelib/ncbistd.hpp>#include <serial/serialdef.hpp>#include <memory>BEGIN_NCBI_SCOPEstatic const size_t MAX_FILE_NAME_LENGTH = 31;class SourceFile{public:    SourceFile(const string& name, bool binary = false);    SourceFile(const string& name, const list<string>& dirs,               bool binary = false);    ~SourceFile(void);    operator CNcbiIstream&(void) const        {            return *m_StreamPtr;        }    enum EType {        eUnknown,  // Unknown type        eASN,      // ASN file        eDTD       // DTD file    };    EType GetType(void) const;private:    string m_Name;    CNcbiIstream* m_StreamPtr;    bool m_Open;    bool x_Open(const string& name, bool binary);};class DestinationFile{public:    DestinationFile(const string& name, bool binary = false);    ~DestinationFile(void);    operator CNcbiOstream&(void) const        {            return *m_StreamPtr;        }private:    CNcbiOstream* m_StreamPtr;    bool m_Open;};struct FileInfo {    FileInfo(void)        : type(ESerialDataFormat(eSerial_None))        { }    FileInfo(const string& n, ESerialDataFormat t)        : name(n), type(t)        { }    operator bool(void) const        { return !name.empty(); }    operator const string&(void) const        { return name; }    string name;    ESerialDataFormat type;};class CDelayedOfstream : public CNcbiOstrstream{public:    CDelayedOfstream(const string& fileName);    virtual ~CDelayedOfstream(void);    bool is_open(void) const        {            return !m_FileName.empty();        }    void open(const string& fileName);    void close(void);protected:    bool equals(void);    bool rewrite(void);private:    string m_FileName;    auto_ptr<CNcbiIfstream> m_Istream;    auto_ptr<CNcbiOfstream> m_Ostream;};// return combined dir and name, inserting if needed '/'string Path(const string& dir, const string& name);// file name will be valid after adding at most addLength symbolsstring MakeFileName(const string& s, size_t addLength = 0);// return base name of file i.e. without dir and extensionstring BaseName(const string& path);// return dir name of filestring DirName(const string& path);bool IsLocalPath(const string& path);// Convert system-dependent path to the standard path// ('\' ==> '/', ':' ==> '/', etc.)string GetStdPath(const string& path);END_NCBI_SCOPE/** ===========================================================================** $Log: fileutil.hpp,v $* Revision 1000.0  2003/10/29 17:36:07  gouriano* PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.14** Revision 1.14  2002/10/15 13:52:09  gouriano* added "GetType" method - module file type by extension** Revision 1.13  2002/08/06 17:03:48  ucko* Let -opm take a comma-delimited list; move relevant CVS logs to end.** Revision 1.12  2001/08/31 20:05:43  ucko* Fix ICC build.** Revision 1.11  2001/08/15 19:16:10  juran* Add GetStdPath() prototype.** Revision 1.10  2001/05/17 15:00:42  lavr* Typos corrected** Revision 1.9  2001/02/02 16:19:55  vasilche* Fixed file path processing on Mac** Revision 1.8  2000/11/29 17:42:30  vasilche* Added CComment class for storing/printing ASN.1/XML module comments.* Added srcutil.hpp file to reduce file dependency.** Revision 1.7  2000/11/15 20:34:43  vasilche* Added user comments to ENUMERATED types.* Added storing of user comments to ASN.1 module definition.** Revision 1.6  2000/11/14 21:41:13  vasilche* Added preserving of ASN.1 definition comments.** Revision 1.5  2000/04/28 16:58:08  vasilche* Added classes CByteSource and CByteSourceReader for generic reading.* Added delayed reading of choice variants.** Revision 1.4  2000/04/13 14:50:22  vasilche* Added CObjectIStream::Open() and CObjectOStream::Open() for easier use.** Revision 1.3  2000/04/07 19:26:09  vasilche* Added namespace support to datatool.* By default with argument -oR datatool will generate objects in namespace* NCBI_NS_NCBI::objects (aka ncbi::objects).* Datatool's classes also moved to NCBI namespace.** Revision 1.2  2000/03/29 15:51:42  vasilche* Generated files names limited to 31 symbols due to limitations of Mac.** Revision 1.1  2000/02/01 21:46:18  vasilche* Added CGeneratedChoiceTypeInfo for generated choice classes.* Removed CMemberInfo subclasses.* Added support for DEFAULT/OPTIONAL members.* Changed class generation.* Moved datatool headers to include/internal/serial/tool.** Revision 1.5  1999/12/30 21:33:39  vasilche* Changed arguments - more structured.* Added intelligence in detection of source directories.** Revision 1.4  1999/12/28 18:55:57  vasilche* Reduced size of compiled object files:* 1. avoid inline or implicit virtual methods (especially destructors).* 2. avoid std::string's methods usage in inline methods.* 3. avoid string literals ("xxx") in inline methods.** Revision 1.3  1999/12/21 17:44:19  vasilche* Fixed compilation on SunPro C++** Revision 1.2  1999/12/21 17:18:34  vasilche* Added CDelayedFostream class which rewrites file only if contents is changed.** Revision 1.1  1999/12/20 21:00:18  vasilche* Added generation of sources in different directories.** ===========================================================================*/#endif

⌨️ 快捷键说明

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