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

Go to the SVN repository for this file.

1 /* $Id: huge_file.hpp 102574 2024-06-04 15:04:11Z foleyjp $
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 * Authors: Sergiy Gotvyanskyy
27 *
28 * File Description:
29 *
30 *
31 */
32 
33 #ifndef _HUGE_FILE_HPP_INCLUDED_
34 #define _HUGE_FILE_HPP_INCLUDED_
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbiobj.hpp>
38 #include <serial/serialdef.hpp>
39 #include <util/format_guess.hpp>
40 
42 
43 class CMemoryFile;
44 class CObjectIStream;
45 
47 
48 class CSeq_entry;
49 class CSeq_submit;
50 class CSubmit_block;
51 class ILineErrorListener;
52 
54 
56 {
57 public:
58  CHugeFile();
59  virtual ~CHugeFile();
60  const set<TTypeInfo>* m_supported_types = nullptr;
61 
62  std::unique_ptr<CMemoryFile> m_memfile;
63  std::unique_ptr<std::istream> m_stream;
64  std::unique_ptr<std::streambuf> m_streambuf;
66  const char* m_memory = nullptr;
67  std::streampos m_filesize = 0;
68 
69  ESerialDataFormat m_serial_format = eSerial_None;
71  TTypeInfo m_content = nullptr;
72 
73  void Reset();
74  void Open(const std::string& filename, const set<TTypeInfo>* supported_types);
75  bool IsOpen() const { return m_filesize != 0; }
76  TTypeInfo RecognizeContent(std::streampos pos);
77  TTypeInfo RecognizeContent(std::istream& istr);
78  unique_ptr<CObjectIStream> MakeObjStream(std::streampos pos = 0) const;
79 
80 private:
81  bool x_TryOpenStreamFile(const string& filename, std::streampos filesize);
82  bool x_TryOpenMemoryFile(const string& filename);
83 };
84 
86 {
87 public:
88  enum EErrCode
89  {
92  };
93  //virtual const char* GetErrCodeString(void) const override;
95 };
96 
98 {
99 public:
100  virtual void Open(CHugeFile* file, ILineErrorListener * pMessageListener) = 0;
101  virtual bool GetNextBlob() = 0;
103  virtual bool IsMultiSequence() const = 0;
105  virtual ~IHugeAsnSource(){};
106 protected:
108 };
109 
113 
114 #endif // _HUGE_ASN_READER_HPP_INCLUDED_
EFormat
The formats are checked in the same order as declared here.
@ eUnknown
unknown format
NCBI_EXCEPTION_DEFAULT(CHugeFileException, CException)
std::string m_filename
Definition: huge_file.hpp:65
std::unique_ptr< CMemoryFile > m_memfile
Definition: huge_file.hpp:62
std::unique_ptr< std::istream > m_stream
Definition: huge_file.hpp:63
std::unique_ptr< std::streambuf > m_streambuf
Definition: huge_file.hpp:64
bool IsOpen() const
Definition: huge_file.hpp:75
void Reset()
CMemoryFile –.
Definition: ncbifile.hpp:2861
CObjectIStream –.
Definition: objistr.hpp:93
CObject –.
Definition: ncbiobj.hpp:180
Definition: Seq_entry.hpp:56
CSubmit_block –.
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
virtual void Open(CHugeFile *file, ILineErrorListener *pMessageListener)=0
virtual CRef< CSeq_entry > GetNextSeqEntry()=0
virtual bool GetNextBlob()=0
virtual CConstRef< CSubmit_block > GetSubmitBlock() const =0
virtual bool IsMultiSequence() const =0
virtual ~IHugeAsnSource()
Definition: huge_file.hpp:105
Definition: set.hpp:45
Include a standard set of the NCBI C++ Toolkit most basic headers.
string
Definition: cgiapp.hpp:687
EErrCode
Error types that an application can generate.
Definition: ncbiexpt.hpp:884
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
@ eSerial_None
Definition: serialdef.hpp:72
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_XHUGEASN_EXPORT
Definition: ncbi_export.h:809
FILE * file
Definition: fix_pub.hpp:45
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Tue Jul 16 13:22:19 2024 by modify_doxy.py rev. 669887