Compute Graph Framework SDK Reference  5.8
Util.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DW_FRAMEWORK_DWNODES_COMMON_UTIL_HPP_
32#define DW_FRAMEWORK_DWNODES_COMMON_UTIL_HPP_
33
35
36namespace dw
37{
38namespace framework
39{
40
42template <typename FixedStringT>
43void getFixedStringParam(FixedStringT& param, ParameterProvider& provider, const char* key)
44{
45 std::string str;
46 // Ignored if the parameter is not provided
47 if (provider.getOptional(key, &str))
48 {
49 if (param.max_size() < str.size())
50 {
51 throw Exception(DW_INVALID_ARGUMENT, "getFixedStringParam: FixedString parameter is not long enough, provided len: ",
52 str.size(), ", capacity: ", param.max_size());
53 }
54 else
55 {
56 param = str.c_str();
57 }
58 }
59}
60
61} // namespace framework
62} // namespace dw
63
64#endif // DW_FRAMEWORK_DWNODES_COMMON_UTIL_HPP_
The interface to access parameter values identified by name and/or (semantic) type.
bool getOptional(dw::core::StringView const &key, T *out) const
void getFixedStringParam(FixedStringT &param, ParameterProvider &provider, const char *key)
Definition: Util.hpp:43
Definition: Exception.hpp:47