| 1527 | }; |
| 1528 | |
| 1529 | class DynamicJsonAccessor final : public JsonAccessor { |
| 1530 | public: |
| 1531 | void InitializeValue(const google::protobuf::Message& message) { |
| 1532 | ABSL_CHECK_OK(reflection_.Initialize(message.GetDescriptor())); // Crash OK |
| 1533 | } |
| 1534 | |
| 1535 | void InitializeListValue(const google::protobuf::Message& message) { |
| 1536 | ABSL_CHECK_OK(reflection_.Initialize(message.GetDescriptor())); // Crash OK |
| 1537 | } |
| 1538 | |
| 1539 | void InitializeStruct(const google::protobuf::Message& message) { |
| 1540 | ABSL_CHECK_OK(reflection_.Initialize(message.GetDescriptor())); // Crash OK |
| 1541 | } |
| 1542 | |
| 1543 | google::protobuf::Value::KindCase GetKindCase( |
| 1544 | const google::protobuf::MessageLite& message) const override { |
| 1545 | return reflection_.Value().GetKindCase( |
| 1546 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1547 | } |
| 1548 | |
| 1549 | bool GetBoolValue(const google::protobuf::MessageLite& message) const override { |
| 1550 | return reflection_.Value().GetBoolValue( |
| 1551 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1552 | } |
| 1553 | |
| 1554 | double GetNumberValue(const google::protobuf::MessageLite& message) const override { |
| 1555 | return reflection_.Value().GetNumberValue( |
| 1556 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1557 | } |
| 1558 | |
| 1559 | well_known_types::StringValue GetStringValue( |
| 1560 | const google::protobuf::MessageLite& message, std::string& scratch) const override { |
| 1561 | return reflection_.Value().GetStringValue( |
| 1562 | google::protobuf::DownCastMessage<google::protobuf::Message>(message), scratch); |
| 1563 | } |
| 1564 | |
| 1565 | const google::protobuf::MessageLite& GetListValue( |
| 1566 | const google::protobuf::MessageLite& message) const override { |
| 1567 | return reflection_.Value().GetListValue( |
| 1568 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1569 | } |
| 1570 | |
| 1571 | int ValuesSize(const google::protobuf::MessageLite& message) const override { |
| 1572 | return reflection_.ListValue().ValuesSize( |
| 1573 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1574 | } |
| 1575 | |
| 1576 | const google::protobuf::MessageLite& Values(const google::protobuf::MessageLite& message, |
| 1577 | int index) const override { |
| 1578 | return reflection_.ListValue().Values( |
| 1579 | google::protobuf::DownCastMessage<google::protobuf::Message>(message), index); |
| 1580 | } |
| 1581 | |
| 1582 | const google::protobuf::MessageLite& GetStructValue( |
| 1583 | const google::protobuf::MessageLite& message) const override { |
| 1584 | return reflection_.Value().GetStructValue( |
| 1585 | google::protobuf::DownCastMessage<google::protobuf::Message>(message)); |
| 1586 | } |