NCBI C++ ToolKit
item.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef ITEM__HPP
2 #define ITEM__HPP
3 
4 /* $Id: item.hpp 79700 2017-10-04 15:45:27Z gouriano $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * !!! PUT YOUR DESCRIPTION HERE !!!
33 */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <serial/serialutil.hpp>
37 #include <serial/impl/typeref.hpp>
38 #include <serial/impl/memberid.hpp>
39 #include <serial/impl/objstack.hpp>
40 
41 
42 /** @addtogroup FieldsComplex
43  *
44  * @{
45  */
46 
47 
49 
50 class CItemsInfo;
51 class CSerialFacet;
52 
54 {
55 public:
56  enum {
57  eNoOffset = -1
58  };
59 
61  TTypeInfo type);
63  const CTypeRef& type);
64  CItemInfo(const char* id, TPointerOffsetType offset,
65  TTypeInfo type);
66  CItemInfo(const char* id, TPointerOffsetType offset,
67  const CTypeRef& type);
68  virtual ~CItemInfo(void);
69 
70  const CMemberId& GetId(void) const;
71  CMemberId& GetId(void);
72 
73  TMemberIndex GetIndex(void) const;
74 
76 
77  TTypeInfo GetTypeInfo(void) const;
78 
80  TObjectPtr classPtr) const = 0;
81 
84 
85  bool NonEmpty(void) const;
86  CItemInfo* SetNonEmpty(void);
87 
88  bool Optional(void) const;
89 
90  void Validate(TConstObjectPtr classPtr, const CObjectStack& stk) const;
91 
92  CItemInfo* Restrict( ESerialFacet type, const string& pattern);
93  CItemInfo* Restrict( ESerialFacet type, Uint8 value);
94  CItemInfo* RestrictI(ESerialFacet type, Int8 value);
95  CItemInfo* RestrictD(ESerialFacet type, double value);
96 
97  template<typename T>
99  static_assert(is_integral<T>::value || is_floating_point<T>::value, "Wrong data type");
101  return RestrictI(type, (Int8)value);
102  }
104  return Restrict(type, (Uint8)value);
105  }
107  return RestrictD(type, (double)value);
108  }
109  _ASSERT(0);
110  return nullptr;
111  }
112 
113 private:
114  friend class CItemsInfo;
115  virtual void UpdateFunctions(void) = 0;
116 
117  // member ID
119  // member index
121  // offset of member inside object
123  // type of member
125 
127 protected:
130 };
131 
132 class CConstObjectInfo;
134 {
135 public:
136  CSerialFacet(void);
137  virtual ~CSerialFacet(void);
138  void Validate(TTypeInfo info, TConstObjectPtr object, const CObjectStack& stk) const;
139  virtual void Validate(const CConstObjectInfo& oi, const CObjectStack& stk) const = 0;
140 };
141 
142 /* @} */
143 
144 
145 #include <serial/impl/item.inl>
146 
148 
149 #endif /* ITEM__HPP */
CConstObjectInfo –.
Definition: objectinfo.hpp:421
CObjectIStream –.
Definition: objistr.hpp:93
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define T(s)
Definition: common.h:230
int offset
Definition: replacements.h:160
bool Optional(void) const
virtual void UpdateDelayedBuffer(CObjectIStream &in, TObjectPtr classPtr) const =0
bool m_Optional
Definition: item.hpp:128
const CMemberId & GetId(void) const
CMemberId & GetId(void)
CMemberId m_Id
Definition: item.hpp:118
virtual void Validate(const CConstObjectInfo &oi, const CObjectStack &stk) const =0
TObjectPtr GetItemPtr(TObjectPtr object) const
TPointerOffsetType m_Offset
Definition: item.hpp:122
bool m_NonEmpty
Definition: item.hpp:126
CTypeRef m_Type
Definition: item.hpp:124
TMemberIndex m_Index
Definition: item.hpp:120
virtual void UpdateFunctions(void)=0
TMemberIndex GetIndex(void) const
CItemInfo * RestrictV(ESerialFacet type, T value)
Definition: item.hpp:98
TConstObjectPtr GetItemPtr(TConstObjectPtr object) const
TPointerOffsetType GetOffset(void) const
TTypeInfo GetTypeInfo(void) const
const CSerialFacet * m_Restrict
Definition: item.hpp:129
bool NonEmpty(void) const
void Validate(TConstObjectPtr classPtr, const CObjectStack &stk) const
void * TObjectPtr
Definition: serialdef.hpp:55
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
ESerialFacet
Definition: serialdef.hpp:212
const void * TConstObjectPtr
Definition: serialdef.hpp:59
ssize_t TPointerOffsetType
Definition: serialdef.hpp:241
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
std::istream & in(std::istream &in_, double &x_)
Definition: type.c:6
#define _ASSERT
Modified on Fri Sep 20 14:58:16 2024 by modify_doxy.py rev. 669887