Browse Source

Add dstr_end function to get the last character

jp9000 11 years ago
parent
commit
dc42ac0012
1 changed files with 10 additions and 0 deletions
  1. 10 0
      libobs/util/dstr.h

+ 10 - 0
libobs/util/dstr.h

@@ -135,6 +135,8 @@ EXPORT void dstr_mid(struct dstr *dst, const struct dstr *str,
 EXPORT void dstr_right(struct dstr *dst, const struct dstr *str,
 		const size_t pos);
 
+static inline char dstr_end(const struct dstr *str);
+
 EXPORT void dstr_from_mbs(struct dstr *dst, const char *mbstr);
 EXPORT char *dstr_to_mbs(const struct dstr *str);
 EXPORT void dstr_from_wcs(struct dstr *dst, const wchar_t *wstr);
@@ -306,6 +308,14 @@ static inline int dstr_ncmpi(const struct dstr *str1, const char *str2,
 	return astrcmpi_n(str1->array, str2, n);
 }
 
+static inline char dstr_end(const struct dstr *str)
+{
+	if (dstr_isempty(str))
+		return 0;
+
+	return str->array[str->len];
+}
+
 #ifdef __cplusplus
 }
 #endif