diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-03-27 12:52:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-27 12:52:33 -0700 |
commit | 928ef7f2c02f18d9945dd750884dffbdebef1b98 (patch) | |
tree | d3b71619bfa0b8a91854045c01ce8b5cd15ae403 /upb/upb.h | |
parent | 00f96cb9475228ecacd9be1660f4f8d9d7b24038 (diff) |
Removed reflection and other extraneous things from the core library. (#158)
* Removed reflection and other extraneous things from the core library.
* Added missing files and ran buildifier.
* New CMakeLists.txt.
* Made table its own cc_library() for internal usage.
Diffstat (limited to 'upb/upb.h')
-rw-r--r-- | upb/upb.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -13,6 +13,7 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> +#include <string.h> #ifdef __cplusplus #include <memory> @@ -170,6 +171,33 @@ class upb::Status { #endif /* __cplusplus */ +/** upb_strview ************************************************************/ + +typedef struct { + const char *data; + size_t size; +} upb_strview; + +UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size) { + upb_strview ret; + ret.data = data; + ret.size = size; + return ret; +} + +UPB_INLINE upb_strview upb_strview_makez(const char *data) { + return upb_strview_make(data, strlen(data)); +} + +UPB_INLINE bool upb_strview_eql(upb_strview a, upb_strview b) { + return a.size == b.size && memcmp(a.data, b.data, a.size) == 0; +} + +#define UPB_STRVIEW_INIT(ptr, len) {ptr, len} + +#define UPB_STRVIEW_FORMAT "%.*s" +#define UPB_STRVIEW_ARGS(view) (int)(view).size, (view).data + /** upb_alloc *****************************************************************/ /* A upb_alloc is a possibly-stateful allocator object. |