Qore Programming Language  0.9.2
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 
58  DLLEXPORT const char* getName() const;
59 
60  DLLEXPORT bool isSystem() const;
61 
63 
65  DLLEXPORT const QoreExternalMemberBase* findLocalMember(const char* name) const;
66 
68 
70  DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
71 
73 
77  DLLEXPORT std::string getNamespacePath(bool anchored = false) const;
78 
80 
83  DLLEXPORT bool equal(const TypedHashDecl* other) const;
84 
86 
88  DLLEXPORT const char* getModuleName() const;
89 
90 protected:
92  DLLEXPORT ~TypedHashDecl();
93 
94 private:
95  DLLEXPORT TypedHashDecl(typed_hash_decl_private* p);
96 
97  typed_hash_decl_private* priv;
98 };
99 
101 
104 public:
106  DLLLOCAL TypedHashDeclHolder(TypedHashDecl* thd) : thd(thd) {
107  }
108 
110  DLLEXPORT ~TypedHashDeclHolder();
111 
113  DLLLOCAL TypedHashDecl* operator*() const {
114  return thd;
115  }
116 
118  DLLLOCAL TypedHashDecl* operator->() const {
119  return thd;
120  }
121 
123  DLLLOCAL TypedHashDecl* operator=(TypedHashDecl* nhd);
124 
126  DLLLOCAL TypedHashDecl* release() {
127  auto rv = thd;
128  thd = nullptr;
129  return rv;
130  }
131 
132 private:
134  TypedHashDecl* thd;
135 };
136 
139 public:
140  DLLEXPORT TypedHashDeclMemberIterator(const TypedHashDecl& thd);
141 
142  DLLEXPORT ~TypedHashDeclMemberIterator();
143 
144  DLLEXPORT bool next();
145 
146  DLLEXPORT const QoreExternalMemberBase& getMember() const;
147 
148  DLLEXPORT const char* getName() const;
149 
150 private:
151  class typed_hash_decl_member_iterator* priv;
152 };
153 
155 DLLEXPORT extern const TypedHashDecl* hashdeclStatInfo;
156 
158 DLLEXPORT extern const TypedHashDecl* hashdeclDirStatInfo;
159 
161 DLLEXPORT extern const TypedHashDecl* hashdeclFilesystemInfo;
162 
164 DLLEXPORT extern const TypedHashDecl* hashdeclDateTimeInfo;
165 
167 DLLEXPORT extern const TypedHashDecl* hashdeclIsoWeekInfo;
168 
170 DLLEXPORT extern const TypedHashDecl* hashdeclCallStackInfo;
171 
173 DLLEXPORT extern const TypedHashDecl* hashdeclExceptionInfo;
174 
176 DLLEXPORT extern const TypedHashDecl* hashdeclStatementInfo;
177 
179 DLLEXPORT extern const TypedHashDecl* hashdeclNetIfInfo;
180 
182 DLLEXPORT extern const TypedHashDecl* hashdeclSourceLocationInfo;
183 
185 
187 DLLEXPORT extern const TypedHashDecl* hashdeclSerializationInfo;
188 
190 
192 DLLEXPORT extern const TypedHashDecl* hashdeclObjectSerializationInfo;
193 
195 
197 DLLEXPORT extern const TypedHashDecl* hashdeclIndexedObjectSerializationInfo;
198 
200 
202 DLLEXPORT extern const TypedHashDecl* hashdeclHashSerializationInfo;
203 
205 
207 DLLEXPORT extern const TypedHashDecl* hashdeclListSerializationInfo;
208 
209 #endif
DLLLOCAL TypedHashDecl * operator*() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:113
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:106
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:118
allows for temporary storage of a TypedHashDecl pointer
Definition: TypedHashDecl.h:103
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the typed hash (hashdecl) definition
external wrapper base class for class and hashdecl members
Definition: QoreReflection.h:118
DLLLOCAL TypedHashDecl * release()
releases the TypedHashDecl*
Definition: TypedHashDecl.h:126
Allows iteration of a hashdecl's members.
Definition: TypedHashDecl.h:138
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