|
69 | 69 | #include "absl/container/flat_hash_map.h"
|
70 | 70 | #include "absl/log/absl_check.h"
|
71 | 71 | #include "absl/log/absl_log.h"
|
| 72 | +#include "absl/strings/str_format.h" |
72 | 73 | #include "absl/strings/string_view.h"
|
73 | 74 | #include "absl/synchronization/mutex.h"
|
74 | 75 | #include "absl/types/optional.h"
|
@@ -347,6 +348,12 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
|
347 | 348 | // include original user comments in output).
|
348 | 349 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
349 | 350 |
|
| 351 | + // Allows formatting with absl and gtest. |
| 352 | + template <typename Sink> |
| 353 | + friend void AbslStringify(Sink& sink, const Descriptor& d) { |
| 354 | + absl::Format(&sink, "%s", d.DebugString()); |
| 355 | + } |
| 356 | + |
350 | 357 | // Returns true if this is a placeholder for an unknown type. This will
|
351 | 358 | // only be the case if this descriptor comes from a DescriptorPool
|
352 | 359 | // with AllowUnknownDependencies() set.
|
@@ -981,6 +988,12 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
|
981 | 988 | // See Descriptor::DebugStringWithOptions().
|
982 | 989 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
983 | 990 |
|
| 991 | + // Allows formatting with absl and gtest. |
| 992 | + template <typename Sink> |
| 993 | + friend void AbslStringify(Sink& sink, const FieldDescriptor& d) { |
| 994 | + absl::Format(&sink, "%s", d.DebugString()); |
| 995 | + } |
| 996 | + |
984 | 997 | // Helper method to get the CppType for a particular Type.
|
985 | 998 | static CppType TypeToCppType(Type type);
|
986 | 999 |
|
@@ -1186,6 +1199,12 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
|
1186 | 1199 | // See Descriptor::DebugStringWithOptions().
|
1187 | 1200 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1188 | 1201 |
|
| 1202 | + // Allows formatting with absl and gtest. |
| 1203 | + template <typename Sink> |
| 1204 | + friend void AbslStringify(Sink& sink, const OneofDescriptor& d) { |
| 1205 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1206 | + } |
| 1207 | + |
1189 | 1208 | // Source Location ---------------------------------------------------
|
1190 | 1209 |
|
1191 | 1210 | // Updates |*out_location| to the source location of the complete
|
@@ -1307,6 +1326,12 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
|
1307 | 1326 | // See Descriptor::DebugStringWithOptions().
|
1308 | 1327 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1309 | 1328 |
|
| 1329 | + // Allows formatting with absl and gtest. |
| 1330 | + template <typename Sink> |
| 1331 | + friend void AbslStringify(Sink& sink, const EnumDescriptor& d) { |
| 1332 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1333 | + } |
| 1334 | + |
1310 | 1335 | // Returns true if this is a placeholder for an unknown enum. This will
|
1311 | 1336 | // only be the case if this descriptor comes from a DescriptorPool
|
1312 | 1337 | // with AllowUnknownDependencies() set.
|
@@ -1500,6 +1525,12 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
|
1500 | 1525 | // See Descriptor::DebugStringWithOptions().
|
1501 | 1526 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1502 | 1527 |
|
| 1528 | + // Allows formatting with absl and gtest. |
| 1529 | + template <typename Sink> |
| 1530 | + friend void AbslStringify(Sink& sink, const EnumValueDescriptor& d) { |
| 1531 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1532 | + } |
| 1533 | + |
1503 | 1534 | // Source Location ---------------------------------------------------
|
1504 | 1535 |
|
1505 | 1536 | // Updates |*out_location| to the source location of the complete
|
@@ -1597,6 +1628,12 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
|
1597 | 1628 | // See Descriptor::DebugStringWithOptions().
|
1598 | 1629 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1599 | 1630 |
|
| 1631 | + // Allows formatting with absl and gtest. |
| 1632 | + template <typename Sink> |
| 1633 | + friend void AbslStringify(Sink& sink, const ServiceDescriptor& d) { |
| 1634 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1635 | + } |
| 1636 | + |
1600 | 1637 | // Source Location ---------------------------------------------------
|
1601 | 1638 |
|
1602 | 1639 | // Updates |*out_location| to the source location of the complete
|
@@ -1698,6 +1735,12 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase {
|
1698 | 1735 | // See Descriptor::DebugStringWithOptions().
|
1699 | 1736 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1700 | 1737 |
|
| 1738 | + // Allows formatting with absl and gtest. |
| 1739 | + template <typename Sink> |
| 1740 | + friend void AbslStringify(Sink& sink, const MethodDescriptor& d) { |
| 1741 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1742 | + } |
| 1743 | + |
1701 | 1744 | // Source Location ---------------------------------------------------
|
1702 | 1745 |
|
1703 | 1746 | // Updates |*out_location| to the source location of the complete
|
@@ -1913,6 +1956,12 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
|
1913 | 1956 | // See Descriptor::DebugStringWithOptions().
|
1914 | 1957 | std::string DebugStringWithOptions(const DebugStringOptions& options) const;
|
1915 | 1958 |
|
| 1959 | + // Allows formatting with absl and gtest. |
| 1960 | + template <typename Sink> |
| 1961 | + friend void AbslStringify(Sink& sink, const FileDescriptor& d) { |
| 1962 | + absl::Format(&sink, "%s", d.DebugString()); |
| 1963 | + } |
| 1964 | + |
1916 | 1965 | // Returns true if this is a placeholder for an unknown file. This will
|
1917 | 1966 | // only be the case if this descriptor comes from a DescriptorPool
|
1918 | 1967 | // with AllowUnknownDependencies() set.
|
|
0 commit comments