diff options
Diffstat (limited to 'source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh')
-rw-r--r-- | source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh index 3f428b1ab5c..e42f5080d25 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh @@ -6,9 +6,6 @@ /* * Various text parsing utilities used by OBJ importer. - * The utilities are not directly usable by other formats, since - * they treat backslash (\) as a whitespace character (OBJ format - * allows backslashes to function as a line-continuation character). * * Many of these functions take two pointers (p, end) indicating * which part of a string to operate on, and return a possibly @@ -27,21 +24,22 @@ namespace blender::io::obj { * The returned line will not have '\n' characters at the end; * the `buffer` is modified to contain remaining text without * the input line. - * - * Note that backslash (\) character is treated as a line - * continuation. */ StringRef read_next_line(StringRef &buffer); /** + * Fix up OBJ line continuations by replacing backslash (\) and the + * following newline with spaces. + */ +void fixup_line_continuations(char *p, char *end); + +/** * Drop leading white-space from a string part. - * Note that backslash character is considered white-space. */ const char *drop_whitespace(const char *p, const char *end); /** * Drop leading non-white-space from a string part. - * Note that backslash character is considered white-space. */ const char *drop_non_whitespace(const char *p, const char *end); @@ -62,12 +60,17 @@ const char *parse_int( * The parsed result is stored in `dst`. The function skips * leading white-space unless `skip_space=false`. If the * number can't be parsed (invalid syntax, out of range), - * `fallback` value is stored instead. + * `fallback` value is stored instead. If `require_trailing_space` + * is true, the character after the number has to be whitespace. * * Returns the start of remainder of the input string after parsing. */ -const char *parse_float( - const char *p, const char *end, float fallback, float &dst, bool skip_space = true); +const char *parse_float(const char *p, + const char *end, + float fallback, + float &dst, + bool skip_space = true, + bool require_trailing_space = false); /** * Parse a number of white-space separated floats from an input string. @@ -77,6 +80,11 @@ const char *parse_float( * * Returns the start of remainder of the input string after parsing. */ -const char *parse_floats(const char *p, const char *end, float fallback, float *dst, int count); +const char *parse_floats(const char *p, + const char *end, + float fallback, + float *dst, + int count, + bool require_trailing_space = false); } // namespace blender::io::obj |