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

Go to the SVN repository for this file.

1 /* $Id: SeqTable_single_data.cpp 66471 2015-03-05 16:08:06Z vasilche $
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  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'seqtable.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 // generated includes
42 
43 // generated classes
44 
46 
47 BEGIN_objects_SCOPE // namespace ncbi::objects::
48 
49 // destructor
51 {
52 }
53 
54 
56  const char* type_name)
57 {
58  NCBI_THROW_FMT(CSeqTableException, eIncompatibleValueType,
59  "CSeqTable_single_data::GetValue("<<type_name<<"&): "
60  "value is too big for requested type: "<<value);
61 }
62 
63 
65 {
66  NCBI_THROW_FMT(CSeqTableException, eIncompatibleValueType,
67  "CSeqTable_single_data::GetValue("<<type_name<<"&): "
68  <<SelectionName(Which())<<
69  " value cannot be converted to requested type");
70 }
71 
72 
73 template<class DstInt, class SrcInt>
74 static inline
75 bool sx_DownCast(DstInt& v, const SrcInt& value, const char* type_name)
76 {
77  v = DstInt(value);
78  if ( SrcInt(v) != value ) {
80  }
81  return true;
82 }
83 
84 
86 {
87  static const char* const type_name = "bool";
88  switch ( Which() ) {
89  case e_Bit:
90  v = GetBit();
91  break;
92  case e_Int:
94  break;
95  case e_Int8:
97  break;
98  default:
100  }
101 }
102 
103 
105 {
106  static const char* const type_name = "Int1";
107  switch ( Which() ) {
108  case e_Bit:
109  v = GetBit();
110  break;
111  case e_Int:
113  break;
114  case e_Int8:
116  break;
117  default:
119  }
120 }
121 
122 
124 {
125  static const char* const type_name = "Int2";
126  switch ( Which() ) {
127  case e_Bit:
128  v = GetBit();
129  break;
130  case e_Int:
132  break;
133  case e_Int8:
135  break;
136  default:
138  }
139 }
140 
141 
143 {
144  static const char* const type_name = "int";
145  switch ( Which() ) {
146  case e_Bit:
147  v = GetBit();
148  break;
149  case e_Int:
150  v = GetInt();
151  break;
152  case e_Int8:
154  break;
155  default:
157  }
158 }
159 
160 
162 {
163  switch ( Which() ) {
164  case e_Bit:
165  v = GetBit();
166  break;
167  case e_Int:
168  v = GetInt();
169  break;
170  case e_Int8:
171  v = GetInt8();
172  break;
173  default:
174  ThrowConversionError("Int8");
175  }
176 }
177 
178 
179 void CSeqTable_single_data::GetValue(double& v) const
180 {
181  switch ( Which() ) {
182  case e_Bit:
183  v = GetBit();
184  break;
185  case e_Int:
186  v = GetInt();
187  break;
188  case e_Int8:
189  v = GetInt8();
190  break;
191  case e_Real:
192  v = GetReal();
193  break;
194  default:
195  ThrowConversionError("double");
196  }
197 }
198 
199 
200 void CSeqTable_single_data::GetValue(string& v) const
201 {
202  if ( IsString() ) {
203  v = GetString();
204  }
205  else {
206  ThrowConversionError("string");
207  }
208 }
209 
210 
212 {
213  if ( IsBytes() ) {
214  v = GetBytes();
215  }
216  else {
217  ThrowConversionError("vector<char>");
218  }
219 }
220 
221 
222 END_objects_SCOPE // namespace ncbi::objects::
223 
static bool sx_DownCast(DstInt &v, const SrcInt &value, const char *type_name)
User-defined methods of the data storage class.
Seq-loc and seq-align mapper exceptions.
static void ThrowOverflowError(Int8 value, const char *type_name)
void GetValue(bool &v) const
void ThrowConversionError(const char *type_name) const
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:719
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
int8_t Int1
1-byte (8-bit) signed integer
Definition: ncbitype.h:98
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
E_Choice Which(void) const
Which variant is currently selected.
const TString & GetString(void) const
Get the variant data.
bool IsBytes(void) const
Check if variant Bytes is selected.
TInt8 GetInt8(void) const
Get the variant data.
TBit GetBit(void) const
Get the variant data.
bool IsString(void) const
Check if variant String is selected.
const TBytes & GetBytes(void) const
Get the variant data.
TReal GetReal(void) const
Get the variant data.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
TInt GetInt(void) const
Get the variant data.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static const char * type_name(CS_INT value)
Definition: will_convert.c:122
Modified on Wed Sep 04 15:05:17 2024 by modify_doxy.py rev. 669887