| Qore Programming Language - C/C++ Library 1.0.8

TypedHashDecl.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 TypedHashDecl.h
4
5 Qore Programming Language
6
7 Copyright (C) 2003 - 2021 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;
38 class QoreExternalMemberBase;
39 class QoreExternalProgramLocation;
40
42
44 class TypedHashDecl {
45 friend class typed_hash_decl_private;
46
47 public:
48 DLLEXPORT TypedHashDecl(const char* name, const char* path);
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
98
100 DLLEXPORT const QoreNamespace* getNamespace() const;
101
103
108 DLLEXPORT QoreHashNode* doRuntimeCast(const QoreHashNode* h, ExceptionSink* xsink) const;
109
110 protected:
112 DLLEXPORT ~TypedHashDecl();
113
114 private:
115 DLLEXPORT TypedHashDecl(typed_hash_decl_private* p);
116
117 typed_hash_decl_private* priv;
118 };
119
121
123 class TypedHashDeclHolder {
124 public:
126 DLLLOCAL TypedHashDeclHolder(TypedHashDecl* thd) : thd(thd) {
127 }
128
130 DLLEXPORT ~TypedHashDeclHolder();
131
133 DLLLOCAL TypedHashDecl* operator*() const {
134 return thd;
135 }
136
138 DLLLOCAL TypedHashDecl* operator->() const {
139 return thd;
140 }
141
143 DLLLOCAL TypedHashDecl* operator=(TypedHashDecl* nhd);
144
146 DLLLOCAL TypedHashDecl* release() {
147 auto rv = thd;
148 thd = nullptr;
149 return rv;
150 }
151
152 private:
154 TypedHashDecl* thd;
155 };
156
158 class TypedHashDeclMemberIterator {
159 public:
160 DLLEXPORT TypedHashDeclMemberIterator(const TypedHashDecl& thd);
161
162 DLLEXPORT ~TypedHashDeclMemberIterator();
163
164 DLLEXPORT bool next();
165
166 DLLEXPORT const QoreExternalMemberBase& getMember() const;
167
168 DLLEXPORT const char* getName() const;
169
170 private:
171 class typed_hash_decl_member_iterator* priv;
172 };
173
175 DLLEXPORT extern const TypedHashDecl* hashdeclStatInfo;
176
178 DLLEXPORT extern const TypedHashDecl* hashdeclDirStatInfo;
179
181 DLLEXPORT extern const TypedHashDecl* hashdeclFilesystemInfo;
182
184 DLLEXPORT extern const TypedHashDecl* hashdeclDateTimeInfo;
185
187 DLLEXPORT extern const TypedHashDecl* hashdeclIsoWeekInfo;
188
190 DLLEXPORT extern const TypedHashDecl* hashdeclCallStackInfo;
191
193 DLLEXPORT extern const TypedHashDecl* hashdeclExceptionInfo;
194
196 DLLEXPORT extern const TypedHashDecl* hashdeclStatementInfo;
197
199 DLLEXPORT extern const TypedHashDecl* hashdeclNetIfInfo;
200
202 DLLEXPORT extern const TypedHashDecl* hashdeclSourceLocationInfo;
203
205
207 DLLEXPORT extern const TypedHashDecl* hashdeclSerializationInfo;
208
210
212 DLLEXPORT extern const TypedHashDecl* hashdeclObjectSerializationInfo;
213
215
217 DLLEXPORT extern const TypedHashDecl* hashdeclIndexedObjectSerializationInfo;
218
220
222 DLLEXPORT extern const TypedHashDecl* hashdeclHashSerializationInfo;
223
225
227 DLLEXPORT extern const TypedHashDecl* hashdeclListSerializationInfo;
228
230
232 DLLEXPORT extern const TypedHashDecl* hashdeclUrlInfo;
233
235
237 DLLEXPORT extern const TypedHashDecl* hashdeclFtpResponseInfo;
238
240
242 DLLEXPORT extern const TypedHashDecl* hashdeclSocketPollInfo;
243
244 #endif
TypedHashDecl::getName
DLLEXPORT const char * getName() const
returns the name of the typed hash
TypedHashDeclHolder::operator*
DLLLOCAL TypedHashDecl * operator*() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:133
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
TypedHashDecl::~TypedHashDecl
DLLEXPORT ~TypedHashDecl()
deletes the object and frees all memory
TypedHashDecl::equal
DLLEXPORT bool equal(const TypedHashDecl *other) const
returns true if the hashdecl passed as an arugment is equal to this hashdecl
TypedHashDeclHolder::TypedHashDeclHolder
DLLLOCAL TypedHashDeclHolder(TypedHashDecl *thd)
creates the object
Definition: TypedHashDecl.h:126
TypedHashDecl::getNamespacePath
DLLEXPORT std::string getNamespacePath(bool anchored=false) const
returns the full namespace path of the class
TypedHashDeclHolder::operator->
DLLLOCAL TypedHashDecl * operator->() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:138
QoreNamespace
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
TypedHashDeclHolder
allows for temporary storage of a TypedHashDecl pointer
Definition: TypedHashDecl.h:123
TypedHashDecl::getSourceLocation
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the typed hash (hashdecl) definition
TypedHashDecl::isPublic
DLLEXPORT bool isPublic() const
returns true if the typed hash has the public (export) flag set
TypedHashDecl::doRuntimeCast
DLLEXPORT QoreHashNode * doRuntimeCast(const QoreHashNode *h, ExceptionSink *xsink) const
Performs a runtime cast and returns a typed hash if the has passed is compatible. ...
QoreExternalMemberBase
external wrapper base class for class and hashdecl members
Definition: QoreReflection.h:118
TypedHashDecl::isSystem
DLLEXPORT bool isSystem() const
returns true if the typed hash is a builtin typed hash
TypedHashDeclHolder::release
DLLLOCAL TypedHashDecl * release()
releases the TypedHashDecl*
Definition: TypedHashDecl.h:146
TypedHashDeclMemberIterator
Allows iteration of a hashdecl&#39;s members.
Definition: TypedHashDecl.h:158
TypedHashDecl::addMember
DLLEXPORT void addMember(const char *name, const QoreTypeInfo *memberTypeInfo, QoreValue init_val)
adds an element to a built-in hashdecl
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:267
TypedHashDecl::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo(bool or_nothing=false) const
returns the type info object for the hashdecl
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
TypedHashDeclHolder::~TypedHashDeclHolder
DLLEXPORT ~TypedHashDeclHolder()
deletes the TypedHashDecl object if still managed
TypedHashDecl::findLocalMember
DLLEXPORT const QoreExternalMemberBase * findLocalMember(const char *name) const
Finds the given local member or returns nullptr.
QoreExternalProgramLocation
external wrapper class for source code location information
Definition: QoreReflection.h:187
TypedHashDecl::getModuleName
DLLEXPORT const char * getModuleName() const
Returns the module name the class was loaded from or nullptr if it is a builtin class.
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
TypedHashDecl::getNamespace
DLLEXPORT const QoreNamespace * getNamespace() const
Returns the namespace owning the typed hash declaration.
TypedHashDeclHolder::operator=
DLLLOCAL TypedHashDecl * operator=(TypedHashDecl *nhd)
assign new TypedHashDecl value; any managed object is deleted if still managed