• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google Inc.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8syntax = "proto2";
9
10package pb;
11
12import "google/protobuf/descriptor.proto";
13
14extend google.protobuf.FeatureSet {
15  optional CppFeatures cpp = 1000;
16}
17
18message CppFeatures {
19  // Whether or not to treat an enum field as closed.  This option is only
20  // applicable to enum fields, and will be removed in the future.  It is
21  // consistent with the legacy behavior of using proto3 enum types for proto2
22  // fields.
23  optional bool legacy_closed_enum = 1 [
24    retention = RETENTION_RUNTIME,
25    targets = TARGET_TYPE_FIELD,
26    targets = TARGET_TYPE_FILE,
27    feature_support = {
28      edition_introduced: EDITION_2023,
29      edition_deprecated: EDITION_2023,
30      deprecation_warning: "The legacy closed enum behavior in C++ is "
31                           "deprecated and is scheduled to be removed in "
32                           "edition 2025.  See http://protobuf.dev/programming-guides/enum/#cpp for "
33                           "more information",
34    },
35    edition_defaults = { edition: EDITION_LEGACY, value: "true" },
36    edition_defaults = { edition: EDITION_PROTO3, value: "false" }
37  ];
38
39  enum StringType {
40    STRING_TYPE_UNKNOWN = 0;
41    VIEW = 1;
42    CORD = 2;
43    STRING = 3;
44  }
45
46  optional StringType string_type = 2 [
47    retention = RETENTION_RUNTIME,
48    targets = TARGET_TYPE_FIELD,
49    targets = TARGET_TYPE_FILE,
50    feature_support = {
51      edition_introduced: EDITION_2023,
52    },
53    edition_defaults = { edition: EDITION_LEGACY, value: "STRING" },
54    edition_defaults = { edition: EDITION_2024, value: "VIEW" }
55  ];
56
57  optional bool enum_name_uses_string_view = 3 [
58    retention = RETENTION_SOURCE,
59    targets = TARGET_TYPE_ENUM,
60    targets = TARGET_TYPE_FILE,
61    feature_support = {
62      edition_introduced: EDITION_2024,
63    },
64    edition_defaults = { edition: EDITION_LEGACY, value: "false" },
65    edition_defaults = { edition: EDITION_2024, value: "true" }
66  ];
67}
68