Skip to content

Commit 719dff1

Browse files
saka1lemire
authored andcommitted
Add predicates to ParsedJson::iterator (simdjson#153)
1 parent 7c8404e commit 719dff1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

include/simdjson/parsedjson.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ struct ParsedJson {
154154

155155
bool is_double() const;
156156

157+
bool is_true() const;
158+
159+
bool is_false() const;
160+
161+
bool is_null() const;
162+
157163
static bool is_object_or_array(uint8_t type);
158164

159165
// when at {, go one level deep, looking for a given key

src/parsedjsoniterator.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ bool ParsedJson::iterator::is_double() const {
161161
return get_type() == 'd';
162162
}
163163

164+
bool ParsedJson::iterator::is_true() const {
165+
return get_type() == 't';
166+
}
167+
168+
bool ParsedJson::iterator::is_false() const {
169+
return get_type() == 'f';
170+
}
171+
172+
bool ParsedJson::iterator::is_null() const {
173+
return get_type() == 'n';
174+
}
175+
164176
bool ParsedJson::iterator::is_object_or_array(uint8_t type) {
165177
return (type == '[' || (type == '{'));
166178
}

0 commit comments

Comments
 (0)