NCBI C++ ToolKit
Parse_src_.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id$
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  * File Description:
27  * This code was generated by application DATATOOL
28  * using the following specifications:
29  * 'macro.asn'.
30  *
31  * ATTENTION:
32  * Don't edit or commit this file into CVS as this file will
33  * be overridden (by DATATOOL) without warning!
34  * ===========================================================================
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 #include <serial/serialimpl.hpp>
40 
41 // generated includes
46 
47 BEGIN_objects_SCOPE // namespace ncbi::objects::
48 
49 
50 // generated classes
51 
53 {
54  if ( m_choice != e_not_set )
56 }
57 
59 {
60  switch ( m_choice ) {
62  m_string.Destruct();
63  break;
64  case e_Org:
65  case e_General_id:
66  m_object->RemoveReference();
67  break;
68  default:
69  break;
70  }
72 }
73 
74 void CParse_src_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
75 {
76  switch ( index ) {
77  case e_Org:
78  (m_object = new(pool) ncbi::objects::CParse_src_org())->AddReference();
79  break;
80  case e_General_id:
81  (m_object = new(pool) ncbi::objects::CParse_src_general_id())->AddReference();
82  break;
84  m_string.Construct();
85  break;
86  default:
87  break;
88  }
89  m_choice = index;
90 }
91 
92 const char* const CParse_src_Base::sm_SelectionNames[] = {
93  "not set",
94  "defline",
95  "flatfile",
96  "local-id",
97  "org",
98  "comment",
99  "bankit-comment",
100  "structured-comment",
101  "file-id",
102  "general-id"
103 };
104 
106 {
107  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
108 }
109 
111 {
112  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
113 }
114 
116 {
118  return *static_cast<const TOrg*>(m_object);
119 }
120 
122 {
124  return *static_cast<TOrg*>(m_object);
125 }
126 
128 {
129  TOrg* ptr = &value;
130  if ( m_choice != e_Org || m_object != ptr ) {
131  ResetSelection();
132  (m_object = ptr)->AddReference();
133  m_choice = e_Org;
134  }
135 }
136 
138 {
140  *m_string = value;
141 }
142 
144 {
146  return *static_cast<const TGeneral_id*>(m_object);
147 }
148 
150 {
152  return *static_cast<TGeneral_id*>(m_object);
153 }
154 
156 {
157  TGeneral_id* ptr = &value;
158  if ( m_choice != e_General_id || m_object != ptr ) {
159  ResetSelection();
160  (m_object = ptr)->AddReference();
162  }
163 }
164 
165 // helper methods
166 
167 // type info
169 {
170  SET_CHOICE_MODULE("NCBI-Macro");
171  ADD_NAMED_NULL_CHOICE_VARIANT("defline", null, ());
172  ADD_NAMED_NULL_CHOICE_VARIANT("flatfile", null, ());
173  ADD_NAMED_NULL_CHOICE_VARIANT("local-id", null, ());
175  ADD_NAMED_NULL_CHOICE_VARIANT("comment", null, ());
176  ADD_NAMED_NULL_CHOICE_VARIANT("bankit-comment", null, ());
177  ADD_NAMED_BUF_CHOICE_VARIANT("structured-comment", m_string, STD, (string));
178  ADD_NAMED_NULL_CHOICE_VARIANT("file-id", null, ());
179  ADD_NAMED_REF_CHOICE_VARIANT("general-id", m_object, CParse_src_general_id);
180  info->CodeVersion(22400);
181  info->DataSpec(ncbi::EDataSpec::eASN);
182 }
184 
185 // constructor
187  : m_choice(e_not_set)
188 {
189 }
190 
191 // destructor
193 {
194  Reset();
195 }
196 
197 
198 
199 END_objects_SCOPE // namespace ncbi::objects::
200 
202 
User-defined methods of the data storage class.
BEGIN_NAMED_BASE_CHOICE_INFO("Parse-src", CParse_src)
Definition: Parse_src_.cpp:168
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CParse_src_general_id –.
CParse_src_org –.
CParse_src –.
Definition: Parse_src.hpp:66
string
Definition: cgiapp.hpp:687
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
#define ADD_NAMED_REF_CHOICE_VARIANT(MemberAlias, MemberName, ClassName)
Definition: serialimpl.hpp:400
#define END_CHOICE_INFO
Definition: serialimpl.hpp:506
#define SET_CHOICE_MODULE(ModuleName)
Definition: serialimpl.hpp:500
#define ADD_NAMED_NULL_CHOICE_VARIANT(MemberAlias, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:379
#define ADD_NAMED_BUF_CHOICE_VARIANT(MemberAlias, MemberName, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:385
@ eDoNotResetVariant
Definition: serialbase.hpp:78
void AddReference(void) const
Add reference to object.
Definition: ncbiobj.hpp:489
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
virtual void Reset(void)
Reset the whole object.
Definition: Parse_src_.cpp:52
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Parse_src_.cpp:110
static const char *const sm_SelectionNames[]
Definition: Parse_src_.hpp:318
E_Choice m_choice
Definition: Parse_src_.hpp:314
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Parse_src_.hpp:321
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Parse_src_.cpp:58
TStructured_comment & SetStructured_comment(void)
Select the variant.
Definition: Parse_src_.hpp:444
TOrg & SetOrg(void)
Select the variant.
Definition: Parse_src_.cpp:121
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Parse_src_.hpp:322
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Parse_src_.cpp:105
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Parse_src_.hpp:342
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Parse_src_.cpp:74
virtual ~CParse_src_Base(void)
Definition: Parse_src_.cpp:192
const TGeneral_id & GetGeneral_id(void) const
Get the variant data.
Definition: Parse_src_.cpp:143
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TOrg & GetOrg(void) const
Get the variant data.
Definition: Parse_src_.cpp:115
E_Choice
Choice variants.
Definition: Parse_src_.hpp:91
string TStructured_comment
Definition: Parse_src_.hpp:157
TGeneral_id & SetGeneral_id(void)
Select the variant.
Definition: Parse_src_.cpp:149
@ e_not_set
No variant selected.
Definition: Parse_src_.hpp:92
@ e_not_set
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define STD
Modified on Wed Sep 04 15:02:28 2024 by modify_doxy.py rev. 669887