| 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 |
/** |
| 16 |
* @fileoverview Protocol buffer serializer. |
| 17 |
* @author [email protected] (Erik Arvidsson) |
| 18 |
*/ |
| 19 |
|
| 20 |
goog.provide('goog.proto'); |
| 21 |
|
| 22 |
|
| 23 |
goog.require('goog.proto.Serializer'); |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* Instance of the serializer object. |
| 28 |
* @type {goog.proto.Serializer} |
| 29 |
* @private |
| 30 |
*/ |
| 31 |
goog.proto.serializer_ = null; |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* Serializes an object or a value to a protocol buffer string. |
| 36 |
* @param {Object} object The object to serialize. |
| 37 |
* @return {string} The serialized protocol buffer string. |
| 38 |
*/ |
| 39 |
goog.proto.serialize = function(object) { |
| 40 |
if (!goog.proto.serializer_) { |
| 41 |
goog.proto.serializer_ = new goog.proto.Serializer; |
| 42 |
} |
| 43 |
return goog.proto.serializer_.serialize(object); |
| 44 |
}; |