diff options
author | Joshua Haberman <joshua@reverberate.org> | 2011-02-22 01:54:31 -0800 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2011-02-22 01:54:31 -0800 |
commit | fd184f0df2e5e428873eadfaf1ae829d2e4d8e51 (patch) | |
tree | 19c4a1d9099f04c74de60eb4d8149ea1b5d930a0 /src/upb_string.h | |
parent | 0c6786c6fad563f181e66c90df2a74597ce6d18b (diff) |
Major work on Lua extension and default values.
Default values are now supported, and the Lua extension
can now create and modify individual protobuf objects.
Diffstat (limited to 'src/upb_string.h')
-rw-r--r-- | src/upb_string.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/upb_string.h b/src/upb_string.h index 3799c5e..efafa44 100644 --- a/src/upb_string.h +++ b/src/upb_string.h @@ -134,6 +134,9 @@ INLINE upb_string *upb_string_getref(upb_string *str) { // Returns the length of the string. INLINE upb_strlen_t upb_string_len(upb_string *str) { return str->len; } +INLINE bool upb_string_isempty(upb_string *str) { + return !str || upb_string_len(str) == 0; +} // Use to read the bytes of the string. The caller *must* call // upb_string_endread() after the data has been read. The window between @@ -273,6 +276,10 @@ void upb_string_substr(upb_string *str, upb_string *target_str, //#endif #define UPB_STRLIT(str) &(upb_string)UPB_STATIC_STRING(str) +// Returns a singleton empty string. +upb_string *upb_emptystring(); + + /* upb_string library functions ***********************************************/ // Named like their <string.h> counterparts, these are all safe against buffer @@ -339,6 +346,9 @@ INLINE upb_string *upb_strdupc(const char *src) { return upb_strduplen(src, strlen(src)); } +// Returns a newly-allocated NULL-terminated copy of str. +char *upb_string_newcstr(upb_string *str); + // Appends 'append' to 's' in-place, resizing s if necessary. void upb_strcat(upb_string *s, upb_string *append); |