2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/util/Predicates.h
20 * Useful XMLObject predicates for use with STL algorithms.
23 #ifndef __xmltooling_predicates_h__
24 #define __xmltooling_predicates_h__
26 #include <xmltooling/XMLObject.h>
30 namespace xmltooling {
33 * Predicate that checks the QName of an XMLObject.
41 * @param q the QName to check for
43 hasQName(const QName& q) : m_q(q) {
47 * Returns true iff the provided object's QName matches the constructor argument.
49 * @param xmlObject the object to examine
51 bool operator()(const XMLObject* xmlObject) const {
52 return xmlObject ? (xmlObject->getElementQName() == m_q) : false;
60 * Predicate that checks the xsi:type of an XMLObject.
68 * @param q the QName to check for
70 hasSchemaType(const QName& q) : m_q(q) {
74 * Returns true iff the provided object's xsi:type matches the constructor argument.
76 * @param xmlObject the object to examine
78 bool operator()(const XMLObject* xmlObject) const {
79 const QName* xsitype = xmlObject ? xmlObject->getSchemaType() : NULL;
80 return xsitype ? (*xsitype == m_q) : false;
89 #endif /* __xmltooling_predicates_h__ */