Added support for lists (without index value)

This commit is contained in:
Raphael Coeffic
2021-11-10 11:07:00 +01:00
parent 77ff579355
commit a8f2212f2c
22 changed files with 124 additions and 75 deletions
+30 -1
View File
@@ -27,6 +27,9 @@
struct YamlParserCalls;
#define FLAG_STATE_IDX_INVALID (1 << 0)
#define FLAG_STATE_ARRAY_ELMT (1 << 1)
class YamlTreeWalker
{
struct State {
@@ -34,6 +37,7 @@ class YamlTreeWalker
uint32_t bit_ofs;
int8_t attr_idx;
uint16_t elmts;
uint8_t flags;
inline uint32_t getOfs() {
return bit_ofs + node->size * elmts;
@@ -44,7 +48,6 @@ class YamlTreeWalker
uint8_t stack_level;
uint8_t virt_level;
uint8_t anon_union;
bool idx_invalid;
uint8_t* data;
@@ -71,6 +74,28 @@ class YamlTreeWalker
void incAttr() { stack[stack_level].attr_idx++; }
void incElmts() { stack[stack_level].elmts++; }
inline bool isIdxInvalid() {
return stack[stack_level].flags & FLAG_STATE_IDX_INVALID;
}
inline void setIdxInvalid(bool set) {
if (set) stack[stack_level].flags |= FLAG_STATE_IDX_INVALID;
else stack[stack_level].flags &= ~FLAG_STATE_IDX_INVALID;
}
inline bool isArrayElmt() {
return stack[stack_level].flags & FLAG_STATE_ARRAY_ELMT;
}
inline bool isParentArrayElmt() {
return !empty() && stack[stack_level + 1].flags & FLAG_STATE_ARRAY_ELMT;
}
inline void setArrayElmt(bool set) {
if (set) stack[stack_level].flags |= FLAG_STATE_ARRAY_ELMT;
else stack[stack_level].flags &= ~FLAG_STATE_ARRAY_ELMT;
}
bool empty() { return stack_level == NODE_STACK_DEPTH; }
bool full() { return stack_level == 0; }
@@ -110,6 +135,10 @@ public:
return stack[stack_level].elmts;
}
uint16_t getParentElmts() {
return empty() ? 0 : stack[stack_level + 1].elmts;
}
// Increment the cursor until a match is found or the end of
// the current collection (node of type YDT_NONE) is reached.
//