Struct NodeType
Synopsis
#include <src/c4/yml/tree.hpp>
struct NodeType
Description
wraps a NodeType_e element with some syntactic sugar and predicates
Summary
Source
Lines 206-278 in src/c4/yml/tree.hpp.
struct NodeType
{
public:
NodeType_e type;
public:
inline operator NodeType_e & C4_RESTRICT () { return type; }
inline operator NodeType_e const& C4_RESTRICT () const { return type; }
NodeType() : type(NOTYPE) {}
NodeType(NodeType_e t) : type(t) {}
NodeType(type_bits t) : type((NodeType_e)t) {}
const char *type_str() const { return type_str(type); }
static const char* type_str(NodeType_e t);
void set(NodeType_e t) { type = t; }
void set(type_bits t) { type = (NodeType_e)t; }
void add(NodeType_e t) { type = (NodeType_e)(type|t); }
void add(type_bits t) { type = (NodeType_e)(type|t); }
void rem(NodeType_e t) { type = (NodeType_e)(type & ~t); }
void rem(type_bits t) { type = (NodeType_e)(type & ~t); }
void clear() { type = NOTYPE; }
public:
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wnull-dereference"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# if __GNUC__ >= 6
# pragma GCC diagnostic ignored "-Wnull-dereference"
# endif
#endif
bool is_stream() const { return ((type & STREAM) == STREAM) != 0; }
bool is_doc() const { return (type & DOC) != 0; }
bool is_container() const { return (type & (MAP|SEQ|STREAM)) != 0; }
bool is_map() const { return (type & MAP) != 0; }
bool is_seq() const { return (type & SEQ) != 0; }
bool has_val() const { return (type & VAL) != 0; }
bool has_key() const { return (type & KEY) != 0; }
bool is_val() const { return (type & (KEYVAL)) == VAL; }
bool is_keyval() const { return (type & KEYVAL) == KEYVAL; }
bool has_key_tag() const { return (type & (KEY|KEYTAG)) == (KEY|KEYTAG); }
bool has_val_tag() const { return ((type & (VALTAG)) && (type & (VAL|MAP|SEQ))); }
bool has_key_anchor() const { return (type & (KEY|KEYANCH)) == (KEY|KEYANCH); }
bool is_key_anchor() const { return (type & (KEY|KEYANCH)) == (KEY|KEYANCH); }
bool has_val_anchor() const { return (type & VALANCH) != 0 && (type & (VAL|SEQ|MAP)) != 0; }
bool is_val_anchor() const { return (type & VALANCH) != 0 && (type & (VAL|SEQ|MAP)) != 0; }
bool has_anchor() const { return (type & (KEYANCH|VALANCH)) != 0; }
bool is_anchor() const { return (type & (KEYANCH|VALANCH)) != 0; }
bool is_key_ref() const { return (type & KEYREF) != 0; }
bool is_val_ref() const { return (type & VALREF) != 0; }
bool is_ref() const { return (type & (KEYREF|VALREF)) != 0; }
bool is_anchor_or_ref() const { return (type & (KEYANCH|VALANCH|KEYREF|VALREF)) != 0; }
bool is_key_quoted() const { return (type & (KEY|KEYQUO)) == (KEY|KEYQUO); }
bool is_val_quoted() const { return (type & (VAL|VALQUO)) == (VAL|VALQUO); }
bool is_quoted() const { return (type & (KEY|KEYQUO)) == (KEY|KEYQUO) || (type & (VAL|VALQUO)) == (VAL|VALQUO); }
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
};