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

Index

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 {
    parser.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 NewProtoNameParser Uses

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

NewProtoNameParser 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.

func NewProtoNumParser Uses

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

NewProtoNumParser 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 number using the Uint method.

Directories

PathSynopsis
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 3 packages. Updated 2018-07-21. Refresh now. Tools for package owners.