new Builder(optionsopt)
Constructs a new Builder.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object.<string, *> |
<optional> |
Options |
- Source:
Classes
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:
- Object.<string, (ProtoBuf.Builder.Message|Object)> | null
- Source:
Methods
-
(static) isValidEnum(def) → {boolean}
-
Tests if a definition is a valid enum definition.
Parameters:
Name Type Description def
Object Definition
- Source:
Returns:
true if valid, else false
- Type
- boolean
-
(static) isValidExtend(def) → {boolean}
-
Tests if a definition is a valid extension.
Parameters:
Name Type Description def
Object Definition
- Source:
Returns:
true if valid, else false
- Type
- boolean
-
(static) isValidMessage(def) → {boolean}
-
Tests if a definition is a valid message definition.
Parameters:
Name Type Description def
Object.<string, *> Definition
- Source:
Returns:
true if valid, else false
- Type
- boolean
-
(static) isValidMessageField(def) → {boolean}
-
Tests if a definition is a valid message field definition.
Parameters:
Name Type Description def
Object Definition
- Source:
Returns:
true if valid, else false
- Type
- boolean
-
(static) isValidService(def) → {boolean}
-
Tests if a definition is a valid service definition.
Parameters:
Name Type Description def
Object Definition
- Source:
Returns:
true if valid, else false
- Type
- boolean
-
"import"](json, filenameopt) → {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 <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(defs) → {ProtoBuf.Builder}
-
Creates ths specified protocol types at the current pointer position.
Parameters:
Name Type Description defs
Array.<Object.<string, *>> Messages, enums or services to create
- Source:
Throws:
-
If a message definition is invalid
- Type
- Error
Returns:
this
- Type
- ProtoBuf.Builder
-
define(pkg, optionsopt) → {ProtoBuf.Builder}
-
Defines a package on top of the current pointer position and places the pointer on it.
Parameters:
Name Type Attributes Description pkg
string options
Object.<string, *> <optional>
- Source:
Throws:
-
If the package name is invalid
- Type
- Error
Returns:
this
- Type
- ProtoBuf.Builder
-
lookup(pathopt) → {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.
- Source:
Returns:
Reflection descriptor or
null
if not found- Type
- ProtoBuf.Reflect.T
-
reset()
-
Resets the pointer to the root namespace.
- Source:
-
resolveAll()
-
Resolves all namespace objects.
- Source:
Throws:
-
If a type cannot be resolved
- Type
- Error
-
toString() → {string}
-
Returns a string representation of this object.
- Source:
Returns:
String representation as of "Builder"
- Type
- string