Class: Builder

ProtoBuf. Builder

Provides the functionality to build protocol messages.

Constructor

new Builder(optionsopt)

Constructs a new Builder.

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

Options

Source:

Classes

Message
Service

Members

files :Array.<string>

Imported files.

Type:
  • Array.<string>
Source:

(nullable) importRoot :string

Import root override.

Type:
  • string
Source:

ns :ProtoBuf.Reflect.Namespace

Namespace.

Type:
Source:

(non-null) options :Object.<string, *>

Options.

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

ptr :ProtoBuf.Reflect.T

Namespace pointer.

Type:
Source:

resolved :boolean

Resolved flag.

Type:
  • boolean
Source:

result :Object.<string, (ProtoBuf.Builder.Message|Object)>|null

The current building result.

Type:
Source:

Methods

(static) isEnum(defnon-null) → {boolean}

Tests if a definition most likely describes an enum.

Parameters:
Name Type Description
def Object
Source:
Returns:
Type
boolean

(static) isExtend(defnon-null) → {boolean}

Tests if a definition most likely describes an extended message

Parameters:
Name Type Description
def Object
Source:
Returns:
Type
boolean

(static) isMessage(defnon-null) → {boolean}

Tests if a definition most likely describes a message.

Parameters:
Name Type Description
def Object
Source:
Returns:
Type
boolean

(static) isMessageField(defnon-null) → {boolean}

Tests if a definition most likely describes a message field.

Parameters:
Name Type Description
def Object
Source:
Returns:
Type
boolean

(static) isService(defnon-null) → {boolean}

Tests if a definition most likely describes a service.

Parameters:
Name Type Description
def Object
Source:
Returns:
Type
boolean

"import"](json, filenameopt) → (non-null) {ProtoBuf.Builder}

Imports another definition into this builder.

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

Parsed import

filename string | Object <optional>

Imported file name

Source:
Throws:

If the definition or file cannot be imported

Type
Error
Returns:

this

Type
ProtoBuf.Builder

build(pathopt) → {ProtoBuf.Builder.Message|!Object.<string, *>}

Builds the protocol. This will first try to resolve all definitions and, if this has been successful, return the built package.

Parameters:
Name Type Attributes Description
path string | Array.<string> <optional>

Specifies what to return. If omitted, the entire namespace will be returned.

Source:
Throws:

If a type could not be resolved

Type
Error
Returns:
Type
ProtoBuf.Builder.Message | !Object.<string, *>

create(defsnon-null) → (non-null) {ProtoBuf.Builder}

Creates the specified definitions at the current pointer position.

Parameters:
Name Type Description
defs Array.<!Object>

Messages, enums or services to create

Source:
Throws:

If a message definition is invalid

Type
Error
Returns:

this

Type
ProtoBuf.Builder

define(namespace) → (non-null) {ProtoBuf.Builder}

Defines a namespace on top of the current pointer position and places the pointer on it.

Parameters:
Name Type Description
namespace string
Source:
Returns:

this

Type
ProtoBuf.Builder

lookup(pathopt, excludeNonNamespaceopt) → (nullable) {ProtoBuf.Reflect.T}

Similar to ProtoBuf.Builder#build, but looks up the internal reflection descriptor.

Parameters:
Name Type Attributes Description
path string <optional>

Specifies what to return. If omitted, the entire namespace wiil be returned.

excludeNonNamespace boolean <optional>

Excludes non-namespace types like fields, defaults to false

Source:
Returns:

Reflection descriptor or null if not found

Type
ProtoBuf.Reflect.T

reset() → (non-null) {ProtoBuf.Builder}

Resets the pointer to the root namespace.

Source:
Returns:

this

Type
ProtoBuf.Builder

resolveAll() → (non-null) {ProtoBuf.Builder}

Resolves all namespace objects.

Source:
Throws:

If a type cannot be resolved

Type
Error
Returns:

this

Type
ProtoBuf.Builder

toString() → {string}

Returns a string representation of this object.

Source:
Returns:

String representation as of "Builder"

Type
string