NCBI C++ ToolKit
EInfoResult_.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  * 'einfo.dtd'.
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
45 BEGIN_einfo_SCOPE // namespace einfo::
46 
47 
48 // generated classes
49 
51 {
52  if ( m_choice != e_not_set )
54 }
55 
57 {
58  switch ( m_choice ) {
59  case e_ERROR:
60  m_string.Destruct();
61  break;
62  case e_DbList:
63  case e_DbInfo:
64  m_object->RemoveReference();
65  break;
66  default:
67  break;
68  }
70 }
71 
72 void CEInfoResult_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
73 {
74  switch ( index ) {
75  case e_DbList:
76  (m_object = new(pool) einfo::CDbList())->AddReference();
77  break;
78  case e_DbInfo:
79  (m_object = new(pool) einfo::CDbInfo())->AddReference();
80  break;
81  case e_ERROR:
82  m_string.Construct();
83  break;
84  default:
85  break;
86  }
87  m_choice = index;
88 }
89 
90 const char* const CEInfoResult_Base::sm_SelectionNames[] = {
91  "not set",
92  "DbList",
93  "DbInfo",
94  "ERROR"
95 };
96 
98 {
99  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
100 }
101 
103 {
104  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
105 }
106 
108 {
110  return *static_cast<const TDbList*>(m_object);
111 }
112 
114 {
116  return *static_cast<TDbList*>(m_object);
117 }
118 
120 {
121  TDbList* ptr = &value;
122  if ( m_choice != e_DbList || m_object != ptr ) {
123  ResetSelection();
124  (m_object = ptr)->AddReference();
125  m_choice = e_DbList;
126  }
127 }
128 
130 {
132  return *static_cast<const TDbInfo*>(m_object);
133 }
134 
136 {
138  return *static_cast<TDbInfo*>(m_object);
139 }
140 
142 {
143  TDbInfo* ptr = &value;
144  if ( m_choice != e_DbInfo || m_object != ptr ) {
145  ResetSelection();
146  (m_object = ptr)->AddReference();
147  m_choice = e_DbInfo;
148  }
149 }
150 
152 {
154  *m_string = value;
155 }
156 
157 // helper methods
158 
159 // type info
161 {
162  SET_CHOICE_MODULE("einfo");
163  ADD_NAMED_REF_CHOICE_VARIANT("DbList", m_object, CDbList)->SetNsQualified(true);
164  ADD_NAMED_REF_CHOICE_VARIANT("DbInfo", m_object, CDbInfo)->SetNsQualified(true);
166  info->CodeVersion(22400);
167  info->DataSpec(ncbi::EDataSpec::eDTD);
168 }
170 
171 // constructor
173  : m_choice(e_not_set)
174 {
175 }
176 
177 // destructor
179 {
180  Reset();
181 }
182 
183 
184 
185 END_einfo_SCOPE // namespace einfo::
186 
User-defined methods of the data storage class.
#define BEGIN_einfo_SCOPE
Definition: DbInfo_.hpp:51
#define END_einfo_SCOPE
Definition: DbInfo_.hpp:52
User-defined methods of the data storage class.
User-defined methods of the data storage class.
BEGIN_NAMED_BASE_CHOICE_INFO("eInfoResult", CEInfoResult)
CDbInfo –.
Definition: DbInfo.hpp:64
CDbList –.
Definition: DbList.hpp:64
CEInfoResult –.
Definition: EInfoResult.hpp:64
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_BUF_CHOICE_VARIANT(MemberAlias, MemberName, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:385
@ eDoNotResetVariant
Definition: serialbase.hpp:78
virtual void Reset(void)
Reset the whole object.
E_Choice
Choice variants.
const TDbList & GetDbList(void) const
Get the variant data.
NCBI_NS_NCBI::CSerialObject * m_object
virtual ~CEInfoResult_Base(void)
TDbInfo & SetDbInfo(void)
Select the variant.
void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool *pool=0)
void Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset=NCBI_NS_NCBI::eDoResetVariant)
Select the requested variant if needed.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
TDbList & SetDbList(void)
Select the variant.
static const char *const sm_SelectionNames[]
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
NCBI_NS_STD::string TERROR
const TDbInfo & GetDbInfo(void) const
Get the variant data.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
TERROR & SetERROR(void)
Select the variant.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
static NCBI_NS_STD::string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
@ e_not_set
No variant selected.
@ 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:05:51 2024 by modify_doxy.py rev. 669887