#include <FilterEvaluator.h>
Public Types | |
VAL_BOOL | |
VAL_INT | |
VAL_UINT | |
VAL_I64 | |
VAL_UI64 | |
VAL_FLOAT | |
VAL_LNGDUB | |
VAL_LARGEST_NUMERIC = VAL_LNGDUB | |
VAL_CHAR | |
VAL_STRING | |
enum | Type { VAL_BOOL, VAL_INT, VAL_UINT, VAL_I64, VAL_UI64, VAL_FLOAT, VAL_LNGDUB, VAL_LARGEST_NUMERIC = VAL_LNGDUB, VAL_CHAR, VAL_STRING } |
Public Member Functions | |
Value (bool b, bool conversion_preferred=false) | |
Value (int i, bool conversion_preferred=false) | |
Value (unsigned int u, bool conversion_preferred=false) | |
Value (ACE_INT64 l, bool conversion_preferred=false) | |
Value (ACE_UINT64 m, bool conversion_preferred=false) | |
Value (char c, bool conversion_preferred=false) | |
Value (double f, bool conversion_preferred=false) | |
Value (ACE_CDR::LongDouble ld, bool conversion_preferred=false) | |
Value (const char *s, bool conversion_preferred=false) | |
Value (const TAO::String_Manager &s, bool conversion_preferred=false) | |
Value (const TAO::WString_Manager &s, bool conversion_preferred=false) | |
~Value () | |
Value (const Value &v) | |
Value & | operator= (const Value &v) |
void | swap (Value &other) |
bool | operator== (const Value &v) const |
bool | operator< (const Value &v) const |
bool | like (const Value &v) const |
Value | operator% (const Value &v) const |
bool | convert (Type t) |
template<typename T> | |
T & | get () |
template<typename T> | |
const T & | get () const |
Static Public Member Functions | |
static void | conversion (Value &lhs, Value &rhs) |
Public Attributes | |
Type | type_ |
union { | |
bool b_ | |
int i_ | |
unsigned int u_ | |
ACE_INT64 l_ | |
ACE_UINT64 m_ | |
char c_ | |
double f_ | |
ACE_CDR::LongDouble ld_ | |
const char * s_ | |
}; | |
bool | conversion_preferred_ |
Definition at line 28 of file FilterEvaluator.h.
VAL_BOOL | |
VAL_INT | |
VAL_UINT | |
VAL_I64 | |
VAL_UI64 | |
VAL_FLOAT | |
VAL_LNGDUB | |
VAL_LARGEST_NUMERIC | |
VAL_CHAR | |
VAL_STRING |
Definition at line 51 of file FilterEvaluator.h.
00051 {VAL_BOOL, VAL_INT, VAL_UINT, VAL_I64, VAL_UI64, VAL_FLOAT, 00052 VAL_LNGDUB, VAL_LARGEST_NUMERIC = VAL_LNGDUB, 00053 VAL_CHAR, VAL_STRING};
OpenDDS::DCPS::Value::Value | ( | bool | b, | |
bool | conversion_preferred = false | |||
) |
Definition at line 514 of file FilterEvaluator.cpp.
00515 : type_(VAL_BOOL), b_(b), conversion_preferred_(conversion_preferred) 00516 {}
OpenDDS::DCPS::Value::Value | ( | int | i, | |
bool | conversion_preferred = false | |||
) |
Definition at line 518 of file FilterEvaluator.cpp.
00519 : type_(VAL_INT), i_(i), conversion_preferred_(conversion_preferred) 00520 {}
OpenDDS::DCPS::Value::Value | ( | unsigned int | u, | |
bool | conversion_preferred = false | |||
) |
Definition at line 522 of file FilterEvaluator.cpp.
00523 : type_(VAL_UINT), u_(u), conversion_preferred_(conversion_preferred) 00524 {}
OpenDDS::DCPS::Value::Value | ( | ACE_INT64 | l, | |
bool | conversion_preferred = false | |||
) |
Definition at line 526 of file FilterEvaluator.cpp.
00527 : type_(VAL_I64), l_(l), conversion_preferred_(conversion_preferred) 00528 {}
OpenDDS::DCPS::Value::Value | ( | ACE_UINT64 | m, | |
bool | conversion_preferred = false | |||
) |
Definition at line 530 of file FilterEvaluator.cpp.
00531 : type_(VAL_UI64), m_(m), conversion_preferred_(conversion_preferred) 00532 {}
OpenDDS::DCPS::Value::Value | ( | char | c, | |
bool | conversion_preferred = false | |||
) |
Definition at line 534 of file FilterEvaluator.cpp.
00535 : type_(VAL_CHAR), c_(c), conversion_preferred_(conversion_preferred) 00536 {}
OpenDDS::DCPS::Value::Value | ( | double | f, | |
bool | conversion_preferred = false | |||
) |
Definition at line 538 of file FilterEvaluator.cpp.
00539 : type_(VAL_FLOAT), f_(f), conversion_preferred_(conversion_preferred) 00540 {}
OpenDDS::DCPS::Value::Value | ( | ACE_CDR::LongDouble | ld, | |
bool | conversion_preferred = false | |||
) |
Definition at line 542 of file FilterEvaluator.cpp.
00543 : type_(VAL_LNGDUB), ld_(ld), conversion_preferred_(conversion_preferred) 00544 {}
OpenDDS::DCPS::Value::Value | ( | const char * | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 546 of file FilterEvaluator.cpp.
00547 : type_(VAL_STRING), s_(ACE_OS::strdup(s)) 00548 , conversion_preferred_(conversion_preferred) 00549 {}
OpenDDS::DCPS::Value::Value | ( | const TAO::String_Manager & | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 551 of file FilterEvaluator.cpp.
00552 : type_(VAL_STRING), s_(ACE_OS::strdup(s.in())) 00553 , conversion_preferred_(conversion_preferred) 00554 {}
OpenDDS::DCPS::Value::Value | ( | const TAO::WString_Manager & | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 556 of file FilterEvaluator.cpp.
00557 : type_(VAL_STRING) 00558 #ifdef DDS_HAS_WCHAR 00559 , s_(ACE_OS::strdup(ACE_Wide_To_Ascii(s.in()).char_rep())) 00560 #else 00561 , s_(0) 00562 #endif 00563 , conversion_preferred_(conversion_preferred) 00564 { 00565 #ifndef DDS_HAS_WCHAR 00566 ACE_UNUSED_ARG(s); 00567 #endif 00568 }
OpenDDS::DCPS::Value::~Value | ( | ) |
Definition at line 590 of file FilterEvaluator.cpp.
References s_, type_, and VAL_STRING.
00591 { 00592 if (type_ == VAL_STRING) ACE_OS::free((void*)s_); 00593 }
OpenDDS::DCPS::Value::Value | ( | const Value & | v | ) |
Definition at line 647 of file FilterEvaluator.cpp.
References OpenDDS::DCPS::visit().
00648 : type_(v.type_), conversion_preferred_(v.conversion_preferred_) 00649 { 00650 Assign visitor(*this); 00651 visit(visitor, v); 00652 }
Definition at line 874 of file FilterEvaluator.cpp.
References conversion_preferred_, convert(), type_, VAL_CHAR, VAL_LARGEST_NUMERIC, and VAL_STRING.
Referenced by operator%(), operator<(), and operator==().
00875 { 00876 if (lhs.type_ == rhs.type_) { 00877 return; 00878 } 00879 bool ok = false; 00880 Value& smaller = (lhs.type_ < rhs.type_) ? lhs : rhs; 00881 Value& larger = (lhs.type_ < rhs.type_) ? rhs : lhs; 00882 if (smaller.conversion_preferred_) { 00883 ok = smaller.convert(larger.type_); 00884 } else if (larger.conversion_preferred_) { 00885 ok = larger.convert(smaller.type_); 00886 } else if (smaller.type_ == VAL_CHAR && larger.type_ == VAL_STRING) { 00887 ok = smaller.convert(VAL_STRING); 00888 } else if (larger.type_ <= VAL_LARGEST_NUMERIC) { 00889 ok = smaller.convert(larger.type_); 00890 } else if (larger.type_ == VAL_STRING) { 00891 if (larger.convert(smaller.type_)) { 00892 ok = true; 00893 } else { 00894 ok = smaller.convert(VAL_STRING); 00895 } 00896 } 00897 if (!ok) { 00898 throw std::runtime_error("Types don't match and aren't convertible."); 00899 } 00900 }
bool OpenDDS::DCPS::Value::convert | ( | Type | t | ) |
Definition at line 842 of file FilterEvaluator.cpp.
References conversion_preferred_, OPENDDS_STRING, s_, swap(), type_, VAL_STRING, and OpenDDS::DCPS::visit().
Referenced by conversion().
00843 { 00844 OPENDDS_STRING asString; 00845 if (type_ == VAL_STRING) { 00846 asString = s_; 00847 } else { 00848 std::ostringstream oss; 00849 StreamInsert visitor(oss); 00850 visit(visitor, *this); 00851 asString = oss.str(); 00852 } 00853 00854 Value newval = 0; 00855 newval.type_ = t; 00856 newval.conversion_preferred_ = false; 00857 if (t == VAL_STRING) { 00858 newval.s_ = ACE_OS::strdup(asString.c_str()); 00859 swap(newval); 00860 return true; 00861 } else { 00862 std::istringstream iss(asString); 00863 StreamExtract visitor(iss); 00864 visit(visitor, newval); 00865 if (iss.eof() && !iss.bad()) { 00866 swap(newval); 00867 return true; 00868 } 00869 return false; 00870 } 00871 }
const char *const & OpenDDS::DCPS::Value::get | ( | ) | const |
const char *& OpenDDS::DCPS::Value::get | ( | ) |
bool OpenDDS::DCPS::Value::like | ( | const Value & | v | ) | const |
Definition at line 784 of file FilterEvaluator.cpp.
References OPENDDS_STRING, s_, type_, and VAL_STRING.
00785 { 00786 if (type_ != VAL_STRING || v.type_ != VAL_STRING) { 00787 throw std::runtime_error("'like' operator called on non-string arguments."); 00788 } 00789 OPENDDS_STRING pattern(v.s_); 00790 // escape ? or * in the pattern string so they are not wildcards 00791 for (size_t i = pattern.find_first_of("?*"); i < pattern.length(); 00792 i = pattern.find_first_of("?*", i + 1)) { 00793 pattern.insert(i++, 1, '\\'); 00794 } 00795 // translate _ and % wildcards into those used by ACE::wild_match() (?, *) 00796 for (size_t i = pattern.find_first_of("_%"); i < pattern.length(); 00797 i = pattern.find_first_of("_%", i + 1)) { 00798 pattern[i] = (pattern[i] == '_') ? '?' : '*'; 00799 } 00800 return ACE::wild_match(s_, pattern.c_str(), true, true); 00801 }
Definition at line 774 of file FilterEvaluator.cpp.
References conversion(), and OpenDDS::DCPS::visit().
00775 { 00776 Value lhs = *this; 00777 Value rhs = v; 00778 conversion(lhs, rhs); 00779 Modulus visitor(lhs); 00780 return visit(visitor, rhs); 00781 }
bool OpenDDS::DCPS::Value::operator< | ( | const Value & | v | ) | const |
Definition at line 764 of file FilterEvaluator.cpp.
References conversion(), and OpenDDS::DCPS::visit().
00765 { 00766 Value lhs = *this; 00767 Value rhs = v; 00768 conversion(lhs, rhs); 00769 Less visitor(lhs); 00770 return visit(visitor, rhs); 00771 }
bool OpenDDS::DCPS::Value::operator== | ( | const Value & | v | ) | const |
Definition at line 754 of file FilterEvaluator.cpp.
References conversion(), and OpenDDS::DCPS::visit().
00755 { 00756 Value lhs = *this; 00757 Value rhs = v; 00758 conversion(lhs, rhs); 00759 Equals visitor(lhs); 00760 return visit(visitor, rhs); 00761 }
void OpenDDS::DCPS::Value::swap | ( | Value & | other | ) |
Definition at line 663 of file FilterEvaluator.cpp.
References conversion_preferred_, s_, OpenDDS::DCPS::swap(), type_, VAL_STRING, and OpenDDS::DCPS::visit().
Referenced by convert(), and operator=().
00664 { 00665 Value t(v); 00666 00667 if (v.type_ == VAL_STRING) { 00668 ACE_OS::free((void*)v.s_); 00669 } 00670 00671 Assign visitor1(v, true); 00672 visit(visitor1, *this); 00673 if (type_ == VAL_STRING) { 00674 s_ = 0; 00675 } 00676 00677 Assign visitor2(*this, true); 00678 visit(visitor2, t); 00679 if (t.type_ == VAL_STRING) { 00680 t.s_ = 0; 00681 } 00682 00683 std::swap(conversion_preferred_, v.conversion_preferred_); 00684 std::swap(type_, v.type_); 00685 }
union { ... } |
Definition at line 61 of file FilterEvaluator.h.
Referenced by OpenDDS::DCPS::FilterEvaluator::eval_i(), and get().
Definition at line 66 of file FilterEvaluator.h.
double OpenDDS::DCPS::Value::f_ |
Definition at line 67 of file FilterEvaluator.h.
Definition at line 62 of file FilterEvaluator.h.
ACE_INT64 OpenDDS::DCPS::Value::l_ |
Definition at line 64 of file FilterEvaluator.h.
ACE_CDR::LongDouble OpenDDS::DCPS::Value::ld_ |
Definition at line 68 of file FilterEvaluator.h.
ACE_UINT64 OpenDDS::DCPS::Value::m_ |
Definition at line 65 of file FilterEvaluator.h.
const char* OpenDDS::DCPS::Value::s_ |
Definition at line 59 of file FilterEvaluator.h.
Referenced by conversion(), convert(), like(), swap(), and ~Value().
unsigned int OpenDDS::DCPS::Value::u_ |
Definition at line 63 of file FilterEvaluator.h.