Loading...
Searching...
No Matches
TypedHashDecl.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
TypedHashDecl.h
Qore Programming Language
Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_TYPEDHASHDECL_H
#define _QORE_TYPEDHASHDECL_H
// forward references
class typed_hash_decl_private;
class QoreExternalMemberBase;
class QoreExternalProgramLocation;
class TypedHashDecl {
friend class typed_hash_decl_private;
public:
DLLEXPORT TypedHashDecl(const char* name, const char* path);
DLLEXPORT TypedHashDecl(const TypedHashDecl& old);
DLLEXPORT const QoreTypeInfo* getTypeInfo(bool or_nothing = false) const;
DLLEXPORT void addMember(const char* name, const QoreTypeInfo* memberTypeInfo, QoreValue init_val);
DLLEXPORT const char* getName() const;
DLLEXPORT bool isSystem() const;
DLLEXPORT bool isPublic() const;
DLLEXPORT const QoreExternalMemberBase* findLocalMember(const char* name) const;
DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
DLLEXPORT std::string getNamespacePath(bool anchored = false) const;
DLLEXPORT bool equal(const TypedHashDecl* other) const;
DLLEXPORT const char* getModuleName() const;
DLLEXPORT const QoreNamespace* getNamespace() const;
DLLEXPORT QoreHashNode* doRuntimeCast(const QoreHashNode* h, ExceptionSink* xsink) const;
protected:
DLLEXPORT ~TypedHashDecl();
private:
DLLEXPORT TypedHashDecl(typed_hash_decl_private* p);
typed_hash_decl_private* priv;
};
class TypedHashDeclHolder {
public:
DLLLOCAL TypedHashDeclHolder(TypedHashDecl* thd) : thd(thd) {
}
DLLEXPORT ~TypedHashDeclHolder();
DLLLOCAL TypedHashDecl* operator*() const {
return thd;
}
DLLLOCAL TypedHashDecl* operator->() const {
return thd;
}
DLLLOCAL TypedHashDecl* operator=(TypedHashDecl* nhd);
DLLLOCAL TypedHashDecl* release() {
auto rv = thd;
thd = nullptr;
return rv;
}
private:
TypedHashDecl* thd;
};
class TypedHashDeclMemberIterator {
public:
DLLEXPORT TypedHashDeclMemberIterator(const TypedHashDecl& thd);
DLLEXPORT ~TypedHashDeclMemberIterator();
DLLEXPORT bool next();
DLLEXPORT const QoreExternalMemberBase& getMember() const;
DLLEXPORT const char* getName() const;
private:
class typed_hash_decl_member_iterator* priv;
};
DLLEXPORT extern const TypedHashDecl* hashdeclStatInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclDirStatInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclFilesystemInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclDateTimeInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclIsoWeekInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclCallStackInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclExceptionInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclStatementInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclNetIfInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclSourceLocationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclSerializationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclObjectSerializationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclIndexedObjectSerializationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclHashSerializationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclListSerializationInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclUrlInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclFtpResponseInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclSocketPollInfo;
DLLEXPORT extern const TypedHashDecl* hashdeclPipeInfo;
#endif
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreExternalMemberBase
external wrapper base class for class and hashdecl members
Definition: QoreReflection.h:118
QoreExternalProgramLocation
external wrapper class for source code location information
Definition: QoreReflection.h:187
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
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
TypedHashDeclHolder::operator->
DLLLOCAL TypedHashDecl * operator->() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:138
TypedHashDeclHolder::operator*
DLLLOCAL TypedHashDecl * operator*() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:133
TypedHashDeclHolder::operator=
DLLLOCAL TypedHashDecl * operator=(TypedHashDecl *nhd)
assign new TypedHashDecl value; any managed object is deleted if still managed
TypedHashDeclHolder::~TypedHashDeclHolder
DLLEXPORT ~TypedHashDeclHolder()
deletes the TypedHashDecl object if still managed
TypedHashDeclHolder::TypedHashDeclHolder
DLLLOCAL TypedHashDeclHolder(TypedHashDecl *thd)
creates the object
Definition: TypedHashDecl.h:126
TypedHashDeclHolder::release
DLLLOCAL TypedHashDecl * release()
releases the TypedHashDecl*
Definition: TypedHashDecl.h:146
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
TypedHashDecl::getName
DLLEXPORT const char * getName() const
returns the name of the typed hash
TypedHashDecl::getSourceLocation
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the typed hash (hashdecl) definition
TypedHashDecl::equal
DLLEXPORT bool equal(const TypedHashDecl *other) const
returns true if the hashdecl passed as an arugment is equal to this hashdecl
TypedHashDecl::getNamespacePath
DLLEXPORT std::string getNamespacePath(bool anchored=false) const
returns the full namespace path of the class
TypedHashDecl::findLocalMember
DLLEXPORT const QoreExternalMemberBase * findLocalMember(const char *name) const
Finds the given local member or returns nullptr.
TypedHashDecl::~TypedHashDecl
DLLEXPORT ~TypedHashDecl()
deletes the object and frees all memory
TypedHashDecl::isPublic
DLLEXPORT bool isPublic() const
returns true if the typed hash has the public (export) flag set
TypedHashDecl::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo(bool or_nothing=false) const
returns the type info object for the hashdecl
TypedHashDecl::getNamespace
DLLEXPORT const QoreNamespace * getNamespace() const
Returns the namespace owning the typed hash declaration.
TypedHashDecl::addMember
DLLEXPORT void addMember(const char *name, const QoreTypeInfo *memberTypeInfo, QoreValue init_val)
adds an element to a built-in hashdecl
TypedHashDecl::isSystem
DLLEXPORT bool isSystem() const
returns true if the typed hash is a builtin typed hash
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.
TypedHashDecl::getModuleName
DLLEXPORT const char * getModuleName() const
Returns the module name the class was loaded from or nullptr if it is a builtin class.
TypedHashDeclMemberIterator
Allows iteration of a hashdecl's members.
Definition: TypedHashDecl.h:158
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:276