Blender V5.3
IO_string_utils.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_string_ref.hh"
12
13/*
14 * Various text parsing utilities used by importers.
15 *
16 * Many of these functions take two pointers (p, end) indicating
17 * which part of a string to operate on, and return a possibly
18 * changed new start of the string. They could be taking a StringRef
19 * as input and returning a new StringRef, but this is a hot path
20 * in CSV and OBJ parsing, and the StringRef approach does lose performance
21 * (mostly due to return of StringRef being two register-size values
22 * instead of just one pointer).
23 */
24
25namespace blender::io {
26
34StringRef read_next_line(StringRef &buffer);
35
39const char *drop_whitespace(const char *p, const char *end);
40
44const char *drop_non_whitespace(const char *p, const char *end);
45
55const char *try_parse_int(
56 const char *p, const char *end, int fallback, bool &success, int &dst, bool skip_space = true);
57
67const char *try_parse_float(const char *p,
68 const char *end,
69 int fallback,
70 bool &success,
71 float &dst,
72 bool skip_space = true);
73
83const char *parse_int(
84 const char *p, const char *end, int fallback, int &dst, bool skip_space = true);
85
96const char *parse_float(const char *p,
97 const char *end,
98 float fallback,
99 float &dst,
100 bool skip_space = true,
101 bool require_trailing_space = false);
102
111const char *parse_floats(const char *p,
112 const char *end,
113 float fallback,
114 float *dst,
115 int count,
116 bool require_trailing_space = false);
117
118} // namespace blender::io
const char * parse_float(const char *p, const char *end, float fallback, float &dst, bool skip_space, bool require_trailing_space)
const char * parse_floats(const char *p, const char *end, float fallback, float *dst, int count, bool require_trailing_space)
const char * drop_non_whitespace(const char *p, const char *end)
StringRef read_next_line(StringRef &buffer)
const char * try_parse_int(const char *p, const char *end, int fallback, bool &success, int &dst, bool skip_space)
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)
const char * try_parse_float(const char *p, const char *end, int fallback, bool &success, float &dst, bool skip_space)