-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianmu): fix format using clang-format #792
Showing
9 changed files
with
3,664 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* Copyright (c) 2022 StoneAtom, Inc. All rights reserved. | ||
Use is subject to license terms | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA | ||
*/ | ||
#ifndef TIANMU_CORE_RC_ATTR_TYPEINFO_H_ | ||
#define TIANMU_CORE_RC_ATTR_TYPEINFO_H_ | ||
#pragma once | ||
|
||
#include <bitset> | ||
|
||
#include "common/common_definitions.h" | ||
|
||
namespace Tianmu { | ||
namespace types { | ||
class RCDataType; | ||
} // namespace types | ||
namespace core { | ||
class ATI { | ||
public: | ||
static int TextSize(common::CT attrt, uint precision, int scale, DTCollation col = DTCollation()); | ||
|
||
static bool IsInteger32Type(common::CT attr_type) { | ||
return attr_type == common::CT::INT || attr_type == common::CT::BYTEINT || attr_type == common::CT::SMALLINT || | ||
attr_type == common::CT::MEDIUMINT; | ||
} | ||
|
||
static bool IsIntegerType(common::CT attr_type) { | ||
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT; | ||
} | ||
static bool IsFixedNumericType(common::CT attr_type) { | ||
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT || attr_type == common::CT::NUM; | ||
} | ||
|
||
static bool IsRealType(common::CT attr_type) { | ||
return attr_type == common::CT::FLOAT || attr_type == common::CT::REAL; | ||
} | ||
static bool IsNumericType(common::CT attr_type) { | ||
return IsInteger32Type(attr_type) || attr_type == common::CT::BIGINT || attr_type == common::CT::NUM || | ||
attr_type == common::CT::FLOAT || attr_type == common::CT::REAL; | ||
} | ||
|
||
static bool IsBinType(common::CT attr_type) { | ||
return attr_type == common::CT::BYTE || attr_type == common::CT::VARBYTE || attr_type == common::CT::BIN; | ||
} | ||
|
||
static bool IsTxtType(common::CT attr_type) { | ||
return attr_type == common::CT::STRING || attr_type == common::CT::VARCHAR || attr_type == common::CT::LONGTEXT; | ||
} | ||
|
||
static bool IsCharType(common::CT attr_type) { return attr_type == common::CT::STRING; } | ||
static bool IsStringType(common::CT attr_type) { | ||
return attr_type == common::CT::STRING || attr_type == common::CT::VARCHAR || attr_type == common::CT::LONGTEXT || | ||
IsBinType(attr_type); | ||
} | ||
|
||
static bool IsDateTimeType(common::CT attr_type) { | ||
return attr_type == common::CT::DATE || attr_type == common::CT::TIME || attr_type == common::CT::YEAR || | ||
attr_type == common::CT::DATETIME || attr_type == common::CT::TIMESTAMP; | ||
} | ||
|
||
static bool IsDateTimeNType(common::CT attr_type) { | ||
return attr_type == common::CT::TIME_N || attr_type == common::CT::DATETIME_N || | ||
attr_type == common::CT::TIMESTAMP_N; | ||
} | ||
}; | ||
|
||
class AttributeTypeInfo { | ||
public: | ||
enum class enumATI { | ||
NOT_NULL = 0, | ||
AUTO_INC = 1, | ||
BLOOM_FILTER = 2, | ||
}; | ||
|
||
AttributeTypeInfo(common::CT attrt, bool notnull, uint precision = 0, ushort scale = 0, bool auto_inc = false, | ||
DTCollation collation = DTCollation(), common::PackFmt fmt = common::PackFmt::DEFAULT, | ||
bool filter = false) | ||
: attrt(attrt), fmt(fmt), precision(precision), scale(scale), collation(collation) { | ||
flag[static_cast<int>(enumATI::NOT_NULL)] = notnull; | ||
flag[static_cast<int>(enumATI::BLOOM_FILTER)] = filter; | ||
flag[static_cast<int>(enumATI::AUTO_INC)] = auto_inc; | ||
|
||
// lookup only applies to string type | ||
if (attrt != common::CT::STRING && attrt != common::CT::VARCHAR && Lookup()) | ||
fmt = common::PackFmt::DEFAULT; | ||
} | ||
common::CT Type() const { return attrt; } | ||
common::PackType GetPackType() const { | ||
return ATI::IsDateTimeType(attrt) || ATI::IsNumericType(attrt) || Lookup() ? common::PackType::INT | ||
: common::PackType::STR; | ||
} | ||
uint Precision() const { return precision; } | ||
ushort Scale() const { return scale; } | ||
uint CharLen() const { return precision / collation.collation->mbmaxlen; } | ||
bool NotNull() const { return flag[static_cast<int>(enumATI::NOT_NULL)]; } | ||
bool AutoInc() const { return flag[static_cast<int>(enumATI::AUTO_INC)]; } | ||
void SetCollation(const DTCollation &collation) { this->collation = collation; } | ||
void SetCollation(CHARSET_INFO *charset_info) { this->collation.set(charset_info); } | ||
DTCollation GetCollation() const { return collation; } | ||
CHARSET_INFO *CharsetInfo() const { return const_cast<CHARSET_INFO *>(this->collation.collation); } | ||
const types::RCDataType &ValuePrototype() const; | ||
common::PackFmt Fmt() const { return fmt; } | ||
bool Lookup() const { return fmt == common::PackFmt::LOOKUP; } | ||
unsigned char Flag() const { return flag.to_ulong(); } | ||
void SetFlag(unsigned char v) { flag = std::bitset<std::numeric_limits<unsigned char>::digits>(v); } | ||
|
||
private: | ||
common::CT attrt; | ||
common::PackFmt fmt; | ||
uint precision; | ||
int scale; | ||
DTCollation collation; | ||
|
||
std::bitset<std::numeric_limits<unsigned char>::digits> flag; | ||
}; | ||
} // namespace core | ||
} // namespace Tianmu | ||
|
||
#endif // TIANMU_CORE_RC_ATTR_TYPEINFO_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* Copyright (c) 2022 StoneAtom, Inc. All rights reserved. | ||
Use is subject to license terms | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA | ||
*/ | ||
|
||
#include "rc_data_types.h" | ||
|
||
#include "core/rc_attr.h" | ||
#include "core/rc_attr_typeinfo.h" | ||
|
||
namespace Tianmu { | ||
namespace types { | ||
|
||
RCDataType::~RCDataType() {} | ||
|
||
bool RCDataType::AreComperable(const RCDataType &rcdt) const { return RCDataType::AreComperable(*this, rcdt); } | ||
|
||
bool RCDataType::AreComperable(const RCDataType &rcdt1, const RCDataType &rcdt2) { | ||
common::CT att1 = rcdt1.Type(); | ||
common::CT att2 = rcdt2.Type(); | ||
return AreComparable(att1, att2); | ||
} | ||
|
||
bool RCDataType::compare(const RCDataType &rcdt1, const RCDataType &rcdt2, common::Operator op, char like_esc) { | ||
// DEBUG_ASSERT(RCDataType::AreComperable(rcdt1, rcdt2)); | ||
if (op == common::Operator::O_LIKE || op == common::Operator::O_NOT_LIKE) { | ||
if (rcdt1.IsNull() || rcdt2.IsNull()) | ||
return false; | ||
BString x, y; | ||
BString *rcbs1 = dynamic_cast<BString *>(const_cast<RCDataType *>(&rcdt1)); | ||
if (!rcbs1) { | ||
x = rcdt1.ToBString(); | ||
rcbs1 = &x; | ||
} | ||
BString *rcbs2 = dynamic_cast<BString *>(const_cast<RCDataType *>(&rcdt2)); | ||
if (!rcbs2) { | ||
y = rcdt2.ToBString(); | ||
rcbs2 = &y; | ||
} | ||
bool res = rcbs1->Like(*rcbs2, like_esc); | ||
if (op == common::Operator::O_LIKE) | ||
return res; | ||
else | ||
return !res; | ||
} else if (!rcdt1.IsNull() && !rcdt2.IsNull() && | ||
(((op == common::Operator::O_EQ) && rcdt1 == rcdt2) || | ||
(op == common::Operator::O_NOT_EQ && rcdt1 != rcdt2) || | ||
(op == common::Operator::O_LESS && rcdt1 < rcdt2) || | ||
(op == common::Operator::O_LESS_EQ && (rcdt1 < rcdt2 || rcdt1 == rcdt2)) || | ||
(op == common::Operator::O_MORE && (!(rcdt1 < rcdt2) && rcdt1 != rcdt2)) || | ||
(op == common::Operator::O_MORE_EQ && (!(rcdt1 < rcdt2) || rcdt1 == rcdt2)))) | ||
return true; | ||
return false; | ||
} | ||
|
||
bool RCDataType::compare(const RCDataType &rcdt, common::Operator op, char like_esc) const { | ||
return RCDataType::compare(*this, rcdt, op, like_esc); | ||
} | ||
|
||
bool AreComparable(common::CT attr1_t, common::CT attr2_t) { | ||
if (attr1_t == attr2_t) | ||
return true; | ||
if ((core::ATI::IsDateTimeType(attr1_t)) && (core::ATI::IsDateTimeType(attr2_t))) | ||
return true; | ||
if ((core::ATI::IsTxtType(attr2_t) && attr1_t == common::CT::VARBYTE) || | ||
(core::ATI::IsTxtType(attr1_t) && attr2_t == common::CT::VARBYTE)) | ||
return true; | ||
if ((((attr1_t == common::CT::TIME) || (attr1_t == common::CT::DATE)) && attr2_t != common::CT::DATETIME) || | ||
(((attr2_t == common::CT::TIME) || (attr2_t == common::CT::DATE)) && attr1_t != common::CT::DATETIME) || | ||
(core::ATI::IsBinType(attr1_t) && !core::ATI::IsBinType(attr2_t)) || | ||
(core::ATI::IsBinType(attr2_t) && !core::ATI::IsBinType(attr1_t)) || | ||
(core::ATI::IsTxtType(attr1_t) && !core::ATI::IsTxtType(attr2_t)) || | ||
(core::ATI::IsTxtType(attr2_t) && !core::ATI::IsTxtType(attr1_t))) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool RCDataType::ToDecimal(const RCDataType &in, int scale, RCNum &out) { | ||
if (RCNum *rcn = dynamic_cast<RCNum *>(const_cast<RCDataType *>(&in))) { | ||
if (rcn->IsDecimal(scale)) { | ||
out = rcn->ToDecimal(scale); | ||
return true; | ||
} | ||
} else if (BString *rcs = dynamic_cast<BString *>(const_cast<RCDataType *>(&in))) { | ||
if (RCNum::Parse(*rcs, out) == common::ErrorCode::SUCCESS) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool RCDataType::ToInt(const RCDataType &in, RCNum &out) { | ||
if (RCNum *rcn = dynamic_cast<RCNum *>(const_cast<RCDataType *>(&in))) { | ||
if (rcn->IsInt()) { | ||
out = rcn->ToInt(); | ||
return true; | ||
} | ||
} else if (BString *rcs = dynamic_cast<BString *>(const_cast<RCDataType *>(&in))) { | ||
if (RCNum::Parse(*rcs, out) == common::ErrorCode::SUCCESS) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool RCDataType::ToReal(const RCDataType &in, RCNum &out) { | ||
if (RCNum *rcn = dynamic_cast<RCNum *>(const_cast<RCDataType *>(&in))) { | ||
if (rcn->IsReal()) { | ||
out = rcn->ToReal(); | ||
return true; | ||
} | ||
} else if (BString *rcs = dynamic_cast<BString *>(const_cast<RCDataType *>(&in))) { | ||
if (RCNum::ParseReal(*rcs, out, common::CT::UNK) == common::ErrorCode::SUCCESS) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
ValueTypeEnum RCDataType::GetValueType(common::CT attr_type) { | ||
if (core::ATI::IsNumericType(attr_type)) | ||
return ValueTypeEnum::NUMERIC_TYPE; | ||
else if (core::ATI::IsDateTimeType(attr_type)) | ||
return ValueTypeEnum::DATE_TIME_TYPE; | ||
else if (core::ATI::IsStringType(attr_type)) | ||
return ValueTypeEnum::STRING_TYPE; | ||
return ValueTypeEnum::NULL_TYPE; | ||
} | ||
|
||
} // namespace types | ||
} // namespace Tianmu |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* Copyright (c) 2022 StoneAtom, Inc. All rights reserved. | ||
Use is subject to license terms | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA | ||
*/ | ||
#ifndef TIANMU_TYPES_RC_NUM_H_ | ||
#define TIANMU_TYPES_RC_NUM_H_ | ||
#pragma once | ||
|
||
#include "types/rc_data_types.h" | ||
|
||
namespace Tianmu { | ||
namespace types { | ||
|
||
class BString; | ||
|
||
class RCNum : public ValueBasic<RCNum> { | ||
friend class ValueParserForText; | ||
friend class Engine; | ||
|
||
public: | ||
RCNum(common::CT attrt = common::CT::NUM); | ||
RCNum(int64_t value, short scale = -1, bool dbl = false, common::CT attrt = common::CT::UNK); | ||
RCNum(double value); | ||
RCNum(const RCNum &); | ||
~RCNum(); | ||
|
||
RCNum &Assign(int64_t value, short scale = -1, bool dbl = false, common::CT attrt = common::CT::UNK); | ||
RCNum &Assign(double value); | ||
|
||
static common::ErrorCode Parse(const BString &rcs, RCNum &rcn, common::CT at = common::CT::UNK); | ||
static common::ErrorCode ParseReal(const BString &, RCNum &, common::CT at); | ||
static common::ErrorCode ParseNum(const BString &, RCNum &, short scale = -1); | ||
|
||
RCNum &operator=(const RCNum &rcn); | ||
RCNum &operator=(const RCDataType &rcdt) override; | ||
|
||
common::CT Type() const override; | ||
|
||
bool operator==(const RCDataType &rcdt) const override; | ||
bool operator<(const RCDataType &rcdt) const override; | ||
bool operator>(const RCDataType &rcdt) const override; | ||
bool operator>=(const RCDataType &rcdt) const override; | ||
bool operator<=(const RCDataType &rcdt) const override; | ||
bool operator!=(const RCDataType &rcdt) const override; | ||
|
||
RCNum &operator-=(const RCNum &rcn); | ||
RCNum &operator+=(const RCNum &rcn); | ||
RCNum &operator*=(const RCNum &rcn); | ||
RCNum &operator/=(const RCNum &rcn); | ||
|
||
RCNum operator-(const RCNum &rcn) const; | ||
RCNum operator+(const RCNum &rcn) const; | ||
RCNum operator*(const RCNum &rcn) const; | ||
RCNum operator/(const RCNum &rcn) const; | ||
|
||
bool IsDecimal(ushort scale) const; | ||
bool IsReal() const { return is_double_; } | ||
bool IsInt() const; | ||
|
||
BString ToBString() const override; | ||
RCNum ToDecimal(int scale = -1) const; | ||
RCNum ToReal() const; | ||
RCNum ToInt() const; | ||
|
||
operator int64_t() const { return GetIntPart(); } | ||
operator double() const; | ||
operator float() const { return (float)(double)*this; } | ||
|
||
short Scale() const { return scale_; } | ||
int64_t ValueInt() const { return value_; } | ||
char *GetDataBytesPointer() const override { return (char *)&value_; } | ||
int64_t GetIntPart() const { | ||
return is_double_ ? (int64_t)GetIntPartAsDouble() : value_ / (int64_t)Uint64PowOfTen(scale_); | ||
} | ||
|
||
int64_t GetValueInt64() const { return value_; } | ||
double GetIntPartAsDouble() const; | ||
double GetFractPart() const; | ||
|
||
short GetDecStrLen() const; | ||
short GetDecIntLen() const; | ||
short GetDecFractLen() const; | ||
|
||
uint GetHashCode() const override; | ||
void Negate(); | ||
|
||
private: | ||
int compare(const RCNum &rcn) const; | ||
int compare(const RCDateTime &rcn) const; | ||
|
||
private: | ||
static constexpr int MAX_DEC_PRECISION = 18; | ||
int64_t value_; | ||
ushort scale_; // means 'scale' actually | ||
bool is_double_; | ||
bool is_dot_; | ||
common::CT attr_type_; | ||
|
||
public: | ||
const static ValueTypeEnum value_type = ValueTypeEnum::NUMERIC_TYPE; | ||
}; | ||
|
||
} // namespace types | ||
} // namespace Tianmu | ||
|
||
#endif // TIANMU_TYPES_RC_NUM_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* Copyright (c) 2022 StoneAtom, Inc. All rights reserved. | ||
Use is subject to license terms | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA | ||
*/ | ||
|
||
#include "types/rc_num.h" | ||
|
||
namespace Tianmu { | ||
namespace types { | ||
|
||
RCValueObject::RCValueObject() {} | ||
|
||
RCValueObject::RCValueObject(const RCValueObject &rcvo) { | ||
if (rcvo.value.get()) | ||
construct(*rcvo.value); | ||
} | ||
|
||
RCValueObject::RCValueObject(const RCDataType &rcdt) { construct(rcdt); } | ||
|
||
RCValueObject::~RCValueObject() {} | ||
|
||
RCValueObject &RCValueObject::operator=(const RCValueObject &rcvo) { | ||
if (rcvo.value.get()) | ||
construct(*rcvo.value); | ||
else | ||
value.reset(); | ||
return *this; | ||
} | ||
|
||
inline void RCValueObject::construct(const RCDataType &rcdt) { value = rcdt.Clone(); } | ||
|
||
bool RCValueObject::compare(const RCValueObject &rcvo1, const RCValueObject &rcvo2, common::Operator op, | ||
char like_esc) { | ||
if (rcvo1.IsNull() || rcvo2.IsNull()) | ||
return false; | ||
else | ||
return RCDataType::compare(*rcvo1.value, *rcvo2.value, op, like_esc); | ||
} | ||
|
||
bool RCValueObject::compare(const RCValueObject &rcvo, common::Operator op, char like_esc) const { | ||
return compare(*this, rcvo, op, like_esc); | ||
} | ||
|
||
bool RCValueObject::operator==(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value == *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator<(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value < *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator>(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value > *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator>=(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value >= *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator<=(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value <= *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator!=(const RCValueObject &rcvo) const { | ||
if (IsNull() || rcvo.IsNull()) | ||
return false; | ||
return *value != *rcvo.value; | ||
} | ||
|
||
bool RCValueObject::operator==(const RCDataType &rcn) const { | ||
if (IsNull() || rcn.IsNull()) | ||
return false; | ||
return *value == rcn; | ||
} | ||
|
||
bool RCValueObject::operator<(const RCDataType &rcn) const { | ||
if (IsNull() || rcn.IsNull()) | ||
return false; | ||
return *value < rcn; | ||
} | ||
|
||
bool RCValueObject::operator>(const RCDataType &rcn) const { | ||
if (IsNull() || rcn.IsNull()) | ||
return false; | ||
return *value > rcn; | ||
} | ||
|
||
bool RCValueObject::operator>=(const RCDataType &rcn) const { | ||
if (IsNull() || rcn.IsNull()) | ||
return false; | ||
return *value >= rcn; | ||
} | ||
|
||
bool RCValueObject::operator<=(const RCDataType &rcdt) const { | ||
if (IsNull() || rcdt.IsNull()) | ||
return false; | ||
return *value <= rcdt; | ||
} | ||
|
||
bool RCValueObject::operator!=(const RCDataType &rcn) const { | ||
if (IsNull() || rcn.IsNull()) | ||
return false; | ||
return *value != rcn; | ||
} | ||
|
||
bool RCValueObject::IsNull() const { return value.get() ? value->IsNull() : true; } | ||
|
||
RCDataType &RCValueObject::operator*() const { return value.get() ? *value.get() : RCNum::NullValue(); } | ||
|
||
RCValueObject::operator RCNum &() const { | ||
if (IsNull()) | ||
return RCNum::NullValue(); | ||
if (GetValueType() == ValueTypeEnum::NUMERIC_TYPE || GetValueType() == ValueTypeEnum::DATE_TIME_TYPE) | ||
return static_cast<RCNum &>(*value); | ||
|
||
TIANMU_ERROR("Bad cast in RCValueObject::RCNum&()"); | ||
return static_cast<RCNum &>(*value); | ||
} | ||
|
||
RCValueObject::operator RCDateTime &() const { | ||
if (IsNull()) | ||
return RCDateTime::NullValue(); | ||
if (GetValueType() == ValueTypeEnum::DATE_TIME_TYPE) | ||
return static_cast<RCDateTime &>(*value); | ||
|
||
TIANMU_ERROR("Bad cast in RCValueObject::RCDateTime&()"); | ||
return static_cast<RCDateTime &>(*value); | ||
} | ||
|
||
BString RCValueObject::ToBString() const { | ||
if (IsNull()) | ||
return BString(); | ||
return value->ToBString(); | ||
} | ||
|
||
uint RCValueObject::GetHashCode() const { | ||
if (IsNull()) | ||
return 0; | ||
return value->GetHashCode(); | ||
} | ||
|
||
} // namespace types | ||
} // namespace Tianmu |