NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/trace/propagation/detail/string.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 "opentelemetry/nostd/string_view.h"
7 #include "opentelemetry/version.h"
8 
10 namespace trace
11 {
12 namespace propagation
13 {
14 // NOTE - code within `detail` namespace implements internal details, and not part
15 // of the public interface.
16 namespace detail
17 {
18 
24  char separator,
25  nostd::string_view *results,
26  size_t count)
27 {
28  if (count == 0)
29  {
30  return count;
31  }
32 
33  size_t filled = 0;
34  size_t token_start = 0;
35  for (size_t i = 0; i < s.size(); i++)
36  {
37  if (s[i] != separator)
38  {
39  continue;
40  }
41 
42  results[filled++] = s.substr(token_start, i - token_start);
43 
44  if (filled == count)
45  {
46  return count;
47  }
48 
49  token_start = i + 1;
50  }
51 
52  if (filled < count)
53  {
54  results[filled++] = s.substr(token_start);
55  }
56 
57  return filled;
58 }
59 
60 } // namespace detail
61 } // namespace propagation
62 } // namespace trace
trace
Definition: includes/opentelemetry/context/context_value.h:18
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
trace::propagation::detail::SplitString
size_t SplitString(nostd::string_view s, char separator, nostd::string_view *results, size_t count)
Splits a string by separator, up to given buffer count words.
Definition: includes/opentelemetry/trace/propagation/detail/string.h:23
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
nostd::string_view::size
size_type size() const noexcept
Definition: includes/opentelemetry/nostd/string_view.h:62
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37