NCBI C++ ToolKit
Search_func_.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 Search_func_.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/objects/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.def">macro.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 OBJECTS_MACRO_SEARCH_FUNC_BASE_HPP
42 #define OBJECTS_MACRO_SEARCH_FUNC_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
49 
51 
52 #ifndef BEGIN_objects_SCOPE
53 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
54 # define END_objects_SCOPE END_SCOPE(objects)
55 #endif
56 BEGIN_objects_SCOPE // namespace ncbi::objects::
57 
58 
59 // forward declarations
60 class CString_constraint;
61 
62 
63 // generated classes
64 
65 
66 /** @addtogroup dataspec_NCBI_Macro
67  *
68  * @{
69  */
70 
71 /////////////////////////////////////////////////////////////////////////////
72 ///
73 /// CSearch_func_Base --
74 ///
75 
77 {
79 public:
80  // constructor
81  CSearch_func_Base(void);
82  // destructor
83  virtual ~CSearch_func_Base(void);
84 
85  // type info
87 
88 
89  /// Choice variants.
90  enum E_Choice {
91  e_not_set = 0, ///< No variant selected
101  e_Has_term
102  };
103  /// Maximum+1 value of the choice variant enumerator.
105  e_MaxChoice = 11 ///< == e_Has_term+1
106  };
107 
108  /// Reset the whole object
109  virtual void Reset(void);
110 
111  /// Reset the selection (set it to e_not_set).
112  virtual void ResetSelection(void);
113 
114  /// Which variant is currently selected.
115  ///
116  /// @return
117  /// Choice state enumerator.
118  E_Choice Which(void) const;
119 
120  /// Verify selection, throw exception if it differs from the expected.
121  ///
122  /// @param index
123  /// Expected selection.
124  void CheckSelected(E_Choice index) const;
125 
126  /// Throw 'InvalidSelection' exception.
127  ///
128  /// @param index
129  /// Expected selection.
130  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
131 
132  /// Retrieve selection name (for diagnostic purposes).
133  ///
134  /// @param index
135  /// One of possible selection states.
136  /// @return
137  /// Name string.
138  static string SelectionName(E_Choice index);
139 
140  /// Select the requested variant if needed.
141  ///
142  /// @param index
143  /// New selection state.
144  /// @param reset
145  /// Flag that defines the resetting of the variant data. The data will
146  /// be reset if either the current selection differs from the new one,
147  /// or the flag is set to eDoResetVariant.
149  /// Select the requested variant if needed,
150  /// allocating CObject variants from memory pool.
151  void Select(E_Choice index,
152  EResetVariant reset,
153  CObjectMemoryPool* pool);
154 
155  // types
158  typedef string TPrefix_and_numbers;
159  typedef int TToo_long;
160  typedef string THas_term;
161 
162  // getters
163  // setters
164 
165 
166  /// Check if variant String_constraint is selected.
167  ///
168  /// String_constraint type is defined as 'typedef CString_constraint TString_constraint'.
169  /// @return
170  /// - true, if the variant is selected.
171  /// - false, otherwise.
172  bool IsString_constraint(void) const;
173 
174  /// Get the variant data.
175  ///
176  /// @return
177  /// Reference to the data.
178  const TString_constraint& GetString_constraint(void) const;
179 
180  /// Select the variant.
181  ///
182  /// @return
183  /// Reference to the variant data.
185  /// Select the variant and set its data.
186  ///
187  /// @param value
188  /// Reference to the data.
190 
191 
192  /// Check if variant Contains_plural is selected.
193  ///
194  /// @return
195  /// - true, if the variant is selected.
196  /// - false, otherwise.
197  bool IsContains_plural(void) const;
198 
199  /// Select the variant.
200  void SetContains_plural(void);
201 
202 
203  /// Check if variant N_or_more_brackets_or_parentheses is selected.
204  ///
205  /// N_or_more_brackets_or_parentheses type is defined as 'typedef int TN_or_more_brackets_or_parentheses'.
206  /// @return
207  /// - true, if the variant is selected.
208  /// - false, otherwise.
209  bool IsN_or_more_brackets_or_parentheses(void) const;
210 
211  /// Get the variant data.
212  ///
213  /// @return
214  /// Copy of the variant data.
216 
217  /// Select the variant.
218  ///
219  /// @return
220  /// Reference to the variant data.
222 
223  /// Select the variant and set its data.
224  ///
225  /// @param value
226  /// Variant data.
228 
229 
230  /// Check if variant Three_numbers is selected.
231  ///
232  /// @return
233  /// - true, if the variant is selected.
234  /// - false, otherwise.
235  bool IsThree_numbers(void) const;
236 
237  /// Select the variant.
238  void SetThree_numbers(void);
239 
240 
241  /// Check if variant Underscore is selected.
242  ///
243  /// @return
244  /// - true, if the variant is selected.
245  /// - false, otherwise.
246  bool IsUnderscore(void) const;
247 
248  /// Select the variant.
249  void SetUnderscore(void);
250 
251 
252  /// Check if variant Prefix_and_numbers is selected.
253  ///
254  /// Prefix_and_numbers type is defined as 'typedef string TPrefix_and_numbers'.
255  /// @return
256  /// - true, if the variant is selected.
257  /// - false, otherwise.
258  bool IsPrefix_and_numbers(void) const;
259 
260  /// Get the variant data.
261  ///
262  /// @return
263  /// Reference to the data.
264  const TPrefix_and_numbers& GetPrefix_and_numbers(void) const;
265 
266  /// Select the variant.
267  ///
268  /// @return
269  /// Reference to the variant data.
271 
272  /// Select the variant and set its data.
273  ///
274  /// @param value
275  /// Variant data.
277 
278 
279  /// Check if variant All_caps is selected.
280  ///
281  /// @return
282  /// - true, if the variant is selected.
283  /// - false, otherwise.
284  bool IsAll_caps(void) const;
285 
286  /// Select the variant.
287  void SetAll_caps(void);
288 
289 
290  /// Check if variant Unbalanced_paren is selected.
291  ///
292  /// @return
293  /// - true, if the variant is selected.
294  /// - false, otherwise.
295  bool IsUnbalanced_paren(void) const;
296 
297  /// Select the variant.
298  void SetUnbalanced_paren(void);
299 
300 
301  /// Check if variant Too_long is selected.
302  ///
303  /// Too_long type is defined as 'typedef int TToo_long'.
304  /// @return
305  /// - true, if the variant is selected.
306  /// - false, otherwise.
307  bool IsToo_long(void) const;
308 
309  /// Get the variant data.
310  ///
311  /// @return
312  /// Copy of the variant data.
313  TToo_long GetToo_long(void) const;
314 
315  /// Select the variant.
316  ///
317  /// @return
318  /// Reference to the variant data.
319  TToo_long& SetToo_long(void);
320 
321  /// Select the variant and set its data.
322  ///
323  /// @param value
324  /// Variant data.
326 
327 
328  /// Check if variant Has_term is selected.
329  ///
330  /// Has_term type is defined as 'typedef string THas_term'.
331  /// @return
332  /// - true, if the variant is selected.
333  /// - false, otherwise.
334  bool IsHas_term(void) const;
335 
336  /// Get the variant data.
337  ///
338  /// @return
339  /// Reference to the data.
340  const THas_term& GetHas_term(void) const;
341 
342  /// Select the variant.
343  ///
344  /// @return
345  /// Reference to the variant data.
346  THas_term& SetHas_term(void);
347 
348  /// Select the variant and set its data.
349  ///
350  /// @param value
351  /// Variant data.
352  void SetHas_term(const THas_term& value);
353 
354 
355 private:
356  // copy constructor and assignment operator
359  // choice state
361  // helper methods
362  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
363 
364  static const char* const sm_SelectionNames[];
365  // data
366  union {
369  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
370  NCBI_NS_NCBI::CSerialObject *m_object;
371  };
372 };
373 
374 /* @} */
375 
376 
377 
378 
379 
380 ///////////////////////////////////////////////////////////
381 ///////////////////// inline methods //////////////////////
382 ///////////////////////////////////////////////////////////
383 inline
385 {
386  return m_choice;
387 }
388 
389 inline
391 {
392  if ( m_choice != index )
393  ThrowInvalidSelection(index);
394 }
395 
396 inline
397 void CSearch_func_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
398 {
399  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
400  if ( m_choice != e_not_set )
401  ResetSelection();
402  DoSelect(index, pool);
403  }
404 }
405 
406 inline
407 void CSearch_func_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
408 {
409  Select(index, reset, 0);
410 }
411 
412 inline
414 {
415  return m_choice == e_String_constraint;
416 }
417 
418 inline
420 {
421  return m_choice == e_Contains_plural;
422 }
423 
424 inline
426 {
428 }
429 
430 inline
432 {
434 }
435 
436 inline
438 {
441 }
442 
443 inline
445 {
448 }
449 
450 inline
452 {
455 }
456 
457 inline
459 {
460  return m_choice == e_Three_numbers;
461 }
462 
463 inline
465 {
467 }
468 
469 inline
471 {
472  return m_choice == e_Underscore;
473 }
474 
475 inline
477 {
479 }
480 
481 inline
483 {
484  return m_choice == e_Prefix_and_numbers;
485 }
486 
487 inline
489 {
491  return *m_string;
492 }
493 
494 inline
496 {
498  return *m_string;
499 }
500 
501 inline
503 {
504  return m_choice == e_All_caps;
505 }
506 
507 inline
509 {
511 }
512 
513 inline
515 {
516  return m_choice == e_Unbalanced_paren;
517 }
518 
519 inline
521 {
523 }
524 
525 inline
527 {
528  return m_choice == e_Too_long;
529 }
530 
531 inline
533 {
535  return m_Too_long;
536 }
537 
538 inline
540 {
542  return m_Too_long;
543 }
544 
545 inline
547 {
549  m_Too_long = value;
550 }
551 
552 inline
554 {
555  return m_choice == e_Has_term;
556 }
557 
558 inline
560 {
562  return *m_string;
563 }
564 
565 inline
567 {
569  return *m_string;
570 }
571 
572 ///////////////////////////////////////////////////////////
573 ////////////////// end of inline methods //////////////////
574 ///////////////////////////////////////////////////////////
575 
576 
577 
578 
579 
580 END_objects_SCOPE // namespace ncbi::objects::
581 
583 
584 
585 #endif // OBJECTS_MACRO_SEARCH_FUNC_BASE_HPP
CSearch_func_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CSerialObject Tparent
TToo_long GetToo_long(void) const
Get the variant data.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
TN_or_more_brackets_or_parentheses m_N_or_more_brackets_or_parentheses
bool IsPrefix_and_numbers(void) const
Check if variant Prefix_and_numbers is selected.
THas_term & SetHas_term(void)
Select the variant.
void SetThree_numbers(void)
Select the variant.
bool IsThree_numbers(void) const
Check if variant Three_numbers is selected.
NCBI_NS_NCBI::CSerialObject * m_object
static const char *const sm_SelectionNames[]
virtual ~CSearch_func_Base(void)
bool IsString_constraint(void) const
Check if variant String_constraint is selected.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
E_Choice
Choice variants.
bool IsToo_long(void) const
Check if variant Too_long is selected.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void SetUnbalanced_paren(void)
Select the variant.
const TPrefix_and_numbers & GetPrefix_and_numbers(void) const
Get the variant data.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
bool IsN_or_more_brackets_or_parentheses(void) const
Check if variant N_or_more_brackets_or_parentheses is selected.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
CSearch_func_Base & operator=(const CSearch_func_Base &)
bool IsHas_term(void) const
Check if variant Has_term is selected.
CSearch_func_Base(const CSearch_func_Base &)
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
bool IsContains_plural(void) const
Check if variant Contains_plural is selected.
void SetUnderscore(void)
Select the variant.
CString_constraint TString_constraint
TPrefix_and_numbers & SetPrefix_and_numbers(void)
Select the variant.
void SetAll_caps(void)
Select the variant.
TN_or_more_brackets_or_parentheses GetN_or_more_brackets_or_parentheses(void) const
Get the variant data.
TN_or_more_brackets_or_parentheses & SetN_or_more_brackets_or_parentheses(void)
Select the variant.
const THas_term & GetHas_term(void) const
Get the variant data.
bool IsUnderscore(void) const
Check if variant Underscore is selected.
bool IsUnbalanced_paren(void) const
Check if variant Unbalanced_paren is selected.
TToo_long & SetToo_long(void)
Select the variant.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
TN_or_more_brackets_or_parentheses m_N_or_more_brackets_or_parentheses
void SetContains_plural(void)
Select the variant.
TString_constraint & SetString_constraint(void)
Select the variant.
const TString_constraint & GetString_constraint(void) const
Get the variant data.
virtual void Reset(void)
Reset the whole object.
E_Choice Which(void) const
Which variant is currently selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
int TN_or_more_brackets_or_parentheses
bool IsAll_caps(void) const
Check if variant All_caps is selected.
@ e_not_set
No variant selected.
@ e_N_or_more_brackets_or_parentheses
@ e_MaxChoice
== e_Has_term+1
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Jun 19 17:00:24 2024 by modify_doxy.py rev. 669887