any_pb.js 8.0 KB

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