diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-07-04 11:28:09 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-07-04 11:28:09 -0700 |
commit | 94a2f5bd9c476c7860c412b434b535f472c9a701 (patch) | |
tree | 3bc17c01428808d8934c48eaeb7bd130b839601f /upb.h | |
parent | aecbfe42243ccd06425f021df6fe8d8d65974db7 (diff) |
Move upb_string into its own header file.
Diffstat (limited to 'upb.h')
-rw-r--r-- | upb.h | 27 |
1 files changed, 0 insertions, 27 deletions
@@ -38,33 +38,6 @@ extern "C" { INLINE uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; } -/* Represents a string or bytes. */ -struct upb_string { - /* We expect the data to be 8-bit clean (uint8_t), but char* is such an - * ingrained convention that we follow it. */ - char *ptr; - uint32_t byte_len; -}; - -INLINE bool upb_streql(struct upb_string *s1, struct upb_string *s2) { - return s1->byte_len == s2->byte_len && - memcmp(s1->ptr, s2->ptr, s1->byte_len) == 0; -} - -INLINE void upb_strcpy(struct upb_string *dest, struct upb_string *src) { - memcpy(dest->ptr, src->ptr, dest->byte_len); - dest->byte_len = src->byte_len; -} - -INLINE void upb_print(struct upb_string *str) { - fwrite(str->ptr, str->byte_len, 1, stdout); - fputc('\n', stdout); -} - -#define UPB_STRLIT(strlit) {.ptr=strlit, .byte_len=sizeof(strlit)-1} -#define UPB_STRFARG(str) (str).byte_len, (str).ptr -#define UPB_STRFMT "%.*s" - /* A list of types as they are encoded on-the-wire. */ enum upb_wire_type { UPB_WIRE_TYPE_VARINT = 0, |