The ProtoBuf namespace.
Classes
Namespaces
Members
-
<static> convertFieldsToCamelCase :boolean
-
If set to
true
, field names will be converted from underscore notation to camel case. Defaults tofalse
. Must be set prior to parsing. -
<static> Long :Long
-
-
<static, constant> TYPES :Object.<string,{name: string, wireType: number}>
-
Types.
-
<static, constant> VERSION :string
-
ProtoBuf.js version.
-
<static, constant> WIRE_TYPES :Object.<string,number>
-
Wire types.
-
<static, constant> WIRE_TYPES.BITS32 :number
-
Fixed 32 bits wire type.
-
<static, constant> WIRE_TYPES.BITS64 :number
-
Fixed 64 bits wire type.
-
<static, constant> WIRE_TYPES.ENDGROUP :number
-
End group wire type.
- Deprecated:
- Not supported.
-
<static, constant> WIRE_TYPES.LDELIM :number
-
Length delimited wire type.
-
<static, constant> WIRE_TYPES.STARTGROUP :number
-
Start group wire type.
- Deprecated:
- Not supported.
-
<static> WIRE_TYPES.VARINT :number
-
Varint wire type.
Methods
-
<static> loadJson(json, builder, filename) → {ProtoBuf.Builder}
-
Loads a .json definition and returns the Builder.
Parameters:
Name Type Argument Description json
* | string JSON definition
builder
ProtoBuf.Builder | string | {root: string, file: string} <optional>
Builder to append to. Will create a new one if omitted.
filename
string | {root: string, file: string} <optional>
The corresponding file name if known. Must be specified for imports.
Throws:
If the definition cannot be parsed or built- Type
- Error
Returns:
Builder to create new messages
- Type
- ProtoBuf.Builder
-
<static> loadJsonFile(filename, callback, builder) → {ProtoBuf.Builder|undefined}
-
Loads a .json file and returns the Builder.
Parameters:
Name Type Argument Description filename
string | {root: string, file: string} Path to json file or an object specifying 'file' with an overridden 'root' path for all imported files.
callback
function(ProtoBuf.Builder) <optional>
Callback that will receive the Builder as its first argument. If the request has failed, builder will be NULL. If omitted, the file will be read synchronously and this function will return the Builder or NULL if the request has failed.
builder
ProtoBuf.Builder <optional>
Builder to append to. Will create a new one if omitted.
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, builder, filename) → {ProtoBuf.Builder}
-
Loads a .proto string and returns the Builder.
Parameters:
Name Type Argument Description proto
string .proto file contents
builder
ProtoBuf.Builder | string | {root: string, file: string} <optional>
Builder to append to. Will create a new one if omitted.
filename
string | {root: string, file: string} <optional>
The corresponding file name if known. Must be specified for imports.
Throws:
If the definition cannot be parsed or built- Type
- Error
Returns:
Builder to create new messages
- Type
- ProtoBuf.Builder
-
<static> loadProtoFile(filename, callback, builder) → {ProtoBuf.Builder|undefined}
-
Loads a .proto file and returns the Builder.
Parameters:
Name Type Argument Description filename
string | {root: string, file: string} Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.
callback
function(ProtoBuf.Builder) <optional>
Callback that will receive the Builder as its first argument. If the request has failed, builder will be NULL. If omitted, the file will be read synchronously and this function will return the Builder or NULL if the request has failed.
builder
ProtoBuf.Builder <optional>
Builder to append to. Will create a new one if omitted.
Returns:
The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined
- Type
- ProtoBuf.Builder | undefined
-
<static> newBuilder(pkg, options) → {ProtoBuf.Builder}
-
Constructs a new Builder with the specified package defined.
Parameters:
Name Type Argument Description pkg
string <optional>
Package name as fully qualified name, e.g. "My.Game". If no package is specified, the builder will only contain a global namespace.
options
Object.<string,*> <optional>
Top level options
Returns:
New Builder
- Type
- ProtoBuf.Builder
-
<static> protoFromFile(filename, callback, builder) → {ProtoBuf.Builder|undefined}
-
Loads a .proto file and returns the Builder. This is an alias of ProtoBuf.loadProtoFile.
Parameters:
Name Type Argument Description filename
string | {root: string, file: string} Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.
callback
function(ProtoBuf.Builder) <optional>
Callback that will receive the Builder as its first argument. If the request has failed, builder will be NULL. If omitted, the file will be read synchronously and this function will return the Builder or NULL if the request has failed.
builder
ProtoBuf.Builder <optional>
Builder to append to. Will create a new one if omitted.
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, builder, filename) → {ProtoBuf.Builder}
-
Loads a .proto string and returns the Builder. This is an alias of ProtoBuf.loadProto.
Parameters:
Name Type Argument Description proto
string .proto file contents
builder
ProtoBuf.Builder | string <optional>
Builder to append to. Will create a new one if omitted.
filename
string | {root: string, file: string} <optional>
The corresponding file name if known. Must be specified for imports.
Throws:
If the definition cannot be parsed or built- Type
- Error
Returns:
Builder to create new messages
- Type
- ProtoBuf.Builder