32#ifndef _QORE_QOREPARSEHASHNODE_H
34#define _QORE_QOREPARSEHASHNODE_H
44class QoreParseHashNode :
public ParseNode {
46 typedef std::vector<QoreValue> nvec_t;
47 typedef std::vector<const QoreTypeInfo*> tvec_t;
49 DLLLOCAL QoreParseHashNode(
const QoreProgramLocation* loc,
bool curly =
false)
54 DLLLOCAL QoreParseHashNode(
const QoreParseHashNode& old,
ExceptionSink* xsink) :
59 typeInfo(old.typeInfo),
61 keys.reserve(old.keys.size());
62 values.reserve(old.values.size());
63 for (
auto& i : old.keys) {
64 keys.push_back(copy_value_and_resolve_lvar_refs(i, xsink));
68 for (
auto& i : old.values) {
69 values.push_back(copy_value_and_resolve_lvar_refs(i, xsink));
75 DLLLOCAL ~QoreParseHashNode() {
76 assert(keys.size() == values.size());
77 for (
size_t i = 0; i < keys.size(); ++i) {
78 keys[i].discard(
nullptr);
79 values[i].discard(
nullptr);
92 checkDup(loc, key->c_str());
96 DLLLOCAL
size_t size() {
102 assert(keys.size() == 1);
110 assert(values.size() == 1);
116 DLLLOCAL
void setCurly() {
121 DLLLOCAL
bool isCurly()
const {
125 DLLLOCAL
void finalizeBlock(
int start_line,
int end_line);
127 DLLLOCAL
const nvec_t& getKeys()
const{
131 DLLLOCAL
const nvec_t& getValues()
const {
135 DLLLOCAL
const tvec_t& getValueTypes()
const {
143 DLLLOCAL
virtual const char* getTypeName()
const;
145 DLLLOCAL
virtual int parseInitImpl(
QoreValue& val, QoreParseContext& parse_context);
147 DLLLOCAL
bool hasParseError()
const {
152 typedef std::map<std::string, bool> kmap_t;
153 typedef std::vector<const QoreProgramLocation*> lvec_t;
160 const QoreTypeInfo* vtype =
nullptr;
162 const QoreTypeInfo* typeInfo =
nullptr;
166 bool parse_error =
false;
168 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
172 DLLLOCAL
static void doDuplicateWarning(
const QoreProgramLocation* newoc1,
const char* key);
174 DLLLOCAL
void checkDup(
const QoreProgramLocation* loc,
const char* key) {
175 std::string kstr(key);
176 kmap_t::iterator i = kmap.lower_bound(kstr);
177 if (i == kmap.end() || i->first != kstr)
178 kmap.insert(i, kmap_t::value_type(kstr,
false));
179 else if (!i->second) {
180 doDuplicateWarning(loc, key);
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
DLLEXPORT bool isValue() const
returns true if the object holds a value, false if it holds an expression
DLLEXPORT void clear()
unconditionally set the QoreValue to QoreNothingNode (does not dereference any possible contained Abs...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
this class is used to safely manage calls to AbstractQoreNode::getStringRepresentation() when a simpl...
Definition: QoreStringNode.h:309
const qore_type_t NT_PARSE_HASH
type value for QoreParseHashNode
Definition: node_types.h:83
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:276