All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TypedHashDecl.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
TypedHashDecl.h
Qore Programming Language
Copyright (C) 2003 - 2017 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 TypedHashDecl {
friend class typed_hash_decl_private;
public:
DLLEXPORT TypedHashDecl(const char* name);
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;
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;
};
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;
#endif
TypedHashDecl::~TypedHashDecl
DLLEXPORT ~TypedHashDecl()
deletes the object and frees all memory
TypedHashDeclHolder::TypedHashDeclHolder
DLLLOCAL TypedHashDeclHolder(TypedHashDecl *thd)
creates the object
Definition: TypedHashDecl.h:76
TypedHashDeclHolder::operator->
DLLLOCAL TypedHashDecl * operator->() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:88
TypedHashDeclHolder::operator*
DLLLOCAL TypedHashDecl * operator*() const
implicit conversion to TypedHashDecl*
Definition: TypedHashDecl.h:83
TypedHashDeclHolder
allows for temporary storage of a TypedHashDecl pointer
Definition: TypedHashDecl.h:73
TypedHashDeclHolder::release
DLLLOCAL TypedHashDecl * release()
releases the TypedHashDecl*
Definition: TypedHashDecl.h:96
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:112
TypedHashDeclHolder::~TypedHashDeclHolder
DLLEXPORT ~TypedHashDeclHolder()
deletes the TypedHashDecl object if still managed
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:42
TypedHashDecl::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo(bool or_nothing=false) const
returns the type info object for the hashdecl
TypedHashDeclHolder::operator=
DLLLOCAL TypedHashDecl * operator=(TypedHashDecl *nhd)
assign new TypedHashDecl value; any managed object is deleted if still managed