mirror of
https://github.com/jezhiggins/arabica
synced 2024-12-26 21:58:39 +01:00
XPathExpressionPtr no longer derives from boost::shared_ptr, it contains it instead
This commit is contained in:
parent
f6b2ed4966
commit
fac7cf88de
4 changed files with 15 additions and 16 deletions
|
@ -1,6 +1,3 @@
|
|||
// DOMWriter.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4786 4250 4503)
|
||||
#endif
|
||||
|
|
|
@ -51,20 +51,26 @@ private:
|
|||
}; // class XPathExpression
|
||||
|
||||
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
|
||||
class XPathExpressionPtr : public boost::shared_ptr<XPathExpression<string_type, string_adaptor> >
|
||||
class XPathExpressionPtr
|
||||
{
|
||||
public:
|
||||
XPathExpressionPtr() :
|
||||
boost::shared_ptr<XPathExpression<string_type, string_adaptor> >() { }
|
||||
explicit XPathExpressionPtr(XPathExpression<string_type, string_adaptor>* xp) :
|
||||
boost::shared_ptr<XPathExpression<string_type, string_adaptor> >(xp) { }
|
||||
XPathExpressionPtr(const XPathExpressionPtr& rhs) :
|
||||
boost::shared_ptr<XPathExpression<string_type, string_adaptor> >(rhs) { }
|
||||
XPathExpressionPtr() : ptr_() { }
|
||||
explicit XPathExpressionPtr(XPathExpression<string_type, string_adaptor>* xp) : ptr_(xp) { }
|
||||
XPathExpressionPtr(const XPathExpressionPtr& rhs) : ptr_(rhs.ptr_) { }
|
||||
XPathExpressionPtr& operator=(const XPathExpressionPtr& rhs)
|
||||
{
|
||||
boost::shared_ptr<XPathExpression<string_type, string_adaptor> >::operator=(rhs);
|
||||
ptr_ = rhs.ptr_;
|
||||
return *this;
|
||||
} // operator=
|
||||
|
||||
const XPathExpression<string_type, string_adaptor>* get() const { return ptr_.get(); }
|
||||
const XPathExpression<string_type, string_adaptor>* operator->() const { return ptr_.get(); }
|
||||
|
||||
operator bool() const { return ptr_.get(); }
|
||||
|
||||
private:
|
||||
typedef boost::shared_ptr<const XPathExpression<string_type, string_adaptor> > ExpressionPtr;
|
||||
ExpressionPtr ptr_;
|
||||
}; // class XPathExpressionPtr
|
||||
|
||||
namespace impl
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
std::vector<MatchExpr<string_type, string_adaptor> > compile_match(const string_type& xpath) const
|
||||
{
|
||||
XPathExpressionPtr<string_type, string_adaptor> wrapper = do_compile(xpath, &XPath::parse_xpath_match, match_factory());
|
||||
return (static_cast<impl::MatchExpressionWrapper<string_type, string_adaptor>*>(wrapper.get()))->matches();
|
||||
return (static_cast<const impl::MatchExpressionWrapper<string_type, string_adaptor>*>(wrapper.get()))->matches();
|
||||
} // compile_match
|
||||
|
||||
XPathValue<string_type, string_adaptor> evaluate(const string_type& xpath, const DOM::Node<string_type, string_adaptor>& context) const
|
||||
|
|
|
@ -26,13 +26,9 @@ public:
|
|||
XPathExpression<string_type, string_adaptor>* p2 = new NumericValue<string_type, string_adaptor>(2);
|
||||
|
||||
XPathExpressionPtr<string_type, string_adaptor> add(new impl::PlusOperator<string_type, string_adaptor>(p1, p2));
|
||||
assertEquals(1, add.use_count());
|
||||
|
||||
add->evaluate(dummy_);
|
||||
|
||||
assertEquals(3.0, add->evaluateAsNumber(dummy_), 0.0);
|
||||
|
||||
assertEquals(1, add.use_count());
|
||||
} // test1
|
||||
|
||||
void test2()
|
||||
|
|
Loading…
Reference in a new issue