Procházet zdrojové kódy

libobs/util: Add func to go to next CF token and copy it

Adds a function to the C-family parser to go to the next token and
create a string copy of it.  Useful for when you want to get a copy of
the next token regardless of what type it is.
jp9000 před 9 roky
rodič
revize
d5e2cdf4d3
1 změnil soubory, kde provedl 9 přidání a 0 odebrání
  1. 9 0
      libobs/util/cf-parser.h

+ 9 - 0
libobs/util/cf-parser.h

@@ -264,6 +264,15 @@ static inline int cf_next_name(struct cf_parser *p, char **dst,
 	return cf_get_name(p, dst, name, goto_token);
 }
 
+static inline int cf_next_token_copy(struct cf_parser *p, char **dst)
+{
+	if (!cf_next_valid_token(p))
+		return PARSE_EOF;
+
+	cf_copy_token(p, dst);
+	return PARSE_SUCCESS;
+}
+
 static inline int cf_get_name_ref(struct cf_parser *p, struct strref *dst,
 		const char *name, const char *goto_token)
 {