#include <FilterEvaluator.h>
Public Types | |
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 30 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 53 of file FilterEvaluator.h.
00053 {VAL_BOOL, VAL_INT, VAL_UINT, VAL_I64, VAL_UI64, VAL_FLOAT, 00054 VAL_LNGDUB, VAL_LARGEST_NUMERIC = VAL_LNGDUB, 00055 VAL_CHAR, VAL_STRING};
OpenDDS::DCPS::Value::Value | ( | bool | b, | |
bool | conversion_preferred = false | |||
) |
Definition at line 526 of file FilterEvaluator.cpp.
00527 : type_(VAL_BOOL), b_(b), conversion_preferred_(conversion_preferred) 00528 {}
OpenDDS::DCPS::Value::Value | ( | int | i, | |
bool | conversion_preferred = false | |||
) |
Definition at line 530 of file FilterEvaluator.cpp.
00531 : type_(VAL_INT), i_(i), conversion_preferred_(conversion_preferred) 00532 {}
OpenDDS::DCPS::Value::Value | ( | unsigned int | u, | |
bool | conversion_preferred = false | |||
) |
Definition at line 534 of file FilterEvaluator.cpp.
00535 : type_(VAL_UINT), u_(u), conversion_preferred_(conversion_preferred) 00536 {}
OpenDDS::DCPS::Value::Value | ( | ACE_INT64 | l, | |
bool | conversion_preferred = false | |||
) |
Definition at line 538 of file FilterEvaluator.cpp.
00539 : type_(VAL_I64), l_(l), conversion_preferred_(conversion_preferred) 00540 {}
OpenDDS::DCPS::Value::Value | ( | ACE_UINT64 | m, | |
bool | conversion_preferred = false | |||
) |
Definition at line 542 of file FilterEvaluator.cpp.
00543 : type_(VAL_UI64), m_(m), conversion_preferred_(conversion_preferred) 00544 {}
OpenDDS::DCPS::Value::Value | ( | char | c, | |
bool | conversion_preferred = false | |||
) |
Definition at line 546 of file FilterEvaluator.cpp.
00547 : type_(VAL_CHAR), c_(c), conversion_preferred_(conversion_preferred) 00548 {}
OpenDDS::DCPS::Value::Value | ( | double | f, | |
bool | conversion_preferred = false | |||
) |
Definition at line 550 of file FilterEvaluator.cpp.
00551 : type_(VAL_FLOAT), f_(f), conversion_preferred_(conversion_preferred) 00552 {}
OpenDDS::DCPS::Value::Value | ( | ACE_CDR::LongDouble | ld, | |
bool | conversion_preferred = false | |||
) |
Definition at line 554 of file FilterEvaluator.cpp.
00555 : type_(VAL_LNGDUB), ld_(ld), conversion_preferred_(conversion_preferred) 00556 {}
OpenDDS::DCPS::Value::Value | ( | const char * | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 558 of file FilterEvaluator.cpp.
References strdup().
00559 : type_(VAL_STRING), s_(ACE_OS::strdup(s)) 00560 , conversion_preferred_(conversion_preferred) 00561 {}
OpenDDS::DCPS::Value::Value | ( | const TAO::String_Manager & | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 563 of file FilterEvaluator.cpp.
References strdup().
00564 : type_(VAL_STRING), s_(ACE_OS::strdup(s.in())) 00565 , conversion_preferred_(conversion_preferred) 00566 {}
OpenDDS::DCPS::Value::Value | ( | const TAO::WString_Manager & | s, | |
bool | conversion_preferred = false | |||
) |
Definition at line 568 of file FilterEvaluator.cpp.
References strdup().
00569 : type_(VAL_STRING) 00570 #ifdef DDS_HAS_WCHAR 00571 , s_(ACE_OS::strdup(ACE_Wide_To_Ascii(s.in()).char_rep())) 00572 #else 00573 , s_(0) 00574 #endif 00575 , conversion_preferred_(conversion_preferred) 00576 { 00577 #ifndef DDS_HAS_WCHAR 00578 ACE_UNUSED_ARG(s); 00579 #endif 00580 }
OpenDDS::DCPS::Value::~Value | ( | ) |
Definition at line 602 of file FilterEvaluator.cpp.
References ACE_OS::free(), s_, type_, and VAL_STRING.
00603 { 00604 if (type_ == VAL_STRING) ACE_OS::free((void*)s_); 00605 }
OpenDDS::DCPS::Value::Value | ( | const Value & | v | ) |
Definition at line 659 of file FilterEvaluator.cpp.
00660 : type_(v.type_), conversion_preferred_(v.conversion_preferred_) 00661 { 00662 Assign visitor(*this); 00663 visit(visitor, v); 00664 }
Definition at line 886 of file FilterEvaluator.cpp.
References conversion_preferred_, convert(), type_, VAL_CHAR, VAL_LARGEST_NUMERIC, and VAL_STRING.
Referenced by operator%(), operator<(), and operator==().
00887 { 00888 if (lhs.type_ == rhs.type_) { 00889 return; 00890 } 00891 bool ok = false; 00892 Value& smaller = (lhs.type_ < rhs.type_) ? lhs : rhs; 00893 Value& larger = (lhs.type_ < rhs.type_) ? rhs : lhs; 00894 if (smaller.conversion_preferred_) { 00895 ok = smaller.convert(larger.type_); 00896 } else if (larger.conversion_preferred_) { 00897 ok = larger.convert(smaller.type_); 00898 } else if (smaller.type_ == VAL_CHAR && larger.type_ == VAL_STRING) { 00899 ok = smaller.convert(VAL_STRING); 00900 } else if (larger.type_ <= VAL_LARGEST_NUMERIC) { 00901 ok = smaller.convert(larger.type_); 00902 } else if (larger.type_ == VAL_STRING) { 00903 if (larger.convert(smaller.type_)) { 00904 ok = true; 00905 } else { 00906 ok = smaller.convert(VAL_STRING); 00907 } 00908 } 00909 if (!ok) { 00910 throw std::runtime_error("Types don't match and aren't convertible."); 00911 } 00912 }
bool OpenDDS::DCPS::Value::convert | ( | Type | t | ) |
const char *const & OpenDDS::DCPS::Value::get | ( | void | ) | const [inline] |
const char *& OpenDDS::DCPS::Value::get | ( | void | ) | [inline] |
bool OpenDDS::DCPS::Value::like | ( | const Value & | v | ) | const |
Definition at line 796 of file FilterEvaluator.cpp.
References OPENDDS_STRING, s_, type_, VAL_STRING, and ACE::wild_match().
00797 { 00798 if (type_ != VAL_STRING || v.type_ != VAL_STRING) { 00799 throw std::runtime_error("'like' operator called on non-string arguments."); 00800 } 00801 OPENDDS_STRING pattern(v.s_); 00802 // escape ? or * in the pattern string so they are not wildcards 00803 for (size_t i = pattern.find_first_of("?*"); i < pattern.length(); 00804 i = pattern.find_first_of("?*", i + 1)) { 00805 pattern.insert(i++, 1, '\\'); 00806 } 00807 // translate _ and % wildcards into those used by ACE::wild_match() (?, *) 00808 for (size_t i = pattern.find_first_of("_%"); i < pattern.length(); 00809 i = pattern.find_first_of("_%", i + 1)) { 00810 pattern[i] = (pattern[i] == '_') ? '?' : '*'; 00811 } 00812 return ACE::wild_match(s_, pattern.c_str(), true, true); 00813 }
Definition at line 786 of file FilterEvaluator.cpp.
References conversion().
00787 { 00788 Value lhs = *this; 00789 Value rhs = v; 00790 conversion(lhs, rhs); 00791 Modulus visitor(lhs); 00792 return visit(visitor, rhs); 00793 }
bool OpenDDS::DCPS::Value::operator< | ( | const Value & | v | ) | const |
Definition at line 776 of file FilterEvaluator.cpp.
References conversion().
00777 { 00778 Value lhs = *this; 00779 Value rhs = v; 00780 conversion(lhs, rhs); 00781 Less visitor(lhs); 00782 return visit(visitor, rhs); 00783 }
Definition at line 667 of file FilterEvaluator.cpp.
References swap().
bool OpenDDS::DCPS::Value::operator== | ( | const Value & | v | ) | const |
Definition at line 766 of file FilterEvaluator.cpp.
References conversion().
00767 { 00768 Value lhs = *this; 00769 Value rhs = v; 00770 conversion(lhs, rhs); 00771 Equals visitor(lhs); 00772 return visit(visitor, rhs); 00773 }
void OpenDDS::DCPS::Value::swap | ( | Value & | other | ) |
Definition at line 675 of file FilterEvaluator.cpp.
References conversion_preferred_, ACE_OS::free(), s_, type_, and VAL_STRING.
Referenced by operator=().
00676 { 00677 Value t(v); 00678 00679 if (v.type_ == VAL_STRING) { 00680 ACE_OS::free((void*)v.s_); 00681 } 00682 00683 Assign visitor1(v, true); 00684 visit(visitor1, *this); 00685 if (type_ == VAL_STRING) { 00686 s_ = 0; 00687 } 00688 00689 Assign visitor2(*this, true); 00690 visit(visitor2, t); 00691 if (t.type_ == VAL_STRING) { 00692 t.s_ = 0; 00693 } 00694 00695 std::swap(conversion_preferred_, v.conversion_preferred_); 00696 std::swap(type_, v.type_); 00697 }
union { ... } |
Definition at line 63 of file FilterEvaluator.h.
Referenced by OpenDDS::DCPS::FilterEvaluator::eval_i(), and get().
Definition at line 68 of file FilterEvaluator.h.
Definition at line 73 of file FilterEvaluator.h.
Referenced by conversion(), and swap().
double OpenDDS::DCPS::Value::f_ |
Definition at line 69 of file FilterEvaluator.h.
Definition at line 64 of file FilterEvaluator.h.
Definition at line 66 of file FilterEvaluator.h.
Definition at line 70 of file FilterEvaluator.h.
Definition at line 67 of file FilterEvaluator.h.
const char* OpenDDS::DCPS::Value::s_ |
Definition at line 71 of file FilterEvaluator.h.
Definition at line 61 of file FilterEvaluator.h.
Referenced by conversion(), like(), swap(), and ~Value().
unsigned int OpenDDS::DCPS::Value::u_ |
Definition at line 65 of file FilterEvaluator.h.