NCBI C++ ToolKit
PlistObject_.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 PlistObject_.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/build-system/project_tree_builder/property_list.xsd">property_list.xsd</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/build-system/project_tree_builder/property_list.def">property_list.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 BUILD_SYSTEM_PROJECT_TREE_BUILDER_PLISTOBJECT_BASE_HPP
42 #define BUILD_SYSTEM_PROJECT_TREE_BUILDER_PLISTOBJECT_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
49 #include <vector>
50 
52 
53 #ifndef BEGIN_objects_SCOPE
54 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
55 # define END_objects_SCOPE END_SCOPE(objects)
56 #endif
57 BEGIN_objects_SCOPE // namespace ncbi::objects::
58 
59 
60 // forward declarations
61 class CArray;
62 class CDict;
63 
64 
65 // generated classes
66 
67 
68 /** @addtogroup dataspec_property_list
69  *
70  * @{
71  */
72 
73 /////////////////////////////////////////////////////////////////////////////
74 ///
75 /// CPlistObject_Base --
76 ///
77 
79 {
81 public:
82  // constructor
83  CPlistObject_Base(void);
84  // destructor
85  virtual ~CPlistObject_Base(void);
86 
87  // type info
89 
90 
91  /// Choice variants.
92  enum E_Choice {
93  e_not_set = 0, ///< No variant selected
95  e_Data, ///< Contents interpreted as Base-64 encoded
96  e_Date, ///< Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. Smaller units may be omitted with a loss of precision)
98  e_Real, ///< Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | "-") d+)? where d is a digit 0-9.
99  e_Integer, ///< Contents should represent a (possibly signed) integer number in base 10
100  e_String, ///<- Primitive types
101  e_True, ///< Boolean constant true
102  e_False ///< Boolean constant false
103  };
104  /// Maximum+1 value of the choice variant enumerator.
106  e_MaxChoice = 10 ///< == e_False+1
107  };
108 
109  /// Reset the whole object
110  virtual void Reset(void);
111 
112  /// Reset the selection (set it to e_not_set).
113  virtual void ResetSelection(void);
114 
115  /// Which variant is currently selected.
116  ///
117  /// @return
118  /// Choice state enumerator.
119  E_Choice Which(void) const;
120 
121  /// Verify selection, throw exception if it differs from the expected.
122  ///
123  /// @param index
124  /// Expected selection.
125  void CheckSelected(E_Choice index) const;
126 
127  /// Throw 'InvalidSelection' exception.
128  ///
129  /// @param index
130  /// Expected selection.
131  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
132 
133  /// Retrieve selection name (for diagnostic purposes).
134  ///
135  /// @param index
136  /// One of possible selection states.
137  /// @return
138  /// Name string.
139  static string SelectionName(E_Choice index);
140 
141  /// Select the requested variant if needed.
142  ///
143  /// @param index
144  /// New selection state.
145  /// @param reset
146  /// Flag that defines the resetting of the variant data. The data will
147  /// be reset if either the current selection differs from the new one,
148  /// or the flag is set to eDoResetVariant.
150  /// Select the requested variant if needed,
151  /// allocating CObject variants from memory pool.
152  void Select(E_Choice index,
153  EResetVariant reset,
154  CObjectMemoryPool* pool);
155 
156  // types
157  typedef CArray TArray;
158  typedef vector< char > TData;
159  typedef string TDate;
160  typedef CDict TDict;
161  typedef double TReal;
162  typedef int TInteger;
163  typedef string TString;
164 
165  // getters
166  // setters
167 
168 
169  /// Check if variant Array is selected.
170  ///
171  /// Array type is defined as 'typedef CArray TArray'.
172  /// @return
173  /// - true, if the variant is selected.
174  /// - false, otherwise.
175  bool IsArray(void) const;
176 
177  /// Get the variant data.
178  ///
179  /// @return
180  /// Reference to the data.
181  const TArray& GetArray(void) const;
182 
183  /// Select the variant.
184  ///
185  /// @return
186  /// Reference to the variant data.
187  TArray& SetArray(void);
188  /// Select the variant and set its data.
189  ///
190  /// @param value
191  /// Reference to the data.
192  void SetArray(TArray& value);
193 
194 
195  /// Check if variant Data is selected.
196  ///
197  /// Data type is defined as 'typedef vector< char > TData'.
198  /// @return
199  /// - true, if the variant is selected.
200  /// - false, otherwise.
201  bool IsData(void) const;
202 
203  /// Get the variant data.
204  ///
205  /// @return
206  /// Reference to the data.
207  const TData& GetData(void) const;
208 
209  /// Select the variant.
210  ///
211  /// @return
212  /// Reference to the variant data.
213  TData& SetData(void);
214 
215 
216  /// Check if variant Date is selected.
217  ///
218  /// Date type is defined as 'typedef string TDate'.
219  /// @return
220  /// - true, if the variant is selected.
221  /// - false, otherwise.
222  bool IsDate(void) const;
223 
224  /// Get the variant data.
225  ///
226  /// @return
227  /// Reference to the data.
228  const TDate& GetDate(void) const;
229 
230  /// Select the variant.
231  ///
232  /// @return
233  /// Reference to the variant data.
234  TDate& SetDate(void);
235 
236  /// Select the variant and set its data.
237  ///
238  /// @param value
239  /// Variant data.
240  void SetDate(const TDate& value);
241 
242 
243  /// Check if variant Dict is selected.
244  ///
245  /// Dict type is defined as 'typedef CDict TDict'.
246  /// @return
247  /// - true, if the variant is selected.
248  /// - false, otherwise.
249  bool IsDict(void) const;
250 
251  /// Get the variant data.
252  ///
253  /// @return
254  /// Reference to the data.
255  const TDict& GetDict(void) const;
256 
257  /// Select the variant.
258  ///
259  /// @return
260  /// Reference to the variant data.
261  TDict& SetDict(void);
262  /// Select the variant and set its data.
263  ///
264  /// @param value
265  /// Reference to the data.
266  void SetDict(TDict& value);
267 
268 
269  /// Check if variant Real is selected.
270  ///
271  /// Real type is defined as 'typedef double TReal'.
272  /// @return
273  /// - true, if the variant is selected.
274  /// - false, otherwise.
275  bool IsReal(void) const;
276 
277  /// Get the variant data.
278  ///
279  /// @return
280  /// Copy of the variant data.
281  TReal GetReal(void) const;
282 
283  /// Select the variant.
284  ///
285  /// @return
286  /// Reference to the variant data.
287  TReal& SetReal(void);
288 
289  /// Select the variant and set its data.
290  ///
291  /// @param value
292  /// Variant data.
293  void SetReal(TReal value);
294 
295 
296  /// Check if variant Integer is selected.
297  ///
298  /// Integer type is defined as 'typedef int TInteger'.
299  /// @return
300  /// - true, if the variant is selected.
301  /// - false, otherwise.
302  bool IsInteger(void) const;
303 
304  /// Get the variant data.
305  ///
306  /// @return
307  /// Copy of the variant data.
308  TInteger GetInteger(void) const;
309 
310  /// Select the variant.
311  ///
312  /// @return
313  /// Reference to the variant data.
314  TInteger& SetInteger(void);
315 
316  /// Select the variant and set its data.
317  ///
318  /// @param value
319  /// Variant data.
320  void SetInteger(TInteger value);
321 
322 
323  /// Check if variant String is selected.
324  ///
325  /// String type is defined as 'typedef string TString'.
326  /// @return
327  /// - true, if the variant is selected.
328  /// - false, otherwise.
329  bool IsString(void) const;
330 
331  /// Get the variant data.
332  ///
333  /// @return
334  /// Reference to the data.
335  const TString& GetString(void) const;
336 
337  /// Select the variant.
338  ///
339  /// @return
340  /// Reference to the variant data.
341  TString& SetString(void);
342 
343  /// Select the variant and set its data.
344  ///
345  /// @param value
346  /// Variant data.
347  void SetString(const TString& value);
348 
349 
350  /// Check if variant True is selected.
351  ///
352  /// @return
353  /// - true, if the variant is selected.
354  /// - false, otherwise.
355  bool IsTrue(void) const;
356 
357  /// Select the variant.
358  void SetTrue(void);
359 
360 
361  /// Check if variant False is selected.
362  ///
363  /// @return
364  /// - true, if the variant is selected.
365  /// - false, otherwise.
366  bool IsFalse(void) const;
367 
368  /// Select the variant.
369  void SetFalse(void);
370 
371 
372 private:
373  // copy constructor and assignment operator
376  // choice state
378  // helper methods
379  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
380 
381  static const char* const sm_SelectionNames[];
382  // data
383  union {
384  NCBI_NS_NCBI::CUnionBuffer<TData> m_Data;
387  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
388  NCBI_NS_NCBI::CSerialObject *m_object;
389  };
390 };
391 
392 /* @} */
393 
394 
395 
396 
397 
398 ///////////////////////////////////////////////////////////
399 ///////////////////// inline methods //////////////////////
400 ///////////////////////////////////////////////////////////
401 inline
403 {
404  return m_choice;
405 }
406 
407 inline
409 {
410  if ( m_choice != index )
411  ThrowInvalidSelection(index);
412 }
413 
414 inline
415 void CPlistObject_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
416 {
417  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
418  if ( m_choice != e_not_set )
419  ResetSelection();
420  DoSelect(index, pool);
421  }
422 }
423 
424 inline
425 void CPlistObject_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
426 {
427  Select(index, reset, 0);
428 }
429 
430 inline
432 {
433  return m_choice == e_Array;
434 }
435 
436 inline
438 {
439  return m_choice == e_Data;
440 }
441 
442 inline
444 {
446  return *m_Data;
447 }
448 
449 inline
451 {
453  return *m_Data;
454 }
455 
456 inline
458 {
459  return m_choice == e_Date;
460 }
461 
462 inline
464 {
466  return *m_string;
467 }
468 
469 inline
471 {
473  return *m_string;
474 }
475 
476 inline
478 {
479  return m_choice == e_Dict;
480 }
481 
482 inline
484 {
485  return m_choice == e_Real;
486 }
487 
488 inline
490 {
492  return m_Real;
493 }
494 
495 inline
497 {
499  return m_Real;
500 }
501 
502 inline
504 {
506  m_Real = value;
507 }
508 
509 inline
511 {
512  return m_choice == e_Integer;
513 }
514 
515 inline
517 {
519  return m_Integer;
520 }
521 
522 inline
524 {
526  return m_Integer;
527 }
528 
529 inline
531 {
533  m_Integer = value;
534 }
535 
536 inline
538 {
539  return m_choice == e_String;
540 }
541 
542 inline
544 {
546  return *m_string;
547 }
548 
549 inline
551 {
553  return *m_string;
554 }
555 
556 inline
558 {
559  return m_choice == e_True;
560 }
561 
562 inline
564 {
566 }
567 
568 inline
570 {
571  return m_choice == e_False;
572 }
573 
574 inline
576 {
578 }
579 
580 ///////////////////////////////////////////////////////////
581 ////////////////// end of inline methods //////////////////
582 ///////////////////////////////////////////////////////////
583 
584 
585 
586 
587 
588 END_objects_SCOPE // namespace ncbi::objects::
589 
591 
592 
593 #endif // BUILD_SYSTEM_PROJECT_TREE_BUILDER_PLISTOBJECT_BASE_HPP
CArray –.
Definition: Array.hpp:66
CDict –.
Definition: Dict.hpp:66
CPlistObject_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
TData & SetData(void)
Select the variant.
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< TData > m_Data
TInteger & SetInteger(void)
Select the variant.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
void SetTrue(void)
Select the variant.
TReal GetReal(void) const
Get the variant data.
TDate & SetDate(void)
Select the variant.
CPlistObject_Base(const CPlistObject_Base &)
bool IsInteger(void) const
Check if variant Integer is selected.
bool IsArray(void) const
Check if variant Array is selected.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
static const char *const sm_SelectionNames[]
bool IsReal(void) const
Check if variant Real is selected.
TInteger GetInteger(void) const
Get the variant data.
bool IsString(void) const
Check if variant String is selected.
const TString & GetString(void) const
Get the variant data.
bool IsTrue(void) const
Check if variant True is selected.
bool IsDate(void) const
Check if variant Date is selected.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
virtual void Reset(void)
Reset the whole object.
bool IsDict(void) const
Check if variant Dict is selected.
TArray & SetArray(void)
Select the variant.
const TData & GetData(void) const
Get the variant data.
NCBI_NS_NCBI::CSerialObject * m_object
E_Choice
Choice variants.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
E_Choice Which(void) const
Which variant is currently selected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
virtual ~CPlistObject_Base(void)
TDict & SetDict(void)
Select the variant.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
NCBI_NS_NCBI::CUnionBuffer< TData > m_Data
const TDict & GetDict(void) const
Get the variant data.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void SetFalse(void)
Select the variant.
bool IsData(void) const
Check if variant Data is selected.
CSerialObject Tparent
CPlistObject_Base & operator=(const CPlistObject_Base &)
bool IsFalse(void) const
Check if variant False is selected.
const TDate & GetDate(void) const
Get the variant data.
TString & SetString(void)
Select the variant.
const TArray & GetArray(void) const
Get the variant data.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
TReal & SetReal(void)
Select the variant.
vector< char > TData
@ e_True
Boolean constant true.
@ e_Real
Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)?...
@ e_Date
Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' ...
@ e_not_set
No variant selected.
@ e_Integer
Contents should represent a (possibly signed) integer number in base 10.
@ e_False
Boolean constant false.
@ e_Data
Contents interpreted as Base-64 encoded.
@ e_MaxChoice
== e_False+1
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:19 2024 by modify_doxy.py rev. 669887