Path: blob/trunk/third_party/closure/goog/proto2/util.js
2868 views
// Copyright 2009 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Utility methods for Protocol Buffer 2 implementation.16*/1718goog.provide('goog.proto2.Util');1920goog.require('goog.asserts');212223/**24* @define {boolean} Defines a PBCHECK constant that can be turned off by25* clients of PB2. This for is clients that do not want assertion/checking26* running even in non-COMPILED builds.27*/28goog.define('goog.proto2.Util.PBCHECK', !COMPILED);293031/**32* Asserts that the given condition is true, if and only if the PBCHECK33* flag is on.34*35* @param {*} condition The condition to check.36* @param {string=} opt_message Error message in case of failure.37* @throws {Error} Assertion failed, the condition evaluates to false.38*/39goog.proto2.Util.assert = function(condition, opt_message) {40if (goog.proto2.Util.PBCHECK) {41goog.asserts.assert(condition, opt_message);42}43};444546/**47* Returns true if debug assertions (checks) are on.48*49* @return {boolean} The value of the PBCHECK constant.50*/51goog.proto2.Util.conductChecks = function() {52return goog.proto2.Util.PBCHECK;53};545556