写读Blob源码的时候,读完blob.hpp后,发现其中存在如下的这些方法。下面我们详细的来分析这些方法的源码以及它们的函数功能。
- CHECK_EQ()
- CHECK_LE()
- CHECK_GE()
- CHECK_LT()
CHECK方法是封装在GLOG库中,而GLOG库是Google开发的用于记录应用程序的使用库,提供基于C++标准输入输出流形式的接口,记录时可以选择不同的日志级别,方便将重要日志和普通日志分开。 GLOG 提供如下的CHECK方法:
代码位于 /usr/include/glog/logging.h
// Equality/Inequality checks - compare two values, and log a FATAL message
// including the two values when the result is not as expected. The values
// must have operator<<(ostream, ...) defined.
//
// You may append to the error message like so:
// CHECK_NE(1, 2) << ": The world must be ending!";
//
// We are very careful to ensure that each argument is evaluated exactly
// once, and that anything which is legal to pass as a function argument is
// legal here. In particular, the arguments may be temporary expressions
// which will end up being destroyed at the end of the apparent statement,
// for example:
// CHECK_EQ(string("abc")[1], 'b');
//
// WARNING: These don't compile correctly if one of the arguments is a pointer
// and the other is NULL. To work around this, simply static_cast NULL to the
// type of the desired pointer.
#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2) #相当于assert(val1 == val2)
# release下可用