Blender  V3.3
obj_import_string_utils.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
5 #include "BLI_string_ref.hh"
6 
7 /*
8  * Various text parsing utilities used by OBJ importer.
9  *
10  * Many of these functions take two pointers (p, end) indicating
11  * which part of a string to operate on, and return a possibly
12  * changed new start of the string. They could be taking a StringRef
13  * as input and returning a new StringRef, but this is a hot path
14  * in OBJ parsing, and the StringRef approach does lose performance
15  * (mostly due to return of StringRef being two register-size values
16  * instead of just one pointer).
17  */
18 
19 namespace blender::io::obj {
20 
28 StringRef read_next_line(StringRef &buffer);
29 
34 void fixup_line_continuations(char *p, char *end);
35 
39 const char *drop_whitespace(const char *p, const char *end);
40 
44 const char *drop_non_whitespace(const char *p, const char *end);
45 
55 const char *parse_int(
56  const char *p, const char *end, int fallback, int &dst, bool skip_space = true);
57 
68 const char *parse_float(const char *p,
69  const char *end,
70  float fallback,
71  float &dst,
72  bool skip_space = true,
73  bool require_trailing_space = false);
74 
83 const char *parse_floats(const char *p,
84  const char *end,
85  float fallback,
86  float *dst,
87  int count,
88  bool require_trailing_space = false);
89 
90 } // namespace blender::io::obj
int count
ccl_global float * buffer
const char * parse_floats(const char *p, const char *end, float fallback, float *dst, int count, bool require_trailing_space)
void fixup_line_continuations(char *p, char *end)
const char * drop_non_whitespace(const char *p, const char *end)
const char * parse_int(const char *p, const char *end, int fallback, int &dst, bool skip_space)
const char * drop_whitespace(const char *p, const char *end)
StringRef read_next_line(StringRef &buffer)
const char * parse_float(const char *p, const char *end, float fallback, float &dst, bool skip_space, bool require_trailing_space)