Sha256: f1b62ee3123c401e5f34b0a12c7a0814204f9906ab789e27cefe205e44d83b32

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_BASE_STRING_VIEW_H_
#define UPB_BASE_STRING_VIEW_H_

#include <string.h>

// Must be last.
#include "upb/port/def.inc"

#define UPB_STRINGVIEW_INIT(ptr, len) \
  { ptr, len }

#define UPB_STRINGVIEW_FORMAT "%.*s"
#define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data

// LINT.IfChange(struct_definition)
typedef struct {
  const char* data;
  size_t size;
} upb_StringView;
// LINT.ThenChange(
//  GoogleInternalName0,
//  //depot/google3/third_party/upb/bits/golang/accessor.go:map_go_string
// )

#ifdef __cplusplus
extern "C" {
#endif

UPB_API_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
                                                             size_t size) {
  upb_StringView ret;
  ret.data = data;
  ret.size = size;
  return ret;
}

UPB_INLINE upb_StringView upb_StringView_FromString(const char* data) {
  return upb_StringView_FromDataAndSize(data, strlen(data));
}

UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) {
  return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
}

#ifdef __cplusplus
} /* extern "C" */
#endif

#include "upb/port/undef.inc"

#endif /* UPB_BASE_STRING_VIEW_H_ */

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
grpc-1.60.2 third_party/upb/upb/base/string_view.h
grpc-1.61.3 third_party/upb/upb/base/string_view.h
grpc-1.62.3 third_party/upb/upb/base/string_view.h
grpc-1.62.0 third_party/upb/upb/base/string_view.h
grpc-1.62.0.pre1 third_party/upb/upb/base/string_view.h
grpc-1.61.0 third_party/upb/upb/base/string_view.h
grpc-1.61.0.pre2 third_party/upb/upb/base/string_view.h
grpc-1.60.0 third_party/upb/upb/base/string_view.h
grpc-1.60.0.pre1 third_party/upb/upb/base/string_view.h