Changeset af0beac in serd


Ignore:
Timestamp:
07/31/17 00:37:56 (3 weeks ago)
Author:
David Robillard <d@…>
Branches:
serd1
Children:
9709d1b
Parents:
a26622b
git-author:
David Robillard <d@…> (03/16/16 13:54:49)
git-committer:
David Robillard <d@…> (07/31/17 00:37:56)
Message:

Rename SerdChunk? to SerdSlice?

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • serd/serd.h

    ra26622b raf0beac  
    223223 
    224224/** 
    225    An unterminated string fragment. 
     225   An unterminated immutable slice of a string. 
    226226*/ 
    227227typedef struct { 
    228228    const char* buf;  /**< Start of chunk */ 
    229229    size_t      len;  /**< Length of chunk in bytes */ 
    230 } SerdChunk; 
     230} SerdSlice; 
    231231 
    232232/** 
     
    253253   A parsed URI. 
    254254 
    255    This struct directly refers to chunks in other strings, it does not own any 
     255   This struct directly refers to slices in other strings, it does not own any 
    256256   memory itself.  Thus, URIs can be parsed and/or resolved against a base URI 
    257257   in-place without allocating memory. 
    258258*/ 
    259259typedef struct { 
    260     SerdChunk scheme;     /**< Scheme */ 
    261     SerdChunk authority;  /**< Authority */ 
    262     SerdChunk path_base;  /**< Path prefix if relative */ 
    263     SerdChunk path;       /**< Path suffix */ 
    264     SerdChunk query;      /**< Query */ 
    265     SerdChunk fragment;   /**< Fragment */ 
     260    SerdSlice scheme;     /**< Scheme */ 
     261    SerdSlice authority;  /**< Authority */ 
     262    SerdSlice path_base;  /**< Path prefix if relative */ 
     263    SerdSlice path;       /**< Path suffix */ 
     264    SerdSlice query;      /**< Query */ 
     265    SerdSlice fragment;   /**< Fragment */ 
    266266} SerdURI; 
    267267 
     
    716716                 const SerdNode* uri, 
    717717                 SerdNode*       prefix, 
    718                  SerdChunk*      suffix); 
     718                 SerdSlice*      suffix); 
    719719 
    720720/** 
     
    725725serd_env_expand(const SerdEnv*  env, 
    726726                const SerdNode* curie, 
    727                 SerdChunk*      uri_prefix, 
    728                 SerdChunk*      uri_suffix); 
     727                SerdSlice*      uri_prefix, 
     728                SerdSlice*      uri_suffix); 
    729729 
    730730/** 
     
    967967 
    968968/** 
    969    Finish a serialisation to a chunk with serd_buffer_sink(). 
     969   Finish a serialisation to a buffer with serd_buffer_sink(). 
    970970 
    971971   The returned string is the result of the serialisation, which is NULL 
  • src/env.c

    ra26622b raf0beac  
    187187                 const SerdNode* uri, 
    188188                 SerdNode*       prefix, 
    189                  SerdChunk*      suffix) 
     189                 SerdSlice*      suffix) 
    190190{ 
    191191    for (size_t i = 0; i < env->n_prefixes; ++i) { 
     
    211211serd_env_expand(const SerdEnv*  env, 
    212212                const SerdNode* curie, 
    213                 SerdChunk*      uri_prefix, 
    214                 SerdChunk*      uri_suffix) 
     213                SerdSlice*      uri_prefix, 
     214                SerdSlice*      uri_suffix) 
    215215{ 
    216216    const char* const colon = (const char*)memchr( 
     
    239239    switch (node->type) { 
    240240    case SERD_CURIE: { 
    241         SerdChunk prefix; 
    242         SerdChunk suffix; 
     241        SerdSlice prefix; 
     242        SerdSlice suffix; 
    243243        if (serd_env_expand(env, node, &prefix, &suffix)) { 
    244244            return SERD_NODE_NULL; 
  • src/serd_internal.h

    ra26622b raf0beac  
    381381 
    382382static inline bool 
    383 chunk_equals(const SerdChunk* a, const SerdChunk* b) 
     383slice_equals(const SerdSlice* a, const SerdSlice* b) 
    384384{ 
    385385    return a->len == b->len 
     
    408408{ 
    409409    if (!root || !root->scheme.len || 
    410         !chunk_equals(&root->scheme, &uri->scheme) || 
    411         !chunk_equals(&root->authority, &uri->authority)) { 
     410        !slice_equals(&root->scheme, &uri->scheme) || 
     411        !slice_equals(&root->authority, &uri->authority)) { 
    412412        return false; 
    413413    } 
  • src/uri.c

    ra26622b raf0beac  
    316316/// Merge `base` and `path` in-place 
    317317static void 
    318 merge(SerdChunk* base, SerdChunk* path) 
     318merge(SerdSlice* base, SerdSlice* path) 
    319319{ 
    320320    size_t      up; 
  • src/writer.c

    ra26622b raf0beac  
    482482{ 
    483483    SerdNode  prefix; 
    484     SerdChunk suffix; 
     484    SerdSlice suffix; 
    485485 
    486486    if (is_inline_start(writer, field, flags)) { 
     
    538538            const SerdStatementFlags flags) 
    539539{ 
    540     SerdChunk prefix; 
    541     SerdChunk suffix; 
     540    SerdSlice prefix; 
     541    SerdSlice suffix; 
    542542    switch (writer->syntax) { 
    543543    case SERD_NTRIPLES: 
  • tests/serd_test.c

    ra26622b raf0beac  
    421421    } 
    422422 
    423     SerdChunk prefix, suffix; 
     423    SerdSlice prefix, suffix; 
    424424    if (!serd_env_expand(env, &b, &prefix, &suffix)) { 
    425425        return failure("Expanded invalid curie %s\n", b.buf); 
     
    570570    o = serd_node_from_string(SERD_URI, "http://example.org/base"); 
    571571    if (serd_writer_set_base_uri(writer, &o)) { 
    572         return failure("Failed to write to chunk sink\n"); 
     572        return failure("Failed to write to buffer sink\n"); 
    573573    } 
    574574 
Note: See TracChangeset for help on using the changeset viewer.