patch 4.0
This commit is contained in:
@ -10,48 +10,38 @@
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_LIB_OB_TRUNCATED_STRING_H_
|
||||
#define OCEANBASE_LIB_OB_TRUNCATED_STRING_H_
|
||||
#ifndef OCEANBAE_LIB_OB_TRUNCATED_STRING_H_
|
||||
#define OCEANBAE_LIB_OB_TRUNCATED_STRING_H_
|
||||
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "share/config/ob_server_config.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
class ObTruncatedString {
|
||||
class ObTruncatedString
|
||||
{
|
||||
public:
|
||||
ObTruncatedString(const ObString& str, const int32_t limit)
|
||||
ObTruncatedString(const ObString &str, const int32_t limit)
|
||||
{
|
||||
const int32_t len = (limit < str.length()) ? (limit < 0 ? 0 : limit) : str.length();
|
||||
str_ = ObString(len, str.ptr());
|
||||
}
|
||||
|
||||
explicit ObTruncatedString(const ObString& str)
|
||||
explicit ObTruncatedString(const ObString &str)
|
||||
{
|
||||
const int32_t len = (GCONF.max_string_print_length < str.length())
|
||||
? static_cast<int32_t>(GCONF.max_string_print_length)
|
||||
: str.length();
|
||||
const int32_t len = (GCONF.max_string_print_length < str.length()) ?
|
||||
static_cast<int32_t>(GCONF.max_string_print_length) : str.length();
|
||||
str_ = ObString(len, str.ptr());
|
||||
}
|
||||
inline int32_t length() const
|
||||
{
|
||||
return str_.length();
|
||||
}
|
||||
inline int32_t size() const
|
||||
{
|
||||
return str_.size();
|
||||
}
|
||||
inline const char* ptr() const
|
||||
{
|
||||
return str_.ptr();
|
||||
}
|
||||
inline const ObString& string() const
|
||||
{
|
||||
return str_;
|
||||
}
|
||||
inline int32_t length() const { return str_.length(); }
|
||||
inline int32_t size() const { return str_.size(); }
|
||||
inline const char *ptr() const { return str_.ptr(); }
|
||||
inline const ObString & string() const { return str_; }
|
||||
|
||||
int64_t to_string(char* buf, const int64_t len) const
|
||||
int64_t to_string(char *buf, const int64_t len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
if (OB_ISNULL(buf) || len <= 0) {
|
||||
@ -68,7 +58,9 @@ private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObTruncatedString);
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
}/* ns common*/
|
||||
}/* ns oceanbase */
|
||||
|
||||
#endif // OCEANBAE_LIB_OB_TRUNCATED_STRING_H_
|
||||
|
||||
|
||||
#endif // OCEANBASE_LIB_OB_TRUNCATED_STRING_H_
|
||||
|
||||
Reference in New Issue
Block a user