chromium/third_party/mediapipe/src/mediapipe/framework/tool/options_field_util.cc


#include "mediapipe/framework/tool/options_field_util.h"

#include <memory>
#include <string>
#include <tuple>
#include <vector>

#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "mediapipe/framework/packet.h"
#include "mediapipe/framework/packet_type.h"
#include "mediapipe/framework/port/advanced_proto_inc.h"
#include "mediapipe/framework/port/any_proto.h"
#include "mediapipe/framework/port/canonical_errors.h"
#include "mediapipe/framework/port/ret_check.h"
#include "mediapipe/framework/port/status.h"
#include "mediapipe/framework/tool/name_util.h"
#include "mediapipe/framework/tool/proto_util_lite.h"
#include "mediapipe/framework/tool/type_util.h"

namespace mediapipe {
namespace tool {
namespace options_field_util {

WireFormatLite;
FieldType;

// Utility functions for OptionsFieldUtil.
namespace {

// The type name for the proto3 "Any" type.
constexpr absl::string_view kGoogleProtobufAny =;

// Converts a FieldDescriptor::Type to the corresponding FieldType.
FieldType AsFieldType(proto_ns::FieldDescriptorProto::Type type) {}

// Serializes a packet value.
absl::Status WriteField(const FieldData& packet, const FieldDescriptor* field,
                        std::string* result) {}

// Deserializes a packet from a protobuf field.
absl::Status ReadField(absl::string_view bytes, const FieldDescriptor& field,
                       FieldData* result) {}

// Reads all values from a repeated field.
absl::StatusOr<std::vector<FieldData>> GetFieldValues(
    const FieldData& message_data, const FieldDescriptor& field) {}

// Reads one value from a field.
absl::Status GetFieldValue(const FieldData& message_data,
                           const FieldPathEntry& entry, FieldData* result) {}

// Writes one value to a field.
absl::Status SetFieldValue(FieldData& result, const FieldPathEntry& entry,
                           const FieldData& value) {}

// Writes several values to a repeated field.
// The specified |values| replace the specified |entry| index,
// or if no index is specified all field values are replaced.
absl::Status SetFieldValues(FieldData& result, const FieldPathEntry& entry,
                            const std::vector<FieldData>& values) {}

// Returns true for a field of type "google.protobuf.Any".
bool IsProtobufAny(const FieldDescriptor* field) {}

// Returns the message FieldData from a serialized protobuf.Any.
FieldData ParseProtobufAny(const FieldData& data) {}

// Returns the serialized protobuf.Any containing a message FieldData.
FieldData SerializeProtobufAny(const FieldData& data) {}

// Returns the field index of an extension type in a repeated field.
StatusOr<int> FindExtensionIndex(const FieldData& message_data,
                                 FieldPathEntry* entry) {}

// Returns true if the value of a field is available.
bool HasField(const FieldPath& field_path, const FieldData& message_data) {}

// Returns the extension field containing the specified extension-type.
const FieldDescriptor* FindExtensionField(const FieldData& message_data,
                                          absl::string_view extension_type) {}

// Sets a protobuf in a repeated protobuf::Any field.
void SetOptionsMessage(
    const FieldData& node_options,
    proto_ns::RepeatedPtrField<mediapipe::protobuf::Any>* result) {}

}  // anonymous namespace

// Deserializes a packet containing a MessageLite value.
absl::StatusOr<Packet> ReadMessage(const std::string& value,
                                   const std::string& type_name) {}

// Merge two options FieldData values.
absl::StatusOr<FieldData> MergeMessages(const FieldData& base,
                                        const FieldData& over) {}

// Returns either the extension field or the repeated protobuf.Any field index
// holding the specified extension-type.
absl::Status FindExtension(const FieldData& message_data,
                           FieldPathEntry* entry) {}

// Return the FieldPath referencing an extension message.
FieldPath GetExtensionPath(const std::string& parent_type,
                           const std::string& extension_type,
                           const std::string& field_name,
                           bool is_protobuf_any) {}

// Returns the requested options protobuf for a graph node.
absl::StatusOr<FieldData> GetNodeOptions(const FieldData& message_data,
                                         const std::string& extension_type) {}

// Returns the requested options protobuf for a graph.
absl::StatusOr<FieldData> GetGraphOptions(const FieldData& message_data,
                                          const std::string& extension_type) {}

// Reads the FieldData values from a protobuf field.
absl::StatusOr<std::vector<FieldData>> GetFieldValues(
    const FieldData& message_data, const FieldPath& field_path) {}

// Reads a FieldData value from a protobuf field.
absl::StatusOr<FieldData> GetField(const FieldData& message_data,
                                   const FieldPath& field_path) {}

// Writes FieldData values into protobuf field.
absl::Status SetFieldValues(FieldData& message_data,
                            const FieldPath& field_path,
                            const std::vector<FieldData>& values) {}

// Writes a FieldData value into protobuf field.
absl::Status SetField(FieldData& message_data, const FieldPath& field_path,
                      const FieldData& value) {}

// Merges FieldData values into nested protobuf Message.
// For each new field index, any previous value is merged with the new value.
absl::Status MergeFieldValues(FieldData& message_data,
                              const FieldPath& field_path,
                              const std::vector<FieldData>& values) {}

// Sets the node_options field in a Node, and clears the options field.
void SetOptionsMessage(const FieldData& node_options,
                       CalculatorGraphConfig::Node* node) {}

// Serialize a MessageLite to a FieldData.
FieldData AsFieldData(const proto_ns::MessageLite& message) {}

// Represents a protobuf enum value stored in a Packet.
struct ProtoEnum {};

absl::StatusOr<Packet> AsPacket(const FieldData& data) {}

absl::StatusOr<FieldData> AsFieldData(Packet packet) {}

std::string TypeUrl(absl::string_view type_name) {}

std::string ParseTypeUrl(absl::string_view type_url) {}

}  // namespace options_field_util
}  // namespace tool
}  // namespace mediapipe