Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-06-29 10:52:31 +0300
committerJeroen Bakker <jeroen@blender.org>2021-06-29 10:52:31 +0300
commit66d48b272e6379acb5ee5f1df532e472e1b142fd (patch)
treead84265cdd84a88ed65ec149aa9ecdd84f506b04 /source/blender/gpu/intern/gpu_shader_log.cc
parentee0c3081b08ab2c97dd86215cb9e444d16c2e19a (diff)
Cleanup: GPU Shader Log Parsing.
- Added functions to check if the cursor is at a number. - Added function to parse a number. - Joined skip_separator functions. - Added function to check if cursor is at any given set of characters.
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_log.cc')
-rw-r--r--source/blender/gpu/intern/gpu_shader_log.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_log.cc b/source/blender/gpu/intern/gpu_shader_log.cc
index 5859afb7fbf..12459b4b721 100644
--- a/source/blender/gpu/intern/gpu_shader_log.cc
+++ b/source/blender/gpu/intern/gpu_shader_log.cc
@@ -177,14 +177,41 @@ char *GPULogParser::skip_severity(char *log_line,
return log_line;
}
-char *GPULogParser::skip_separators(char *log_line, char sep1, char sep2, char sep3) const
+char *GPULogParser::skip_separators(char *log_line, const StringRef separators) const
{
- while (ELEM(log_line[0], sep1, sep2, sep3)) {
+ while (at_any(log_line, separators)) {
log_line++;
}
return log_line;
}
+char *GPULogParser::skip_until(char *log_line, char stop_char) const
+{
+ char *cursor = log_line;
+ while (!ELEM(cursor[0], '\n', '\0')) {
+ if (cursor[0] == stop_char) {
+ return cursor;
+ }
+ cursor++;
+ }
+ return log_line;
+}
+
+bool GPULogParser::at_number(const char *log_line) const
+{
+ return log_line[0] >= '0' && log_line[0] <= '9';
+}
+
+bool GPULogParser::at_any(const char *log_line, const StringRef chars) const
+{
+ return chars.find(log_line[0]) != StringRef::not_found;
+}
+
+int GPULogParser::parse_number(const char *log_line, char **r_new_position) const
+{
+ return (int)strtol(log_line, r_new_position, 10);
+}
+
/** \} */
} // namespace blender::gpu