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

Go to the SVN repository for this file.

1 #ifndef OBJCOPY__HPP
2 #define OBJCOPY__HPP
3 
4 /* $Id: objcopy.hpp 51124 2011-09-07 16:16:59Z vasilche $
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: Eugene Vasilchenko
30 *
31 * File Description:
32 * ObjectStreamCopier reads serial data object from one stream and
33 * immediately writes it into another one, usually using different encoding
34 * format. Converted data is not stored in memory.
35 */
36 
37 #include <corelib/ncbistd.hpp>
38 #include <serial/typeinfo.hpp>
39 #include <serial/objostr.hpp>
40 #include <serial/objistr.hpp>
41 #include <serial/objhook.hpp>
42 #include <serial/impl/pathhook.hpp>
43 
44 
45 /** @addtogroup ObjStreamSupport
46  *
47  * @{
48  */
49 
50 
52 
53 class CContainerTypeInfo;
54 class CClassTypeInfo;
55 class CChoiceTypeInfo;
56 class CAliasTypeInfo;
57 class CMemberInfo;
58 
59 class CCopyObjectHook;
62 
63 /////////////////////////////////////////////////////////////////////////////
64 ///
65 /// CObjectStreamCopier --
66 ///
67 /// Read serial data object from one stream and immediately write
68 /// it into another one, usually using different encoding format.
69 /// The benefit of using Copier is that converted data is not stored in memory
71 {
72 public:
73  /// Constructor
74  ///
75  /// @param in
76  /// Input stream reader
77  /// @param out
78  /// Output stream writer
80 
81  /// Destructor
82  ~CObjectStreamCopier(void);
83 
84  CObjectIStream& In(void) const;
85  CObjectOStream& Out(void) const;
86 
87  void ResetLocalHooks(void);
88 
89  /// Copy data
90  ///
91  /// @param type
92  /// Serial class type description
93  void Copy(const CObjectTypeInfo& type);
94 
96  eNoFileHeader
97  };
98  /// Copy data when the input file header is already read
99  ///
100  /// @param type
101  /// Type information
102  /// @param noFileHeader
103  /// Omit file header in the input stream
104  void Copy(TTypeInfo type, ENoFileHeader noFileHeader);
105 
106  /// Copy object, omitting file header both
107  /// in input and output streams
108  ///
109  /// @param type
110  /// Type information
112 
114 
115  // primitive types copy
117  void CopyStringStore(void);
118  void CopyByteBlock(void);
119 
121 
122  // complex types copy
123  void CopyNamedType(TTypeInfo namedTypeInfo, TTypeInfo objectType);
124 
125  void CopyPointer(TTypeInfo declaredType);
126  bool CopyNullPointer(void);
127 
128  void CopyContainer(const CContainerTypeInfo* containerType);
129 
130  void CopyClassRandom(const CClassTypeInfo* classType);
131  void CopyClassSequential(const CClassTypeInfo* classType);
132 
133  void CopyChoice(const CChoiceTypeInfo* choiceType);
134  void CopyAlias(const CAliasTypeInfo* aliasType);
135 
137  void ThrowError1(const CDiagCompileInfo& diag_info,
138  TFailFlags fail, const char* message);
139  void ThrowError1(const CDiagCompileInfo& diag_info,
140  TFailFlags fail, const string& message);
141  void ExpectedMember(const CMemberInfo* memberInfo);
142  void DuplicatedMember(const CMemberInfo* memberInfo);
143 
144  void SetPathCopyObjectHook( const string& path, CCopyObjectHook* hook);
145  void SetPathCopyMemberHook( const string& path, CCopyClassMemberHook* hook);
146  void SetPathCopyVariantHook(const string& path, CCopyChoiceVariantHook* hook);
147  void SetPathHooks(CObjectStack& stk, bool set);
148 
149 private:
155 
156 public:
157  // hook support
161 };
162 
163 
164 /* @ */
165 
166 
167 #include <serial/impl/objcopy.inl>
168 
170 
171 #endif /* OBJCOPY__HPP */
Copy hook for a choice variant (CHOICE)
Definition: objhook.hpp:280
Copy hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:266
Copy hook for a standalone object.
Definition: objhook.hpp:254
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Definition: set.hpp:45
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
EStringType
String type.
Definition: serialdef.hpp:185
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
Definition: serialdef.hpp:186
CObjectIStream & m_In
Definition: objcopy.hpp:150
CStreamPathHook< CMemberInfo *, CCopyClassMemberHook * > m_PathCopyMemberHooks
Definition: objcopy.hpp:152
void CopyExternalObject(TTypeInfo type)
void CopyContainer(const CContainerTypeInfo *containerType)
void CopyStringStore(void)
CLocalHookSet< CCopyChoiceVariantHook > m_ChoiceVariantHookKey
Definition: objcopy.hpp:160
void DuplicatedMember(const CMemberInfo *memberInfo)
CObjectIStream::TFailFlags TFailFlags
Definition: objcopy.hpp:136
void CopyClassSequential(const CClassTypeInfo *classType)
void CopyChoice(const CChoiceTypeInfo *choiceType)
void ThrowError1(const CDiagCompileInfo &diag_info, TFailFlags fail, const string &message)
CLocalHookSet< CCopyObjectHook > m_ObjectHookKey
Definition: objcopy.hpp:158
void CopyString(EStringType type=eStringTypeVisible)
CObjectIStream & In(void) const
void CopyAlias(const CAliasTypeInfo *aliasType)
void CopyAnyContentObject(void)
void CopyNamedType(TTypeInfo namedTypeInfo, TTypeInfo objectType)
void ThrowError1(const CDiagCompileInfo &diag_info, TFailFlags fail, const char *message)
void ExpectedMember(const CMemberInfo *memberInfo)
CStreamPathHook< CVariantInfo *, CCopyChoiceVariantHook * > m_PathCopyVariantHooks
Definition: objcopy.hpp:153
CLocalHookSet< CCopyClassMemberHook > m_ClassMemberHookKey
Definition: objcopy.hpp:159
void CopyClassRandom(const CClassTypeInfo *classType)
CObjectOStream & Out(void) const
CObjectOStream & m_Out
Definition: objcopy.hpp:151
CStreamObjectPathHook< CCopyObjectHook * > m_PathCopyObjectHooks
Definition: objcopy.hpp:154
void CopyObject(TTypeInfo type)
Copy object, omitting file header both in input and output streams.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
std::istream & in(std::istream &in_, double &x_)
Definition: type.c:6
Modified on Fri Sep 20 14:58:26 2024 by modify_doxy.py rev. 669887