NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/includes/opentelemetry/common/string_util.h
Go to the documentation of this file.
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include <ctype.h>
7 
8 #include "opentelemetry/nostd/string_view.h"
9 #include "opentelemetry/version.h"
10 
12 namespace common
13 {
14 
15 class StringUtil
16 {
17 public:
18  static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
19  {
20  while (left <= right && isspace(str[left]))
21  {
22  left++;
23  }
24  while (left <= right && isspace(str[right]))
25  {
26  right--;
27  }
28  return str.substr(left, 1 + right - left);
29  }
30 
32  {
33  if (str.empty())
34  {
35  return str;
36  }
37 
38  return Trim(str, 0, str.size() - 1);
39  }
40 };
41 
42 } // namespace common
43 
common::StringUtil::Trim
static nostd::string_view Trim(nostd::string_view str) noexcept
Definition: 9.2/includes/opentelemetry/common/string_util.h:31
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
nostd::string_view::substr
string_view substr(size_type pos, size_type n=npos) const
Definition: includes/opentelemetry/nostd/string_view.h:70
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
common::StringUtil::Trim
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
Definition: 9.2/includes/opentelemetry/common/string_util.h:18
common
Definition: includes/opentelemetry/common/attribute_value.h:14
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37