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

Go to the SVN repository for this file.

1 #ifndef BLOCKTYPE_HPP
2 #define BLOCKTYPE_HPP
3 
4 /* $Id: blocktype.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 * Type description of compound types: SET, SEQUENCE and CHOICE
33 *
34 */
35 
36 #include "type.hpp"
37 #include <list>
38 
40 
41 class CClassTypeInfo;
42 
43 class CDataMember {
44 public:
45  CDataMember(const string& name, const AutoPtr<CDataType>& type);
46  ~CDataMember(void);
47 
48  void PrintASN(CNcbiOstream& out, int indent, bool last) const;
49  void PrintSpecDump(CNcbiOstream& out, int indent, const char* tag) const;
50  void PrintJSONSchema(CNcbiOstream& out, int indent, list<string>& required, bool contents_only=false) const;
51  void PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only=false) const;
52  void PrintDTD(CNcbiOstream& out) const;
53 
54  bool Check(void) const;
55 
56  const string& GetName(void) const
57  {
58  return m_Name;
59  }
61  {
62  return m_Type.get();
63  }
64  const CDataType* GetType(void) const
65  {
66  return m_Type.get();
67  }
68  bool Optional(void) const
69  {
70  return m_NoPrefix ? m_Optional : (m_Optional || m_Default);
71  }
72  bool NoPrefix(void) const
73  {
74  return m_NoPrefix;
75  }
76  bool Attlist(void) const
77  {
78  return m_Attlist;
79  }
80  bool Notag(void) const
81  {
82  return m_Notag;
83  }
84  bool SimpleType(void) const
85  {
86  return m_SimpleType;
87  }
88  const CDataValue* GetDefault(void) const
89  {
90  return m_Default.get();
91  }
92  bool Nillable(void) const
93  {
94  return m_Nillable;
95  }
96 
97  void SetOptional(void);
98  void SetNoPrefix(void);
99  void SetAttlist(void);
100  void SetNotag(void);
101  void SetSimpleType(void);
102  void SetDefault(const AutoPtr<CDataValue>& value);
103  void SetNillable(void);
104 
106  {
107  return m_Comments;
108  }
109  const CComments& GetComments(void) const
110  {
111  return m_Comments;
112  }
113  void SetRestrictions(const list<CMemberFacet>& c) {
114  m_Restrictions = c;
115  }
116  const list<CMemberFacet>& GetRestrictions(void) const {
117  return m_Restrictions;
118  }
119 
120 private:
121  string m_Name;
125  bool m_Attlist;
126  bool m_Notag;
131  list<CMemberFacet> m_Restrictions;
132 };
133 
136 public:
137  typedef list< AutoPtr<CDataMember> > TMembers;
138 
139  virtual void PrintASN(CNcbiOstream& out, int indent) const override;
140  virtual void PrintSpecDumpExtra(CNcbiOstream& out, int indent) const override;
141  virtual void PrintJSONSchema(CNcbiOstream& out, int indent, list<string>& required, bool contents_only=false) const override;
142  virtual void PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only=false) const override;
143  virtual void PrintDTDElement(CNcbiOstream& out, bool contents_only=false) const override;
144  virtual void PrintDTDExtra(CNcbiOstream& out) const override;
145 
146  virtual void FixTypeTree(void) const override;
147  virtual bool CheckType(void) const override;
148 
149  void AddMember(const AutoPtr<CDataMember>& member);
150 
151  virtual TObjectPtr CreateDefault(const CDataValue& value) const override;
152 
153  virtual const char* XmlMemberSeparator(void) const = 0;
154 
155  const TMembers& GetMembers(void) const
156  {
157  return m_Members;
158  }
159 
161  {
162  return m_LastComments;
163  }
164  bool UniElementNameExists(const string& name) const;
165 
166 protected:
169 };
170 
173 public:
174  virtual CTypeInfo* CreateTypeInfo(void) override;
175 
176  virtual const char* XmlMemberSeparator(void) const override;
177 
178  virtual AutoPtr<CTypeStrings> GenerateCode(void) const override;
179  virtual AutoPtr<CTypeStrings> GetFullCType(void) const override;
180  virtual AutoPtr<CTypeStrings> GetRefCType(void) const override;
181  virtual string GetSpecKeyword(void) const override;
182 
183 protected:
185  virtual CClassTypeInfo* CreateClassInfo(void);
186 };
187 
190 public:
191  virtual bool CheckValue(const CDataValue& value) const override;
192 
193  virtual const char* GetASNKeyword(void) const override;
194  virtual const char* GetDEFKeyword(void) const override;
195 
196 protected:
197  virtual CClassTypeInfo* CreateClassInfo(void) override;
198 };
199 
202 public:
203  virtual bool CheckValue(const CDataValue& value) const override;
204 
205  virtual const char* GetASNKeyword(void) const override;
206  virtual const char* GetDEFKeyword(void) const override;
207 };
208 
211 
212 public:
213  enum EType {
222  };
224  {
225  m_Type = type;
226  }
227  EType GetWsdlType(void) const
228  {
229  return m_Type;
230  }
231 
232  virtual AutoPtr<CTypeStrings> GetFullCType(void) const override;
233 
234  virtual void PrintASN(CNcbiOstream&, int) const override { }
235  virtual void PrintJSONSchema(CNcbiOstream&, int, list<string>&, bool) const override { }
236  virtual void PrintXMLSchema(CNcbiOstream&, int, bool) const override { }
237  virtual void PrintDTDElement(CNcbiOstream&, bool) const override { }
238  virtual bool CheckValue(const CDataValue&) const override { return false; }
239  virtual TObjectPtr CreateDefault(const CDataValue&) const override { return 0; }
240 
241 private:
243 };
244 
246 
247 #endif
CDataMemberContainerType CParent
Definition: blocktype.hpp:172
virtual CClassTypeInfo * CreateClassInfo(void)
Definition: blocktype.cpp:755
virtual CTypeInfo * CreateTypeInfo(void) override
Definition: blocktype.cpp:750
virtual AutoPtr< CTypeStrings > GetFullCType(void) const override
Definition: blocktype.cpp:834
virtual AutoPtr< CTypeStrings > GetRefCType(void) const override
Definition: blocktype.cpp:887
virtual AutoPtr< CTypeStrings > GenerateCode(void) const override
Definition: blocktype.cpp:808
AutoPtr< CTypeStrings > AddMembers(AutoPtr< CClassTypeStrings > &code) const
Definition: blocktype.cpp:841
virtual string GetSpecKeyword(void) const override
Definition: blocktype.cpp:895
virtual const char * XmlMemberSeparator(void) const override
Definition: blocktype.cpp:745
virtual void PrintASN(CNcbiOstream &out, int indent) const override
Definition: blocktype.cpp:88
void AddMember(const AutoPtr< CDataMember > &member)
Definition: blocktype.cpp:83
const TMembers & GetMembers(void) const
Definition: blocktype.hpp:155
virtual bool CheckType(void) const override
Definition: blocktype.cpp:663
list< AutoPtr< CDataMember > > TMembers
Definition: blocktype.hpp:137
virtual void PrintDTDExtra(CNcbiOstream &out) const override
Definition: blocktype.cpp:642
virtual void PrintDTDElement(CNcbiOstream &out, bool contents_only=false) const override
Definition: blocktype.cpp:496
virtual void FixTypeTree(void) const override
Definition: blocktype.cpp:655
virtual void PrintXMLSchema(CNcbiOstream &out, int indent, bool contents_only=false) const override
Definition: blocktype.cpp:249
bool UniElementNameExists(const string &name) const
Definition: blocktype.cpp:729
virtual void PrintJSONSchema(CNcbiOstream &out, int indent, list< string > &required, bool contents_only=false) const override
Definition: blocktype.cpp:118
virtual TObjectPtr CreateDefault(const CDataValue &value) const override
Definition: blocktype.cpp:723
virtual const char * XmlMemberSeparator(void) const =0
virtual void PrintSpecDumpExtra(CNcbiOstream &out, int indent) const override
Definition: blocktype.cpp:106
CComments & LastComments(void)
Definition: blocktype.hpp:160
void PrintDTD(CNcbiOstream &out) const
Definition: blocktype.cpp:1147
bool Optional(void) const
Definition: blocktype.hpp:68
const string & GetName(void) const
Definition: blocktype.hpp:56
const CDataValue * GetDefault(void) const
Definition: blocktype.hpp:88
void SetDefault(const AutoPtr< CDataValue > &value)
Definition: blocktype.cpp:1161
void PrintSpecDump(CNcbiOstream &out, int indent, const char *tag) const
Definition: blocktype.cpp:1078
const CComments & GetComments(void) const
Definition: blocktype.hpp:109
CComments m_Comments
Definition: blocktype.hpp:130
list< CMemberFacet > m_Restrictions
Definition: blocktype.hpp:131
void PrintXMLSchema(CNcbiOstream &out, int indent, bool contents_only=false) const
Definition: blocktype.cpp:1139
void SetRestrictions(const list< CMemberFacet > &c)
Definition: blocktype.hpp:113
string m_Name
Definition: blocktype.hpp:121
void SetNotag(void)
Definition: blocktype.cpp:1180
void SetNillable(void)
Definition: blocktype.cpp:1188
bool m_NoPrefix
Definition: blocktype.hpp:124
bool m_Nillable
Definition: blocktype.hpp:128
bool SimpleType(void) const
Definition: blocktype.hpp:84
const CDataType * GetType(void) const
Definition: blocktype.hpp:64
CDataType * GetType(void)
Definition: blocktype.hpp:60
void SetAttlist(void)
Definition: blocktype.cpp:1176
AutoPtr< CDataType > m_Type
Definition: blocktype.hpp:122
bool Attlist(void) const
Definition: blocktype.hpp:76
bool NoPrefix(void) const
Definition: blocktype.hpp:72
bool Notag(void) const
Definition: blocktype.hpp:80
bool m_Attlist
Definition: blocktype.hpp:125
void PrintJSONSchema(CNcbiOstream &out, int indent, list< string > &required, bool contents_only=false) const
Definition: blocktype.cpp:1134
CComments & Comments(void)
Definition: blocktype.hpp:105
void SetSimpleType(void)
Definition: blocktype.cpp:1184
bool Check(void) const
Definition: blocktype.cpp:1152
~CDataMember(void)
Definition: blocktype.cpp:1052
bool m_SimpleType
Definition: blocktype.hpp:127
AutoPtr< CDataValue > m_Default
Definition: blocktype.hpp:129
void SetNoPrefix(void)
Definition: blocktype.cpp:1171
void PrintASN(CNcbiOstream &out, int indent, bool last) const
Definition: blocktype.cpp:1056
bool Nillable(void) const
Definition: blocktype.hpp:92
CDataMember(const string &name, const AutoPtr< CDataType > &type)
Definition: blocktype.cpp:1034
bool m_Optional
Definition: blocktype.hpp:123
const list< CMemberFacet > & GetRestrictions(void) const
Definition: blocktype.hpp:116
void SetOptional(void)
Definition: blocktype.cpp:1166
virtual const char * GetASNKeyword(void) const override
Definition: blocktype.cpp:968
virtual const char * GetDEFKeyword(void) const override
Definition: blocktype.cpp:973
virtual bool CheckValue(const CDataValue &value) const override
Definition: blocktype.cpp:978
CDataContainerType CParent
Definition: blocktype.hpp:201
virtual const char * GetASNKeyword(void) const override
Definition: blocktype.cpp:909
virtual const char * GetDEFKeyword(void) const override
Definition: blocktype.cpp:914
virtual bool CheckValue(const CDataValue &value) const override
Definition: blocktype.cpp:919
virtual CClassTypeInfo * CreateClassInfo(void) override
Definition: blocktype.cpp:963
CDataContainerType CParent
Definition: blocktype.hpp:189
void * TObjectPtr
Definition: type.hpp:158
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
virtual void PrintJSONSchema(CNcbiOstream &, int, list< string > &, bool) const override
Definition: blocktype.hpp:235
virtual TObjectPtr CreateDefault(const CDataValue &) const override
Definition: blocktype.hpp:239
virtual void PrintXMLSchema(CNcbiOstream &, int, bool) const override
Definition: blocktype.hpp:236
virtual bool CheckValue(const CDataValue &) const override
Definition: blocktype.hpp:238
virtual void PrintASN(CNcbiOstream &, int) const override
Definition: blocktype.hpp:234
void SetWsdlType(EType type)
Definition: blocktype.hpp:223
virtual AutoPtr< CTypeStrings > GetFullCType(void) const override
Definition: blocktype.cpp:1025
CDataContainerType CParent
Definition: blocktype.hpp:210
virtual void PrintDTDElement(CNcbiOstream &, bool) const override
Definition: blocktype.hpp:237
EType GetWsdlType(void) const
Definition: blocktype.hpp:227
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:51
static int type
Definition: getdata.c:31
element_type * get(void) const
Get pointer.
Definition: ncbimisc.hpp:469
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const char * tag
string indent(" ")
Definition: inftrees.h:24
Definition: type.c:6
Modified on Fri Sep 20 14:58:09 2024 by modify_doxy.py rev. 669887