# Copyright (c) 2025-2026 Buf Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated from google/protobuf/cpp_features.proto. DO NOT EDIT.
# Generated by protoc-gen-py v0.1.1 with parameter "no_fmt_off".
# ruff: noqa: PGH004
# ruff: noqa

from __future__ import annotations

from typing import Final, Literal, TYPE_CHECKING, TypeAlias

from protobuf import Enum, Extension, Message
from protobuf._codegen import file_desc

from . import descriptor_pb
from .descriptor_pb import FeatureSet

if TYPE_CHECKING:
    from protobuf import DescFile


_CppFeaturesFields: TypeAlias = Literal[
    "legacy_closed_enum", "string_type", "enum_name_uses_string_view", "repeated_type"
]


class CppFeatures(Message[_CppFeaturesFields]):
    """
    ```proto
    message pb.CppFeatures
    ```

    Attributes:
        legacy_closed_enum:
            Whether or not to treat an enum field as closed.  This option is only
            applicable to enum fields, and will be removed in the future.  It is
            consistent with the legacy behavior of using proto3 enum types for proto2
            fields.

            ```proto
            optional bool legacy_closed_enum = 1;
            ```
        string_type:
            ```proto
            optional pb.CppFeatures.StringType string_type = 2;
            ```
        enum_name_uses_string_view:
            ```proto
            optional bool enum_name_uses_string_view = 3;
            ```
        repeated_type:
            ```proto
            optional pb.CppFeatures.RepeatedType repeated_type = 4;
            ```
    """

    __slots__ = (
        "legacy_closed_enum",
        "string_type",
        "enum_name_uses_string_view",
        "repeated_type",
    )

    if TYPE_CHECKING:

        def __init__(
            self,
            *,
            legacy_closed_enum: bool | None = None,
            string_type: CppFeatures.StringType | None = None,
            enum_name_uses_string_view: bool | None = None,
            repeated_type: CppFeatures.RepeatedType | None = None,
        ) -> None:
            pass

        legacy_closed_enum: bool
        string_type: CppFeatures.StringType
        enum_name_uses_string_view: bool
        repeated_type: CppFeatures.RepeatedType

    class StringType(Enum):
        """
        ```proto
        enum pb.CppFeatures.StringType
        ```

        Attributes:
            UNKNOWN:
                ```proto
                STRING_TYPE_UNKNOWN = 0
                ```
            VIEW:
                ```proto
                VIEW = 1
                ```
            CORD:
                ```proto
                CORD = 2
                ```
            STRING:
                ```proto
                STRING = 3
                ```
        """

        UNKNOWN = 0
        VIEW = 1
        CORD = 2
        STRING = 3

    class RepeatedType(Enum):
        """
        ```proto
        enum pb.CppFeatures.RepeatedType
        ```

        Attributes:
            UNKNOWN:
                ```proto
                REPEATED_TYPE_UNKNOWN = 0
                ```
            LEGACY:
                The repeated field will be backed by proto2::Repeated(Ptr)Field, and
                accessors will return a reference/pointer to this type.

                ```proto
                LEGACY = 1
                ```
            PROXY:
                The repeated field has an opaque backing type, and accessors will return
                a RepeatedFieldProxy.

                ```proto
                PROXY = 2
                ```
        """

        UNKNOWN = 0
        LEGACY = 1
        PROXY = 2


ext_cpp: Final[Extension[FeatureSet, CppFeatures]] = Extension()
"""
```proto
extend google.protobuf.FeatureSet { optional pb.CppFeatures cpp = 1000 [json_name = "[pb.cpp]"] }
```
"""


_DESC = file_desc(
    b'\n"google/protobuf/cpp_features.proto\x12\x02pb\x1a google/protobuf/descriptor.proto"\xd6\x05\n\x0bCppFeatures\x12\x8d\x02\n\x12legacy_closed_enum\x18\x01 \x01(\x08R\x10legacyClosedEnumB\xde\x01\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\t\x18\x84\x07\x12\x04true\xa2\x01\n\x18\xe7\x07\x12\x05false\xb2\x01\xb8\x01\x08\xe8\x07\x10\xe8\x07\x1a\xaf\x01The legacy closed enum behavior in C++ is deprecated and is scheduled to be removed in edition 2025.  See http://protobuf.dev/programming-guides/enum/#cpp for more information\x12f\n\x0bstring_type\x18\x02 \x01(\x0e2\x1a.pb.CppFeatures.StringTypeR\nstringTypeB)\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x0b\x18\x84\x07\x12\x06STRING\xa2\x01\t\x18\xe9\x07\x12\x04VIEW\xb2\x01\x03\x08\xe8\x07\x12d\n\x1aenum_name_uses_string_view\x18\x03 \x01(\x08R\x16enumNameUsesStringViewB(\x88\x01\x01\x98\x01\x06\x98\x01\x01\xa2\x01\n\x18\x84\x07\x12\x05false\xa2\x01\t\x18\xe9\x07\x12\x04true\xb2\x01\x03\x08\xe9\x07\x12`\n\rrepeated_type\x18\x04 \x01(\x0e2\x1c.pb.CppFeatures.RepeatedTypeR\x0crepeatedTypeB\x1d\x88\x01\x01\x98\x01\x04\x98\x01\x01\xa2\x01\x0b\x18\x84\x07\x12\x06LEGACY\xb2\x01\x03\x08\x8fN"E\n\nStringType\x12\x17\n\x13STRING_TYPE_UNKNOWN\x10\x00\x12\x08\n\x04VIEW\x10\x01\x12\x08\n\x04CORD\x10\x02\x12\n\n\x06STRING\x10\x03"@\n\x0cRepeatedType\x12\x19\n\x15REPEATED_TYPE_UNKNOWN\x10\x00\x12\n\n\x06LEGACY\x10\x01\x12\t\n\x05PROXY\x10\x02:?\n\x03cpp\x18\xe8\x07 \x01(\x0b2\x0f.pb.CppFeatures\x12\x1b.google.protobuf.FeatureSetR\x03cpp',
    [descriptor_pb.desc()],
    {
        "CppFeatures": CppFeatures,
        "CppFeatures.StringType": CppFeatures.StringType,
        "CppFeatures.RepeatedType": CppFeatures.RepeatedType,
        "cpp": ext_cpp,
    },
)


def desc() -> DescFile:
    """Returns the descriptor for the file `google/protobuf/cpp_features.proto`."""
    return _DESC
