file_utils.h#

Helpers in this header cover path-based protobuf loading utilities for the C++ API, including onnx::LoadProtoFromPath().

namespace ONNX_LIGHT_NAMESPACE

Functions

template<typename T>
void LoadProtoFromPath(const std::string &proto_path, T &proto)#

Loads a serialized protobuf message from a filesystem path.

Opens the file at proto_path in binary mode, reads its full contents, and parses them into proto with ParseProtoFromBytes().

Template Parameters:

T – Protobuf-like message type accepted by ParseProtoFromBytes().

Parameters:
  • proto_path – UTF-8 path to the serialized protobuf file.

  • proto – Destination message that receives the parsed file contents.

Throws:

std::runtime_error – Throws when the file cannot be opened, cannot be read, or cannot be parsed as the requested protobuf type.