Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba MNN Protobuf Wrappers PB H

From Leeroopedia


Metadata

Attribute Value
Implementation File 3rd_party/protobuf/src/google/protobuf/wrappers.pb.h
Line Count 1734
Domains Serialization, Type_System
Key Classes DoubleValue, FloatValue, Int64Value, UInt64Value, Int32Value, UInt32Value, BoolValue, StringValue, BytesValue
Created 2026-02-10
Knowledge Sources Repo, Doc

Overview

Generated header for the protobuf wrapper well-known types. Declares all nine wrapper message classes that wrap a single primitive value, enabling nullable semantics for proto3 scalar fields.

Usage note: Vendored dependency used internally by MNN for parsing protobuf-based model formats. Not directly imported by end users.

Description

This generated header corresponds to google/protobuf/wrappers.proto and declares the following message classes:

Wrapper Type Wrapped C++ Type Proto Field Type
DoubleValue double double value = 1
FloatValue float float value = 1
Int64Value int64_t int64 value = 1
UInt64Value uint64_t uint64 value = 1
Int32Value int32_t int32 value = 1
UInt32Value uint32_t uint32 value = 1
BoolValue bool bool value = 1
StringValue std::string string value = 1
BytesValue std::string bytes value = 1

Each class follows the standard generated message pattern:

  • Inherits from Message.
  • Provides value() / set_value() accessors.
  • Implements _InternalParse, _InternalSerialize, ByteSizeLong.
  • Supports arena allocation, copy/move construction, and swap.
  • Registers with the global descriptor pool and message factory.

Usage

#include "google/protobuf/wrappers.pb.h"

Included when .proto files reference wrapper types from google/protobuf/wrappers.proto.

Code Reference

// DoubleValue: wraps a double.
class PROTOBUF_EXPORT DoubleValue : public Message {
 public:
  DoubleValue();
  ~DoubleValue() override;
  DoubleValue(const DoubleValue& from);
  DoubleValue& operator=(const DoubleValue& from);

  static const Descriptor* descriptor();
  static const DoubleValue& default_instance();

  // Field accessor: double value = 1;
  double value() const;
  void set_value(double value);
  void clear_value();

 private:
  double value_;
};

// FloatValue: wraps a float.
class PROTOBUF_EXPORT FloatValue : public Message {
 public:
  float value() const;
  void set_value(float value);
  void clear_value();
 private:
  float value_;
};

// Int64Value: wraps an int64.
class PROTOBUF_EXPORT Int64Value : public Message {
 public:
  int64_t value() const;
  void set_value(int64_t value);
  void clear_value();
 private:
  int64_t value_;
};

// StringValue: wraps a string.
class PROTOBUF_EXPORT StringValue : public Message {
 public:
  const std::string& value() const;
  void set_value(const std::string& value);
  void set_value(std::string&& value);
  std::string* mutable_value();
  void clear_value();
 private:
  std::string value_;
};

// BoolValue: wraps a bool.
class PROTOBUF_EXPORT BoolValue : public Message {
 public:
  bool value() const;
  void set_value(bool value);
  void clear_value();
 private:
  bool value_;
};

I/O Contract

Direction Type Description
Input Wire-format bytes Binary protobuf data for a single wrapper message
Output Wire-format bytes Serialized wrapper containing tag + encoded primitive
API value() / set_value() Simple getter/setter for the wrapped scalar
Null semantics Field presence Wrapper absence in parent message indicates null; wrapper with default value indicates "set to default"

Usage Examples

// Using wrapper types for nullable fields
google::protobuf::Int32Value iv;
iv.set_value(100);

// Check if a wrapper field is set on a parent message
if (parent_msg.has_optional_int_field()) {
  int32_t val = parent_msg.optional_int_field().value();
}

// StringValue usage
google::protobuf::StringValue sv;
sv.set_value("hello");
const std::string& s = sv.value();  // "hello"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment