katydid: github.com/katydid/katydid/parser/proto Index | Files | Directories

package proto

import "github.com/katydid/katydid/parser/proto"

Package proto contains an implementation of a protocol buffer parser.

Merging of fields and splitting of arrays are not supported by this parser for optimization reasons. Use the NoLatentAppendingOrMerging function to check whether the marshaled buffer conforms to the limitations.

TODO: defaults, maps and proto3 zero values


Package Files

desc.go nomerge.go proto.go

func NoLatentAppendingOrMerging Uses

func NoLatentAppendingOrMerging(parser ProtoParser) error

NoLatentAppendingOrMerging returns whether the current parser has some latent fields. Latent fields are those fields you have already seen on your walk, but then after seeing a different field you see this field again. This typically happens when the protocol buffer user created an object marshaled it and then merged it with another value.

type DescMap Uses

type DescMap interface {
    //GetRoot returns the root message that was used to create this map.
    GetRoot() *descriptor.DescriptorProto
    //LookupMessage returns the message descriptor of the field type.
    LookupMessage(field *descriptor.FieldDescriptorProto) *descriptor.DescriptorProto
    //LookupFields returns a map of field key to field descriptor in the message.
    LookupFields(msg *descriptor.DescriptorProto) map[uint64]*descriptor.FieldDescriptorProto

DescMap is a map of the descriptor.FileDescriptorSet

func NewDescriptorMap Uses

func NewDescriptorMap(pkgName, msgName string, desc *descriptor.FileDescriptorSet) (DescMap, error)

NewDescriptorMap returns a map of the FileDescriptorSet starting at the message represented by the package name and message name.

type ProtoParser Uses

type ProtoParser interface {
    //Init initialises the parser with a marshaled protocol buffer.
    Init([]byte) error
    //Reset resets the parser to go back to the beginnig.
    Reset() error
    //Message returns the current message's descriptor.
    Message() *descriptor.DescriptorProto
    //Field returns the current field's descriptor.
    Field() *descriptor.FieldDescriptorProto

ProtoParser represents a protocol buffer parser.

func NewProtoParser Uses

func NewProtoParser(rootPackage, rootMessage string, desc *descriptor.FileDescriptorSet) (ProtoParser, error)

NewProtoParser returns a new protocol buffer parser the specific root message. When the value of a field name is requested this parser will return the field name using the String method.


prototestsPackage prototests contains some structures and values that are useful for testing the protocol buffer parser.

Package proto imports 8 packages (graph) and is imported by 2 packages. Updated 2018-08-29. Refresh now. Tools for package owners.