Namespace: ProtoBuf

ProtoBuf

The ProtoBuf namespace.

Source:

Classes

Builder
Map

Namespaces

DotProto
Reflect
Util

Members

(static, non-null) ByteBuffer :function

Type:
  • function
Source:

(static) convertFieldsToCamelCase :boolean

If set to true, field names will be converted from underscore notation to camel case. Defaults to false. Must be set prior to parsing.

Type:
  • boolean
Source:

(static, constant) ID_MAX :number

Maximum field id.

Type:
  • number
Source:

(static, constant) ID_MIN :number

Minimum field id.

Type:
  • number
Source:

(static, non-null) Lang :Object.<string, !RegExp>

Language expressions.

Type:
  • Object.<string, !RegExp>
Source:

(static, nullable) Long :function

Type:
  • function
Source:

(static, constant, non-null) MAP_KEY_TYPES :Array.<!Object.<string, {name: string, wireType: number, defaultValue: *}>>

Valid map key types.

Type:
  • Array.<!Object.<string, {name: string, wireType: number, defaultValue: *}>>
Source:

(static, constant, non-null) PACKABLE_WIRE_TYPES :Array.<number>

Packable wire types.

Type:
  • Array.<number>
Source:

(static) populateAccessors :boolean

By default, messages are populated with (setX, set_x) accessors for each field. This can be disabled by setting this to false prior to building messages.

Type:
  • boolean
Source:

(static) populateDefaults :boolean

By default, messages are populated with default values if a field is not present on the wire. To disable this behavior, set this setting to false.

Type:
  • boolean
Source:

(static, constant, non-null) TYPES :Object.<string, {name: string, wireType: number, defaultValue: *}>

Types.

Type:
  • Object.<string, {name: string, wireType: number, defaultValue: *}>
Source:

(static, constant) VERSION :string

ProtoBuf.js version.

Type:
  • string
Source:

(static, constant) WIRE_TYPES :Object.<string, number>

Wire types.

Type:
  • Object.<string, number>
Source:

(static, constant) WIRE_TYPES.BITS32 :number

Fixed 32 bits wire type.

Type:
  • number
Source:

(static, constant) WIRE_TYPES.BITS64 :number

Fixed 64 bits wire type.

Type:
  • number
Source:

(static, constant) WIRE_TYPES.ENDGROUP :number

End group wire type.

Type:
  • number
Source:

(static, constant) WIRE_TYPES.LDELIM :number

Length delimited wire type.

Type:
  • number
Source:

(static, constant) WIRE_TYPES.STARTGROUP :number

Start group wire type.

Type:
  • number
Source:

(static) WIRE_TYPES.VARINT :number

Varint wire type.

Type:
  • number
Source:

Methods

(static) loadJson(json, builderopt, filenameopt) → {ProtoBuf.Builder}

Loads a .json definition and returns the Builder.

Parameters:
Name Type Attributes Description
json * | string

JSON definition

builder ProtoBuf.Builder | string | Object <optional>

Builder to append to. Will create a new one if omitted.

filename string | Object <optional>

The corresponding file name if known. Must be specified for imports.

Source:
Throws:

If the definition cannot be parsed or built

Type
Error
Returns:

Builder to create new messages

Type
ProtoBuf.Builder

(static) loadJsonFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

Loads a .json file and returns the Builder.

Parameters:
Name Type Attributes Description
filename string | Object

Path to json file or an object specifying 'file' with an overridden 'root' path for all imported files.

callback function <optional>

Callback that will receive null as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.

builder ProtoBuf.Builder <optional>

Builder to append to. Will create a new one if omitted.

Source:
Returns:

The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

Type
ProtoBuf.Builder | undefined

(static) loadProto(proto, builderopt, filenameopt) → {ProtoBuf.Builder}

Loads a .proto string and returns the Builder.

Parameters:
Name Type Attributes Description
proto string

.proto file contents

builder ProtoBuf.Builder | string | Object <optional>

Builder to append to. Will create a new one if omitted.

filename string | Object <optional>

The corresponding file name if known. Must be specified for imports.

Source:
Throws:

If the definition cannot be parsed or built

Type
Error
Returns:

Builder to create new messages

Type
ProtoBuf.Builder

(static) loadProtoFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

Loads a .proto file and returns the Builder.

Parameters:
Name Type Attributes Description
filename string | Object

Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.

callback function <optional>

Callback that will receive null as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.

builder ProtoBuf.Builder <optional>

Builder to append to. Will create a new one if omitted.

Source:
Returns:

The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

Type
ProtoBuf.Builder | undefined

(static) newBuilder(optionsopt) → (non-null) {ProtoBuf.Builder}

Constructs a new empty Builder.

Parameters:
Name Type Attributes Description
options Object.<string, *> <optional>

Builder options, defaults to global options set on ProtoBuf

Source:
Returns:

Builder

Type
ProtoBuf.Builder

(static) protoFromFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

Loads a .proto file and returns the Builder. This is an alias of ProtoBuf.loadProtoFile.

Parameters:
Name Type Attributes Description
filename string | Object

Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.

callback function <optional>

Callback that will receive null as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.

builder ProtoBuf.Builder <optional>

Builder to append to. Will create a new one if omitted.

Source:
Returns:

The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

Type
ProtoBuf.Builder | undefined

(static) protoFromString(proto, builderopt, filenameopt) → {ProtoBuf.Builder}

Loads a .proto string and returns the Builder. This is an alias of ProtoBuf.loadProto.

Parameters:
Name Type Attributes Description
proto string

.proto file contents

builder ProtoBuf.Builder | string <optional>

Builder to append to. Will create a new one if omitted.

filename string | Object <optional>

The corresponding file name if known. Must be specified for imports.

Source:
Throws:

If the definition cannot be parsed or built

Type
Error
Returns:

Builder to create new messages

Type
ProtoBuf.Builder