NCBI C++ ToolKit
SpelledQuery_.hpp
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  */
27 
28 /// @file SpelledQuery_.hpp
29 /// Data storage class.
30 ///
31 /// This file was generated by application DATATOOL
32 /// using the following specifications:
33 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objtools/eutils/espell/espell.dtd">espell.dtd</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objtools/eutils/espell/espell.def">espell.def</a>
36 ///
37 /// ATTENTION:
38 /// Don't edit or commit this file into CVS as this file will
39 /// be overridden (by DATATOOL) without warning!
40 
41 #ifndef espell__OBJTOOLS_EUTILS_ESPELL_SPELLEDQUERY_BASE_HPP
42 #define espell__OBJTOOLS_EUTILS_ESPELL_SPELLEDQUERY_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
49 #include <string>
50 
51 #ifndef BEGIN_espell_SCOPE
52 # define BEGIN_espell_SCOPE BEGIN_SCOPE(espell)
53 # define END_espell_SCOPE END_SCOPE(espell)
54 #endif
55 BEGIN_espell_SCOPE // namespace espell::
56 
57 
58 // generated classes
59 
60 
61 /** @addtogroup dataspec_espell
62  *
63  * @{
64  */
65 
66 /////////////////////////////////////////////////////////////////////////////
67 ///
68 /// CSpelledQuery_Base --
69 ///
70 
71 class NCBI_EUTILS_EXPORT CSpelledQuery_Base : public NCBI_NS_NCBI::CSerialObject
72 {
73  typedef NCBI_NS_NCBI::CSerialObject Tparent;
74 public:
75  // constructor
76  CSpelledQuery_Base(void);
77  // destructor
78  virtual ~CSpelledQuery_Base(void);
79 
80  // type info
82 
83  /////////////////////////////////////////////////////////////////////////////
84  /// \d+
85  ///
86  /// C_Data --
87  ///
88 
89  class NCBI_EUTILS_EXPORT C_Data : public NCBI_NS_NCBI::CSerialObject
90  {
91  typedef NCBI_NS_NCBI::CSerialObject Tparent;
92  public:
93  // constructor
94  C_Data(void);
95  // destructor
96  ~C_Data(void);
97 
98  // type info
100 
101 
102  /// Choice variants.
103  enum E_Choice {
104  e_not_set = 0, ///< No variant selected
105  e_Replaced, ///< \d+
106  e_Original ///< \d+
107  };
108  /// Maximum+1 value of the choice variant enumerator.
110  e_MaxChoice = 3 ///< == e_Original+1
111  };
112 
113  /// Reset the whole object
114  void Reset(void);
115 
116  /// Reset the selection (set it to e_not_set).
117  void ResetSelection(void);
118 
119  /// Which variant is currently selected.
120  ///
121  /// @return
122  /// Choice state enumerator.
123  E_Choice Which(void) const;
124 
125  /// Verify selection, throw exception if it differs from the expected.
126  ///
127  /// @param index
128  /// Expected selection.
129  void CheckSelected(E_Choice index) const;
130 
131  /// Throw 'InvalidSelection' exception.
132  ///
133  /// @param index
134  /// Expected selection.
135  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
136 
137  /// Retrieve selection name (for diagnostic purposes).
138  ///
139  /// @param index
140  /// One of possible selection states.
141  /// @return
142  /// Name string.
143  static NCBI_NS_STD::string SelectionName(E_Choice index);
144 
145  /// Select the requested variant if needed.
146  ///
147  /// @param index
148  /// New selection state.
149  /// @param reset
150  /// Flag that defines the resetting of the variant data. The data will
151  /// be reset if either the current selection differs from the new one,
152  /// or the flag is set to eDoResetVariant.
153  void Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset = NCBI_NS_NCBI::eDoResetVariant);
154  /// Select the requested variant if needed,
155  /// allocating CObject variants from memory pool.
156  void Select(E_Choice index,
158  NCBI_NS_NCBI::CObjectMemoryPool* pool);
159 
160  // types
163 
164  // getters
165  // setters
166 
167 
168  /// Check if variant Replaced is selected.
169  ///
170  /// Replaced type is defined as 'typedef NCBI_NS_STD::string TReplaced'.
171  /// @return
172  /// - true, if the variant is selected.
173  /// - false, otherwise.
174  bool IsReplaced(void) const;
175 
176  /// Get the variant data.
177  ///
178  /// @return
179  /// Reference to the data.
180  const TReplaced& GetReplaced(void) const;
181 
182  /// Select the variant.
183  ///
184  /// @return
185  /// Reference to the variant data.
186  TReplaced& SetReplaced(void);
187 
188  /// Select the variant and set its data.
189  ///
190  /// @param value
191  /// Variant data.
192  void SetReplaced(const TReplaced& value);
193 
194 
195  /// Check if variant Original is selected.
196  ///
197  /// Original type is defined as 'typedef NCBI_NS_STD::string TOriginal'.
198  /// @return
199  /// - true, if the variant is selected.
200  /// - false, otherwise.
201  bool IsOriginal(void) const;
202 
203  /// Get the variant data.
204  ///
205  /// @return
206  /// Reference to the data.
207  const TOriginal& GetOriginal(void) const;
208 
209  /// Select the variant.
210  ///
211  /// @return
212  /// Reference to the variant data.
213  TOriginal& SetOriginal(void);
214 
215  /// Select the variant and set its data.
216  ///
217  /// @param value
218  /// Variant data.
219  void SetOriginal(const TOriginal& value);
220 
221 
222  private:
223  // copy constructor and assignment operator
224  C_Data(const C_Data& );
226  // choice state
228  // helper methods
229  void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool = 0);
230 
231  static const char* const sm_SelectionNames[];
232  // data
233  union {
234  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
236  };
237  };
238  // types
239  typedef NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_Data > > Tdata;
240 
241  // getters
242  // setters
243 
244  /// Check if a value has been assigned to data member.
245  ///
246  /// Data member is mandatory;
247  /// its type is defined as 'typedef NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_Data > > Tdata'
248  /// @return
249  /// - true, if a value has been assigned.
250  /// - false, otherwise.
251  bool IsSet(void) const;
252 
253  /// Check if it is safe to call Get method.
254  ///
255  /// @return
256  /// - true, if the data member is getatable.
257  /// - false, otherwise.
258  bool CanGet(void) const;
259 
260  /// Reset data member.
261  void Reset(void);
262 
263  /// Get the member data.
264  ///
265  /// @return
266  /// Reference to the member data.
267  const Tdata& Get(void) const;
268 
269  /// Assign a value to data member.
270  ///
271  /// @return
272  /// Reference to the data value.
273  Tdata& Set(void);
274 
275  /// Conversion operator to 'const Tdata' type.
276  operator const Tdata& (void) const;
277  /// Conversion operator to 'Tdata' type.
278  operator Tdata& (void);
279 
280 
281 
282 private:
283  // Prohibit copy constructor and assignment operator
286 
287  // data
288  Uint4 m_set_State[1];
289  NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_Data > > m_data;
290 };
291 
292 /* @} */
293 
294 
295 
296 
297 
298 ///////////////////////////////////////////////////////////
299 ///////////////////// inline methods //////////////////////
300 ///////////////////////////////////////////////////////////
301 inline
303 {
304  return m_choice;
305 }
306 
307 inline
309 {
310  if ( m_choice != index )
311  ThrowInvalidSelection(index);
312 }
313 
314 inline
315 void CSpelledQuery_Base::C_Data::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
316 {
317  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
318  if ( m_choice != e_not_set )
319  ResetSelection();
320  DoSelect(index, pool);
321  }
322 }
323 
324 inline
326 {
327  Select(index, reset, 0);
328 }
329 
330 inline
332 {
333  return m_choice == e_Replaced;
334 }
335 
336 inline
338 {
339  CheckSelected(e_Replaced);
340  return *m_string;
341 }
342 
343 inline
345 {
346  Select(e_Replaced, NCBI_NS_NCBI::eDoNotResetVariant);
347  return *m_string;
348 }
349 
350 inline
352 {
353  return m_choice == e_Original;
354 }
355 
356 inline
358 {
359  CheckSelected(e_Original);
360  return *m_string;
361 }
362 
363 inline
365 {
366  Select(e_Original, NCBI_NS_NCBI::eDoNotResetVariant);
367  return *m_string;
368 }
369 
370 inline
372 {
373  return ((m_set_State[0] & 0x3) != 0);
374 }
375 
376 inline
378 {
379  return true;
380 }
381 
382 inline
384 {
385  return m_data;
386 }
387 
388 inline
390 {
391  m_set_State[0] |= 0x1;
392  return m_data;
393 }
394 
395 inline
396 CSpelledQuery_Base::operator const CSpelledQuery_Base::Tdata& (void) const
397 {
398  return m_data;
399 }
400 
401 inline
402 CSpelledQuery_Base::operator CSpelledQuery_Base::Tdata& (void)
403 {
404  m_set_State[0] |= 0x1;
405  return m_data;
406 }
407 
408 ///////////////////////////////////////////////////////////
409 ////////////////// end of inline methods //////////////////
410 ///////////////////////////////////////////////////////////
411 
412 
413 
414 
415 
416 END_espell_SCOPE // namespace espell::
417 
418 
419 #endif // espell__OBJTOOLS_EUTILS_ESPELL_SPELLEDQUERY_BASE_HPP
#define END_espell_SCOPE
#define BEGIN_espell_SCOPE
CSpelledQuery_Base –.
string
Definition: cgiapp.hpp:690
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define NCBI_EUTILS_EXPORT
Definition: ncbi_export.h:1460
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
CSpelledQuery_Base(const CSpelledQuery_Base &)
bool CanGet(void) const
Check if it is safe to call Get method.
const TOriginal & GetOriginal(void) const
Get the variant data.
bool IsSet(void) const
Check if a value has been assigned to data member.
C_Data & operator=(const C_Data &)
const TReplaced & GetReplaced(void) const
Get the variant data.
NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_Data > > Tdata
TReplaced & SetReplaced(void)
Select the variant.
CSpelledQuery_Base & operator=(const CSpelledQuery_Base &)
NCBI_NS_NCBI::CSerialObject Tparent
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
E_Choice Which(void) const
Which variant is currently selected.
NCBI_NS_STD::string TOriginal
NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_Data > > m_data
bool IsOriginal(void) const
Check if variant Original is selected.
const Tdata & Get(void) const
Get the member data.
TOriginal & SetOriginal(void)
Select the variant.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Tdata & Set(void)
Assign a value to data member.
NCBI_NS_STD::string TReplaced
bool IsReplaced(void) const
Check if variant Replaced is selected.
NCBI_NS_NCBI::CSerialObject Tparent
@ e_not_set
const TYPE & Get(const CNamedParameterList *param)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:13 2024 by modify_doxy.py rev. 669887