proto.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2007 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Protocol buffer serializer.
  16. * @author arv@google.com (Erik Arvidsson)
  17. */
  18. goog.provide('goog.proto');
  19. goog.require('goog.proto.Serializer');
  20. /**
  21. * Instance of the serializer object.
  22. * @type {goog.proto.Serializer}
  23. * @private
  24. */
  25. goog.proto.serializer_ = null;
  26. /**
  27. * Serializes an object or a value to a protocol buffer string.
  28. * @param {Object} object The object to serialize.
  29. * @return {string} The serialized protocol buffer string.
  30. */
  31. goog.proto.serialize = function(object) {
  32. if (!goog.proto.serializer_) {
  33. goog.proto.serializer_ = new goog.proto.Serializer;
  34. }
  35. return goog.proto.serializer_.serialize(object);
  36. };