Blender V4.3
obj_import_string_utils.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "BLI_string_ref.hh"
8
9/*
10 * Various text parsing utilities used by OBJ importer.
11 *
12 * Many of these functions take two pointers (p, end) indicating
13 * which part of a string to operate on, and return a possibly
14 * changed new start of the string. They could be taking a StringRef
15 * as input and returning a new StringRef, but this is a hot path
16 * in OBJ parsing, and the StringRef approach does lose performance
17 * (mostly due to return of StringRef being two register-size values
18 * instead of just one pointer).
19 */
20
21namespace blender::io::obj {
22
30StringRef read_next_line(StringRef &buffer);
31
36void fixup_line_continuations(char *p, char *end);
37
41const char *drop_whitespace(const char *p, const char *end);
42
46const char *drop_non_whitespace(const char *p, const char *end);
47
57const char *parse_int(
58 const char *p, const char *end, int fallback, int &dst, bool skip_space = true);
59
70const char *parse_float(const char *p,
71 const char *end,
72 float fallback,
73 float &dst,
74 bool skip_space = true,
75 bool require_trailing_space = false);
76
85const char *parse_floats(const char *p,
86 const char *end,
87 float fallback,
88 float *dst,
89 int count,
90 bool require_trailing_space = false);
91
92} // namespace blender::io::obj
int count
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)