10 #include <boost/any.hpp>
18 template <
typename TYPE>
19 static TYPE
get(
const boost::any& var) {
20 return var.type() ==
typeid(TYPE) ? boost::any_cast<TYPE>(var) : TYPE();
23 template <
typename TYPE,
typename VAR>
24 static TYPE
get(VAR var) {
25 return var.type() ==
typeid(TYPE) ? boost::get<TYPE>(var) : TYPE();
28 template <
typename TYPE,
typename VAR>
30 return (var.type() ==
typeid(TYPE));
33 static VariantNull
null() {
37 static bool isNull(
const boost::any& var) {
41 template <
typename VAR>
43 return typeOf<VariantNull>(var);
46 template <
typename VAR>
48 if (typeOf<String>(var)) {
51 if (typeOf<int32_t>(var)) {
52 return get<int32_t>(var);
54 if (typeOf<int64_t>(var)) {
55 return (int32_t)get<int64_t>(var);
57 if (typeOf<double>(var)) {
59 return (int32_t)(longBits ^ (longBits >> 32));
62 return get< Collection<uint8_t> >(var).hashCode();
65 return get< Collection<int32_t> >(var).hashCode();
68 return get< Collection<int64_t> >(var).hashCode();
71 return get< Collection<double> >(var).hashCode();
74 return get< Collection<String> >(var).hashCode();
76 if (typeOf<LuceneObjectPtr>(var)) {
77 return get<LuceneObjectPtr>(var)->hashCode();
82 template <
typename FIRST,
typename SECOND>
84 return (first.type() == second.type());
87 template <
typename FIRST,
typename SECOND>
88 static bool equals(FIRST first, SECOND second) {
89 return first.type() == second.type() ? (first == second) :
false;
92 template <
typename VAR>
94 return first < second ? -1 : (first == second ? 0 : 1);
static bool isNull(const boost::any &var)
Definition: VariantUtils.h:37
static VariantNull null()
Definition: VariantUtils.h:33
static int64_t doubleToLongBits(double value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-poi...
static int32_t hashCode(const String &value)
Compute the hash code from string.
static bool typeOf(VAR var)
Definition: VariantUtils.h:29
static int32_t hashCode(VAR var)
Definition: VariantUtils.h:47
Definition: VariantUtils.h:16
Definition: AbstractAllTermDocs.h:12
static int32_t compareTo(VAR first, VAR second)
Definition: VariantUtils.h:93
static bool isNull(VAR var)
Definition: VariantUtils.h:42
static bool equals(FIRST first, SECOND second)
Definition: VariantUtils.h:88
static bool equalsType(FIRST first, SECOND second)
Definition: VariantUtils.h:83