Qore Programming Language  0.9.3.1
TypedHashDecl.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  TypedHashDecl.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2019 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_TYPEDHASHDECL_H
33 
34 #define _QORE_TYPEDHASHDECL_H
35 
36 // forward references
37 class typed_hash_decl_private;
40 
42 
45  friend class typed_hash_decl_private;
46 
47 public:
48  DLLEXPORT TypedHashDecl(const char* name);
49 
50  DLLEXPORT TypedHashDecl(const TypedHashDecl& old);
51 
53  DLLEXPORT const QoreTypeInfo* getTypeInfo(bool or_nothing = false) const;
54 
56  DLLEXPORT void addMember(const char* name, const QoreTypeInfo* memberTypeInfo, QoreValue init_val);
57 
59  DLLEXPORT const char* getName() const;
60 
62  DLLEXPORT bool isSystem() const;
63 
65 
67  DLLEXPORT bool isPublic() const;
68 
70 
72  DLLEXPORT const QoreExternalMemberBase* findLocalMember(const char* name) const;
73 
75 
77  DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
78 
80 
84  DLLEXPORT std::string getNamespacePath(bool anchored = false) const;
85 
87 
90  DLLEXPORT bool equal(const TypedHashDecl* other) const;
91 
93 
95  DLLEXPORT const char* getModuleName() const;
96 
97 protected:
99  DLLEXPORT ~TypedHashDecl();
100 
101 private:
102  DLLEXPORT TypedHashDecl(typed_hash_decl_private* p);
103 
104  typed_hash_decl_private* priv;
105 };
106 
108 
111 public:
113  DLLLOCAL TypedHashDeclHolder(TypedHashDecl* thd) : thd(thd) {
114  }
115 
117  DLLEXPORT ~TypedHashDeclHolder();
118 
120  DLLLOCAL TypedHashDecl* operator*() const {
121  return thd;
122  }
123 
125  DLLLOCAL TypedHashDecl* operator->() const {
126  return thd;
127  }
128 
130  DLLLOCAL TypedHashDecl* operator=(TypedHashDecl* nhd);
131 
133  DLLLOCAL TypedHashDecl* release() {
134  auto rv = thd;
135  thd = nullptr;
136  return rv;
137  }
138 
139 private:
141  TypedHashDecl* thd;
142 };
143 
146 public:
147  DLLEXPORT TypedHashDeclMemberIterator(const TypedHashDecl& thd);
148 
149  DLLEXPORT ~TypedHashDeclMemberIterator();
150 
151  DLLEXPORT bool next();
152 
153  DLLEXPORT const QoreExternalMemberBase& getMember() const;
154 
155  DLLEXPORT const char* getName() const;
156 
157 private:
158  class typed_hash_decl_member_iterator* priv;
159 };
160 
162 DLLEXPORT extern const TypedHashDecl* hashdeclStatInfo;
163 
165 DLLEXPORT extern const TypedHashDecl* hashdeclDirStatInfo;
166 
168 DLLEXPORT extern const TypedHashDecl* hashdeclFilesystemInfo;
169 
171 DLLEXPORT extern const TypedHashDecl* hashdeclDateTimeInfo;
172 
174 DLLEXPORT extern const TypedHashDecl* hashdeclIsoWeekInfo;
175 
177 DLLEXPORT extern const TypedHashDecl* hashdeclCallStackInfo;
178 
180 DLLEXPORT extern const TypedHashDecl* hashdeclExceptionInfo;
181 
183 DLLEXPORT extern const TypedHashDecl* hashdeclStatementInfo;
184 
186 DLLEXPORT extern const TypedHashDecl* hashdeclNetIfInfo;
187 
189 DLLEXPORT extern const TypedHashDecl* hashdeclSourceLocationInfo;
190 
192 
194 DLLEXPORT extern const TypedHashDecl* hashdeclSerializationInfo;
195 
197 
199 DLLEXPORT extern const TypedHashDecl* hashdeclObjectSerializationInfo;
200 
202 
204 DLLEXPORT extern const TypedHashDecl* hashdeclIndexedObjectSerializationInfo;
205 
207 
209 DLLEXPORT extern const TypedHashDecl* hashdeclHashSerializationInfo;
210 
212 
214 DLLEXPORT extern const TypedHashDecl* hashdeclListSerializationInfo;
215 
217 
219 DLLEXPORT extern const TypedHashDecl* hashdeclUrlInfo;
220 
221 #endif
DLLEXPORT const char * getName() const
returns the name of the typed hash
DLLLOCAL TypedHashDecl * operator*() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:120
DLLEXPORT ~TypedHashDecl()
deletes the object and frees all memory
DLLEXPORT bool equal(const TypedHashDecl *other) const
returns true if the hashdecl passed as an arugment is equal to this hashdecl
DLLLOCAL TypedHashDeclHolder(TypedHashDecl *thd)
creates the object
Definition: TypedHashDecl.h:113
DLLEXPORT std::string getNamespacePath(bool anchored=false) const
returns the full namespace path of the class
DLLLOCAL TypedHashDecl * operator->() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:125
allows for temporary storage of a TypedHashDecl pointer
Definition: TypedHashDecl.h:110
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the typed hash (hashdecl) definition
DLLEXPORT bool isPublic() const
returns true if the typed hash has the public (export) flag set
external wrapper base class for class and hashdecl members
Definition: QoreReflection.h:118
DLLEXPORT bool isSystem() const
returns true if the typed hash is a builtin typed hash
DLLLOCAL TypedHashDecl * release()
releases the TypedHashDecl*
Definition: TypedHashDecl.h:133
Allows iteration of a hashdecl's members.
Definition: TypedHashDecl.h:145
DLLEXPORT void addMember(const char *name, const QoreTypeInfo *memberTypeInfo, QoreValue init_val)
adds an element to a built-in hashdecl
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
DLLEXPORT const QoreTypeInfo * getTypeInfo(bool or_nothing=false) const
returns the type info object for the hashdecl
DLLEXPORT ~TypedHashDeclHolder()
deletes the TypedHashDecl object if still managed
DLLEXPORT const QoreExternalMemberBase * findLocalMember(const char *name) const
Finds the given local member or returns nullptr.
external wrapper class for source code location information
Definition: QoreReflection.h:187
DLLEXPORT const char * getModuleName() const
Returns the module name the class was loaded from or nullptr if it is a builtin class.
typed hash declaration
Definition: TypedHashDecl.h:44
DLLLOCAL TypedHashDecl * operator=(TypedHashDecl *nhd)
assign new TypedHashDecl value; any managed object is deleted if still managed