Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh
| Context not available. | |||||
| * The utilities are not directly usable by other formats, since | * The utilities are not directly usable by other formats, since | ||||
| * they treat backslash (\) as a whitespace character (OBJ format | * they treat backslash (\) as a whitespace character (OBJ format | ||||
| * allows backslashes to function as a line-continuation character). | * 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 | |||||
| * changed new start of the string. They could be taking a StringRef | |||||
| * as input and returning a new StringRef, but this is a hot path | |||||
| * in OBJ parsing, and the StringRef approach does lose performance | |||||
| * (mostly due to return of StringRef being two register-size values | |||||
| * instead of just one pointer). | |||||
| */ | */ | ||||
| namespace blender::io::obj { | namespace blender::io::obj { | ||||
| Context not available. | |||||
| StringRef read_next_line(StringRef &buffer); | StringRef read_next_line(StringRef &buffer); | ||||
| /** | /** | ||||
| * Drop leading white-space from a StringRef. | * Drop leading white-space from a string part. | ||||
| * Note that backslash character is considered white-space. | * Note that backslash character is considered white-space. | ||||
| */ | */ | ||||
| StringRef drop_whitespace(StringRef str); | const char *drop_whitespace(const char *p, const char *end); | ||||
| /** | /** | ||||
| * Drop leading non-white-space from a StringRef. | * Drop leading non-white-space from a string part. | ||||
| * Note that backslash character is considered white-space. | * Note that backslash character is considered white-space. | ||||
| */ | */ | ||||
| StringRef drop_non_whitespace(StringRef str); | const char *drop_non_whitespace(const char *p, const char *end); | ||||
| /** | /** | ||||
| * Parse an integer from an input string. | * Parse an integer from an input string. | ||||
| Context not available. | |||||
| * number can't be parsed (invalid syntax, out of range), | * number can't be parsed (invalid syntax, out of range), | ||||
| * `fallback` value is stored instead. | * `fallback` value is stored instead. | ||||
| * | * | ||||
| * Returns the remainder of the input string after parsing. | * Returns the start of remainder of the input string after parsing. | ||||
| */ | */ | ||||
| StringRef parse_int(StringRef str, int fallback, int &dst, bool skip_space = true); | const char *parse_int( | ||||
| const char *p, const char *end, int fallback, int &dst, bool skip_space = true); | |||||
| /** | /** | ||||
| * Parse a float from an input string. | * Parse a float from an input string. | ||||
| Context not available. | |||||
| * number can't be parsed (invalid syntax, out of range), | * number can't be parsed (invalid syntax, out of range), | ||||
| * `fallback` value is stored instead. | * `fallback` value is stored instead. | ||||
| * | * | ||||
| * Returns the remainder of the input string after parsing. | * Returns the start of remainder of the input string after parsing. | ||||
| */ | */ | ||||
| StringRef parse_float(StringRef str, 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); | |||||
| /** | /** | ||||
| * Parse a number of white-space separated floats from an input string. | * Parse a number of white-space separated floats from an input string. | ||||
| Context not available. | |||||
| * number can't be parsed (invalid syntax, out of range), | * number can't be parsed (invalid syntax, out of range), | ||||
| * `fallback` value is stored instead. | * `fallback` value is stored instead. | ||||
| * | * | ||||
| * Returns the remainder of the input string after parsing. | * Returns the start of remainder of the input string after parsing. | ||||
| */ | */ | ||||
| StringRef parse_floats(StringRef str, float fallback, float *dst, int count); | const char *parse_floats(const char *p, const char *end, float fallback, float *dst, int count); | ||||
| } // namespace blender::io::obj | } // namespace blender::io::obj | ||||
| Context not available. | |||||