Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5c925ce in mainline for uspace/app/bithenge/tree.h


Ignore:
Timestamp:
2012-06-07T17:00:12Z (9 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
8375d0eb
Parents:
5f679702
Message:

Bithenge: make blobs a type of node

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/tree.h

    r5f679702 r5c925ce  
    5757        BITHENGE_NODE_INTEGER,
    5858        BITHENGE_NODE_STRING,
    59         // TODO: BITHENGE_NODE_BLOB,
     59        BITHENGE_NODE_BLOB,
    6060} bithenge_node_type_t;
    6161
     
    6363        bithenge_node_type_t type;
    6464        union {
    65                 struct bithenge_internal_node_ops_t *internal_ops;
     65                const struct bithenge_internal_node_ops_t *internal_ops;
    6666                bool boolean_value;
    6767                bithenge_int_t integer_value;
     
    7070                        bool needs_free;
    7171                } string_value;
     72                const struct bithenge_random_access_blob_ops_t *blob_ops;
    7273        };
    7374} bithenge_node_t;
     
    8283typedef struct bithenge_internal_node_ops_t {
    8384        int (*for_each)(bithenge_node_t *node, bithenge_for_each_func_t func, void *data);
     85        int (*destroy)(bithenge_node_t *node);
    8486} bithenge_internal_node_ops_t;
    8587
    8688static inline int bithenge_node_for_each(bithenge_node_t *node, bithenge_for_each_func_t func, void *data)
    8789{
     90        assert(node->type == BITHENGE_NODE_INTERNAL);
    8891        return node->internal_ops->for_each(node, func, data);
    8992}
     
    9194static inline bool bithenge_boolean_node_value(bithenge_node_t *node)
    9295{
     96        assert(node->type == BITHENGE_NODE_BOOLEAN);
    9397        return node->boolean_value;
    9498}
     
    96100static inline bithenge_int_t bithenge_integer_node_value(bithenge_node_t *node)
    97101{
     102        assert(node->type == BITHENGE_NODE_INTEGER);
    98103        return node->integer_value;
    99104}
     
    101106static inline const char *bithenge_string_node_value(bithenge_node_t *node)
    102107{
     108        assert(node->type == BITHENGE_NODE_STRING);
    103109        return node->string_value.ptr;
    104110}
Note: See TracChangeset for help on using the changeset viewer.