VTK
9.7.20260913
Main Page
Related Pages
Topics
Namespaces
Classes
Files
File List
File Members
Rendering
WebGPU
Private
vtkWebGPUHelpersPrivate.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#ifndef vtkWebGPUHelpersPrivate_h
5
#define vtkWebGPUHelpersPrivate_h
6
7
#include "vtk_wgpu.h"
8
#include <string>
9
10
// Helper function for converting WGPUStringView to std::string.
11
// This is used internally by WebGPU implementations.
12
inline
std::string
vtkWebGPUStringViewToStdString
(WGPUStringView sv)
13
{
14
if
(sv.length == WGPU_STRLEN)
15
{
16
if
(sv.data ==
nullptr
)
17
{
18
return
{};
19
}
20
return
{ sv.data };
21
}
22
return
{ sv.data, sv.length };
23
}
24
25
// Helper function for constructing a WGPUStringView that borrows a std::string's
26
// storage. The returned view is only valid while the string is alive.
27
inline
WGPUStringView
vtkWebGPUMakeStringView
(
const
std::string& str)
28
{
29
return
WGPUStringView{ str.data(), str.size() };
30
}
31
32
#endif
vtkWebGPUStringViewToStdString
std::string vtkWebGPUStringViewToStdString(WGPUStringView sv)
Definition
vtkWebGPUHelpersPrivate.h:12
vtkWebGPUMakeStringView
WGPUStringView vtkWebGPUMakeStringView(const std::string &str)
Definition
vtkWebGPUHelpersPrivate.h:27
Generated on
for VTK by
1.16.1