Adrià Vilanova MartÃnez | 413cb44 | 2021-09-06 00:30:45 +0200 | [diff] [blame] | 1 | // source: google/protobuf/any.proto |
| 2 | /** |
| 3 | * @fileoverview |
| 4 | * @enhanceable |
| 5 | * @suppress {missingRequire} reports error on implicit type usages. |
| 6 | * @suppress {messageConventions} JS Compiler reports an error if a variable or |
| 7 | * field starts with 'MSG_' and isn't a translatable message. |
| 8 | * @public |
| 9 | */ |
| 10 | // GENERATED CODE -- DO NOT EDIT! |
| 11 | /* eslint-disable */ |
| 12 | // @ts-nocheck |
| 13 | |
| 14 | var jspb = require('google-protobuf'); |
| 15 | var goog = jspb; |
| 16 | var proto = {}; |
| 17 | |
| 18 | goog.exportSymbol('google.protobuf.Any', null, proto); |
| 19 | /** |
| 20 | * Generated by JsPbCodeGenerator. |
| 21 | * @param {Array=} opt_data Optional initial data array, typically from a |
| 22 | * server response, or constructed directly in Javascript. The array is used |
| 23 | * in place and becomes part of the constructed object. It is not cloned. |
| 24 | * If no data is provided, the constructed object will be empty, but still |
| 25 | * valid. |
| 26 | * @extends {jspb.Message} |
| 27 | * @constructor |
| 28 | */ |
| 29 | proto.google.protobuf.Any = function(opt_data) { |
| 30 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
| 31 | }; |
| 32 | goog.inherits(proto.google.protobuf.Any, jspb.Message); |
| 33 | if (goog.DEBUG && !COMPILED) { |
| 34 | /** |
| 35 | * @public |
| 36 | * @override |
| 37 | */ |
| 38 | proto.google.protobuf.Any.displayName = 'proto.google.protobuf.Any'; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |
| 43 | if (jspb.Message.GENERATE_TO_OBJECT) { |
| 44 | /** |
| 45 | * Creates an object representation of this proto. |
| 46 | * Field names that are reserved in JavaScript and will be renamed to pb_name. |
| 47 | * Optional fields that are not set will be set to undefined. |
| 48 | * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
| 49 | * For the list of reserved names please see: |
| 50 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. |
| 51 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the |
| 52 | * JSPB instance for transitional soy proto support: |
| 53 | * http://goto/soy-param-migration |
| 54 | * @return {!Object} |
| 55 | */ |
| 56 | proto.google.protobuf.Any.prototype.toObject = function(opt_includeInstance) { |
| 57 | return proto.google.protobuf.Any.toObject(opt_includeInstance, this); |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * Static version of the {@see toObject} method. |
| 63 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include |
| 64 | * the JSPB instance for transitional soy proto support: |
| 65 | * http://goto/soy-param-migration |
| 66 | * @param {!proto.google.protobuf.Any} msg The msg instance to transform. |
| 67 | * @return {!Object} |
| 68 | * @suppress {unusedLocalVariables} f is only used for nested messages |
| 69 | */ |
| 70 | proto.google.protobuf.Any.toObject = function(includeInstance, msg) { |
| 71 | var f, obj = { |
| 72 | typeUrl: jspb.Message.getFieldWithDefault(msg, 1, ""), |
| 73 | value: msg.getValue_asB64() |
| 74 | }; |
| 75 | |
| 76 | if (includeInstance) { |
| 77 | obj.$jspbMessageInstance = msg; |
| 78 | } |
| 79 | return obj; |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
| 85 | * Deserializes binary data (in protobuf wire format). |
| 86 | * @param {jspb.ByteSource} bytes The bytes to deserialize. |
| 87 | * @return {!proto.google.protobuf.Any} |
| 88 | */ |
| 89 | proto.google.protobuf.Any.deserializeBinary = function(bytes) { |
| 90 | var reader = new jspb.BinaryReader(bytes); |
| 91 | var msg = new proto.google.protobuf.Any; |
| 92 | return proto.google.protobuf.Any.deserializeBinaryFromReader(msg, reader); |
| 93 | }; |
| 94 | |
| 95 | |
| 96 | /** |
| 97 | * Deserializes binary data (in protobuf wire format) from the |
| 98 | * given reader into the given message object. |
| 99 | * @param {!proto.google.protobuf.Any} msg The message object to deserialize into. |
| 100 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. |
| 101 | * @return {!proto.google.protobuf.Any} |
| 102 | */ |
| 103 | proto.google.protobuf.Any.deserializeBinaryFromReader = function(msg, reader) { |
| 104 | while (reader.nextField()) { |
| 105 | if (reader.isEndGroup()) { |
| 106 | break; |
| 107 | } |
| 108 | var field = reader.getFieldNumber(); |
| 109 | switch (field) { |
| 110 | case 1: |
| 111 | var value = /** @type {string} */ (reader.readString()); |
| 112 | msg.setTypeUrl(value); |
| 113 | break; |
| 114 | case 2: |
| 115 | var value = /** @type {!Uint8Array} */ (reader.readBytes()); |
| 116 | msg.setValue(value); |
| 117 | break; |
| 118 | default: |
| 119 | reader.skipField(); |
| 120 | break; |
| 121 | } |
| 122 | } |
| 123 | return msg; |
| 124 | }; |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * Serializes the message to binary data (in protobuf wire format). |
| 129 | * @return {!Uint8Array} |
| 130 | */ |
| 131 | proto.google.protobuf.Any.prototype.serializeBinary = function() { |
| 132 | var writer = new jspb.BinaryWriter(); |
| 133 | proto.google.protobuf.Any.serializeBinaryToWriter(this, writer); |
| 134 | return writer.getResultBuffer(); |
| 135 | }; |
| 136 | |
| 137 | |
| 138 | /** |
| 139 | * Serializes the given message to binary data (in protobuf wire |
| 140 | * format), writing to the given BinaryWriter. |
| 141 | * @param {!proto.google.protobuf.Any} message |
| 142 | * @param {!jspb.BinaryWriter} writer |
| 143 | * @suppress {unusedLocalVariables} f is only used for nested messages |
| 144 | */ |
| 145 | proto.google.protobuf.Any.serializeBinaryToWriter = function(message, writer) { |
| 146 | var f = undefined; |
| 147 | f = message.getTypeUrl(); |
| 148 | if (f.length > 0) { |
| 149 | writer.writeString( |
| 150 | 1, |
| 151 | f |
| 152 | ); |
| 153 | } |
| 154 | f = message.getValue_asU8(); |
| 155 | if (f.length > 0) { |
| 156 | writer.writeBytes( |
| 157 | 2, |
| 158 | f |
| 159 | ); |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /** |
| 165 | * optional string type_url = 1; |
| 166 | * @return {string} |
| 167 | */ |
| 168 | proto.google.protobuf.Any.prototype.getTypeUrl = function() { |
| 169 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); |
| 170 | }; |
| 171 | |
| 172 | |
| 173 | /** |
| 174 | * @param {string} value |
| 175 | * @return {!proto.google.protobuf.Any} returns this |
| 176 | */ |
| 177 | proto.google.protobuf.Any.prototype.setTypeUrl = function(value) { |
| 178 | return jspb.Message.setProto3StringField(this, 1, value); |
| 179 | }; |
| 180 | |
| 181 | |
| 182 | /** |
| 183 | * optional bytes value = 2; |
| 184 | * @return {!(string|Uint8Array)} |
| 185 | */ |
| 186 | proto.google.protobuf.Any.prototype.getValue = function() { |
| 187 | return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); |
| 188 | }; |
| 189 | |
| 190 | |
| 191 | /** |
| 192 | * optional bytes value = 2; |
| 193 | * This is a type-conversion wrapper around `getValue()` |
| 194 | * @return {string} |
| 195 | */ |
| 196 | proto.google.protobuf.Any.prototype.getValue_asB64 = function() { |
| 197 | return /** @type {string} */ (jspb.Message.bytesAsB64( |
| 198 | this.getValue())); |
| 199 | }; |
| 200 | |
| 201 | |
| 202 | /** |
| 203 | * optional bytes value = 2; |
| 204 | * Note that Uint8Array is not supported on all browsers. |
| 205 | * @see http://caniuse.com/Uint8Array |
| 206 | * This is a type-conversion wrapper around `getValue()` |
| 207 | * @return {!Uint8Array} |
| 208 | */ |
| 209 | proto.google.protobuf.Any.prototype.getValue_asU8 = function() { |
| 210 | return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( |
| 211 | this.getValue())); |
| 212 | }; |
| 213 | |
| 214 | |
| 215 | /** |
| 216 | * @param {!(string|Uint8Array)} value |
| 217 | * @return {!proto.google.protobuf.Any} returns this |
| 218 | */ |
| 219 | proto.google.protobuf.Any.prototype.setValue = function(value) { |
| 220 | return jspb.Message.setProto3BytesField(this, 2, value); |
| 221 | }; |
| 222 | |
| 223 | |
| 224 | goog.object.extend(exports, proto); |
| 225 | /* This code will be inserted into generated code for |
| 226 | * google/protobuf/any.proto. */ |
| 227 | |
| 228 | /** |
| 229 | * Returns the type name contained in this instance, if any. |
| 230 | * @return {string|undefined} |
| 231 | */ |
| 232 | proto.google.protobuf.Any.prototype.getTypeName = function() { |
| 233 | return this.getTypeUrl().split('/').pop(); |
| 234 | }; |
| 235 | |
| 236 | |
| 237 | /** |
| 238 | * Packs the given message instance into this Any. |
| 239 | * For binary format usage only. |
| 240 | * @param {!Uint8Array} serialized The serialized data to pack. |
| 241 | * @param {string} name The type name of this message object. |
| 242 | * @param {string=} opt_typeUrlPrefix the type URL prefix. |
| 243 | */ |
| 244 | proto.google.protobuf.Any.prototype.pack = function(serialized, name, |
| 245 | opt_typeUrlPrefix) { |
| 246 | if (!opt_typeUrlPrefix) { |
| 247 | opt_typeUrlPrefix = 'type.googleapis.com/'; |
| 248 | } |
| 249 | |
| 250 | if (opt_typeUrlPrefix.substr(-1) != '/') { |
| 251 | this.setTypeUrl(opt_typeUrlPrefix + '/' + name); |
| 252 | } else { |
| 253 | this.setTypeUrl(opt_typeUrlPrefix + name); |
| 254 | } |
| 255 | |
| 256 | this.setValue(serialized); |
| 257 | }; |
| 258 | |
| 259 | |
| 260 | /** |
| 261 | * @template T |
| 262 | * Unpacks this Any into the given message object. |
| 263 | * @param {function(Uint8Array):T} deserialize Function that will deserialize |
| 264 | * the binary data properly. |
| 265 | * @param {string} name The expected type name of this message object. |
| 266 | * @return {?T} If the name matched the expected name, returns the deserialized |
| 267 | * object, otherwise returns null. |
| 268 | */ |
| 269 | proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) { |
| 270 | if (this.getTypeName() == name) { |
| 271 | return deserialize(this.getValue_asU8()); |
| 272 | } else { |
| 273 | return null; |
| 274 | } |
| 275 | }; |