Changeset cb4a66d2 in mainline for uspace/app/bithenge/transform.h


Ignore:
Timestamp:
2012-08-01T23:43:10Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b8d45e9e
Parents:
47a728e1
Message:

Bithenge: add transform_prefix_apply

  • makes struct nodes more efficient in some cases.
  • will make certain future transforms easier to implement.
File:
1 edited

Legend:

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

    r47a728e1 rcb4a66d2  
    5757} bithenge_scope_t;
    5858
    59 /** Operations that may be provided by a transform. */
     59/** Operations that may be provided by a transform. All transforms must provide
     60 * apply and/or prefix_apply. To be used in struct transforms and repeat
     61 * transforms, transforms must provide prefix_length and/or prefix_apply. */
    6062typedef struct bithenge_transform_ops {
    6163        /** @copydoc bithenge_transform_t::bithenge_transform_apply */
     
    6567        int (*prefix_length)(bithenge_transform_t *self,
    6668            bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out);
     69        /** @copydoc bithenge_transform_t::bithenge_transform_prefix_apply */
     70        int (*prefix_apply)(bithenge_transform_t *self,
     71            bithenge_scope_t *scope, bithenge_blob_t *blob,
     72            bithenge_node_t **out_node, aoff64_t *out_size);
    6773        /** Destroy the transform.
    6874         * @param self The transform. */
     
    191197        assert(self);
    192198        return self->num_params;
    193 }
    194 
    195 /** Apply a transform. Takes ownership of nothing.
    196  * @memberof bithenge_transform_t
    197  * @param self The transform.
    198  * @param scope The scope.
    199  * @param in The input tree.
    200  * @param[out] out Where the output tree will be stored.
    201  * @return EOK on success or an error code from errno.h. */
    202 static inline int bithenge_transform_apply(bithenge_transform_t *self,
    203     bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)
    204 {
    205         assert(self);
    206         assert(self->ops);
    207         return self->ops->apply(self, scope, in, out);
    208 }
    209 
    210 /** Find the length of the prefix of a blob this transform can use as input. In
    211  * other words, figure out how many bytes this transform will use up.  This
    212  * method is optional and can return an error, but it must succeed for struct
    213  * subtransforms. Takes ownership of nothing.
    214  * @memberof bithenge_transform_t
    215  * @param self The transform.
    216  * @param scope The scope.
    217  * @param blob The blob.
    218  * @param[out] out Where the prefix length will be stored.
    219  * @return EOK on success, ENOTSUP if not supported, or another error code from
    220  * errno.h. */
    221 static inline int bithenge_transform_prefix_length(bithenge_transform_t *self,
    222     bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out)
    223 {
    224         assert(self);
    225         assert(self->ops);
    226         if (!self->ops->prefix_length)
    227                 return ENOTSUP;
    228         return self->ops->prefix_length(self, scope, blob, out);
    229199}
    230200
     
    269239int bithenge_init_transform(bithenge_transform_t *,
    270240    const bithenge_transform_ops_t *, int);
     241int bithenge_transform_apply(bithenge_transform_t *, bithenge_scope_t *,
     242    bithenge_node_t *, bithenge_node_t **);
     243int bithenge_transform_prefix_length(bithenge_transform_t *,
     244    bithenge_scope_t *, bithenge_blob_t *, aoff64_t *);
     245int bithenge_transform_prefix_apply(bithenge_transform_t *, bithenge_scope_t *,
     246    bithenge_blob_t *, bithenge_node_t **, aoff64_t *);
    271247int bithenge_new_param_transform(bithenge_transform_t **,
    272248    bithenge_transform_t *, int);
Note: See TracChangeset for help on using the changeset viewer.