#include "mediapipe/framework/tool/proto_util_lite.h"
#include <tuple>
#include "absl/log/absl_check.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "mediapipe/framework/port/canonical_errors.h"
#include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/port/ret_check.h"
#include "mediapipe/framework/port/statusor.h"
#include "mediapipe/framework/tool/field_data.pb.h"
#include "mediapipe/framework/type_map.h"
#define RET_CHECK_NO_LOG(cond) …
namespace mediapipe {
namespace tool {
ArrayInputStream;
CodedInputStream;
CodedOutputStream;
StringOutputStream;
WireFormatLite;
FieldAccess;
FieldValue;
using ProtoPath = ProtoUtilLite::ProtoPath;
FieldType;
FieldData;
bool IsLengthDelimited(WireFormatLite::WireType wire_type) { … }
absl::Status ReadFieldValue(uint32_t tag, CodedInputStream* in,
std::string* result) { … }
absl::Status ReadPackedValues(WireFormatLite::WireType wire_type,
CodedInputStream* in,
std::vector<std::string>* field_values) { … }
absl::Status GetFieldValues(uint32_t field_id, CodedInputStream* in,
CodedOutputStream* out,
std::vector<std::string>* field_values) { … }
void SetFieldValues(uint32_t field_id, WireFormatLite::WireType wire_type,
const std::vector<std::string>& field_values,
CodedOutputStream* out) { … }
FieldAccess::FieldAccess(uint32_t field_id, FieldType field_type)
: … { … }
absl::Status FieldAccess::SetMessage(const std::string& message) { … }
void FieldAccess::GetMessage(std::string* result) { … }
std::vector<FieldValue>* FieldAccess::mutable_field_values() { … }
namespace {
ProtoPathEntry;
absl::StatusOr<std::pair<FieldAccess, int>> AccessField(
const ProtoPathEntry& entry, FieldType field_type,
const FieldValue& message) { … }
}
absl::Status ProtoUtilLite::ReplaceFieldRange(
FieldValue* message, ProtoPath proto_path, int length, FieldType field_type,
const std::vector<FieldValue>& field_values) { … }
absl::Status ProtoUtilLite::GetFieldRange(
const FieldValue& message, ProtoPath proto_path, int length,
FieldType field_type, std::vector<FieldValue>* field_values) { … }
absl::Status ProtoUtilLite::GetFieldCount(const FieldValue& message,
ProtoPath proto_path,
FieldType field_type,
int* field_count) { … }
template <typename T>
absl::Status SyntaxStatus(bool ok, const std::string& text, T* result) { … }
template <typename T>
absl::Status ParseValue(const std::string& text, T* result) { … }
template <>
absl::Status ParseValue<double>(const std::string& text, double* result) { … }
template <>
absl::Status ParseValue<float>(const std::string& text, float* result) { … }
template <>
absl::Status ParseValue<bool>(const std::string& text, bool* result) { … }
template <>
absl::Status ParseValue<std::string>(const std::string& text,
std::string* result) { … }
template <typename T>
std::string FormatValue(T v) { … }
template <typename T>
absl::Status WritePrimitive(void (*writer)(T, proto_ns::io::CodedOutputStream*),
const std::string& text, CodedOutputStream* out) { … }
static absl::Status SerializeValue(const std::string& text,
FieldType field_type,
FieldValue* field_value) { … }
template <typename CType, FieldType DeclaredType>
static absl::Status ReadPrimitive(CodedInputStream* input,
std::string* result) { … }
static absl::Status DeserializeValue(const FieldValue& bytes,
FieldType field_type,
std::string* result) { … }
absl::Status ProtoUtilLite::Serialize(
const std::vector<std::string>& text_values, FieldType field_type,
std::vector<FieldValue>* result) { … }
absl::Status ProtoUtilLite::Deserialize(
const std::vector<FieldValue>& field_values, FieldType field_type,
std::vector<std::string>* result) { … }
absl::Status ProtoUtilLite::WriteValue(const FieldData& value,
FieldType field_type,
std::string* field_bytes) { … }
template <typename ValueT, FieldType kFieldType>
static ValueT ReadValue(absl::string_view field_bytes, absl::Status* status) { … }
absl::Status ReadValue(absl::string_view field_bytes, FieldType field_type,
absl::string_view message_type, FieldData* result) { … }
absl::Status ProtoUtilLite::ReadValue(absl::string_view field_bytes,
FieldType field_type,
absl::string_view message_type,
FieldData* result) { … }
std::string ProtoUtilLite::TypeUrl(absl::string_view type_name) { … }
std::string ProtoUtilLite::ParseTypeUrl(absl::string_view type_url) { … }
}
}