Source: proto/google/protobuf/any_pb.js

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