49 template <
typename T_FROM,
typename T_TO>
50 static std::vector<T_TO*>
filter(
const std::vector<T_FROM*>& v)
52 std::vector<T_TO*> result;
53 for(
int i = 0; i < v.size(); i++) {
54 T_TO* t = cast<T_FROM, T_TO>(v[i]);
65 template <
typename T_FROM,
typename T_TO>
66 static T_TO*
cast(T_FROM* obj)
70 return dynamic_cast<T_TO*
>(obj);
71 }
catch (std::exception& e) {
79 template <
typename T_FROM,
typename T_TO>
80 static T_TO*
cast(T_FROM& obj)
82 return cast<T_FROM, T_TO>(&obj);
86 template <
typename T_FROM,
typename T_TO>
87 static std::vector<T_TO*> find(
const tgTagSearch& tagSearch,
const std::vector<T_FROM*> haystack)
90 std::vector<T_TO*> filtered = filter<T_FROM, T_TO>(haystack);
91 std::vector<T_TO*> result;
94 for(
int i = 0; i < filtered.size(); i++) {
95 tgTaggable* t = cast<T_TO, tgTaggable>(filtered[i]);
96 if(t != 0 && tagSearch.
matches(*t)) {
98 result.push_back(filtered[i]);
static T_TO * cast(T_FROM &obj)
static T_TO * cast(T_FROM *obj)
Contains the definition of class tgTagSearch $Id$.
const bool matches(const tgTags &tags) const
Contains the definition of class tgTaggable $Id$.
static std::vector< T_TO * > filter(const std::vector< T_FROM * > &v)