mirror of https://github.com/vitalif/grive2
node iterator still being worked
parent
3584e12152
commit
65ae81bb96
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
set( GRIVE_VERSION "0.0.4" )
|
set( GRIVE_VERSION "0.0.5-pre" )
|
||||||
|
|
||||||
add_subdirectory( libgrive )
|
add_subdirectory( libgrive )
|
||||||
add_subdirectory( grive )
|
add_subdirectory( grive )
|
||||||
|
|
|
@ -52,7 +52,7 @@ target_link_libraries( grive
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(grive PROPERTIES
|
set_target_properties(grive PROPERTIES
|
||||||
SOVERSION 0 VERSION 0.0.4
|
SOVERSION 0 VERSION ${GRIVE_VERSION}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS grive LIBRARY DESTINATION lib)
|
install(TARGETS grive LIBRARY DESTINATION lib)
|
||||||
|
|
|
@ -177,6 +177,38 @@ private :
|
||||||
ImplVec m_children ;
|
ImplVec m_children ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
Node::iterator::iterator( ImplVec::iterator it ) : m_it( it )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Node::iterator::value_type Node::iterator::operator*() const
|
||||||
|
{
|
||||||
|
return Node( *m_it ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node::iterator Node::iterator::operator++()
|
||||||
|
{
|
||||||
|
m_it++ ;
|
||||||
|
return *this ;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node::iterator Node::iterator::operator++(int)
|
||||||
|
{
|
||||||
|
iterator tmp( *this ) ;
|
||||||
|
++tmp ;
|
||||||
|
return tmp ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Node::iterator::operator==( const iterator& i ) const
|
||||||
|
{
|
||||||
|
return m_it == i.m_it ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Node::iterator::operator!=( const iterator& i ) const
|
||||||
|
{
|
||||||
|
return m_it != i.m_it ;
|
||||||
|
}
|
||||||
|
|
||||||
Node::Node() : m_ptr( new Impl )
|
Node::Node() : m_ptr( new Impl )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -322,4 +354,15 @@ std::ostream& operator<<( std::ostream& os, const Node& node )
|
||||||
return os ;
|
return os ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node::iterator Node::begin()
|
||||||
|
{
|
||||||
|
return iterator( m_ptr->Begin() ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node::iterator Node::end()
|
||||||
|
{
|
||||||
|
return iterator( m_ptr->End() ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // end namespace
|
} } // end namespace
|
||||||
|
|
|
@ -63,6 +63,9 @@ public :
|
||||||
// TODO: implement iterator begin/end functions instead
|
// TODO: implement iterator begin/end functions instead
|
||||||
std::vector<Node> Attr() const ;
|
std::vector<Node> Attr() const ;
|
||||||
|
|
||||||
|
iterator begin() ;
|
||||||
|
iterator end() ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
class Impl ;
|
class Impl ;
|
||||||
typedef std::vector<Impl*> ImplVec ;
|
typedef std::vector<Impl*> ImplVec ;
|
||||||
|
@ -71,15 +74,19 @@ public :
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
iterator( ImplVec::iterator *impl ) ;
|
explicit iterator( std::vector< gr::xml::Node::Impl* >::iterator it ) ;
|
||||||
|
|
||||||
typedef Node value_type ;
|
typedef Node value_type ;
|
||||||
|
|
||||||
value_type operator*() const ;
|
value_type operator*() const ;
|
||||||
// value_type operator*() const ;
|
iterator operator++() ;
|
||||||
|
iterator operator++(int) ;
|
||||||
|
|
||||||
|
bool operator==( const iterator& i ) const ;
|
||||||
|
bool operator!=( const iterator& i ) const ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
ImplVec::iterator *m_node ;
|
ImplVec::iterator m_it ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,15 @@ void NodeTest::TestParseFile( )
|
||||||
CPPUNIT_ASSERT_EQUAL( std::string("q"), n["entry"]["link"]["@href"].Value() ) ;
|
CPPUNIT_ASSERT_EQUAL( std::string("q"), n["entry"]["link"]["@href"].Value() ) ;
|
||||||
CPPUNIT_ASSERT_EQUAL( Node::element, n["entry"]["link"]["href"].GetType() ) ;
|
CPPUNIT_ASSERT_EQUAL( Node::element, n["entry"]["link"]["href"].GetType() ) ;
|
||||||
CPPUNIT_ASSERT_EQUAL( std::string("abc"), n["entry"]["link"]["href"].Value() ) ;
|
CPPUNIT_ASSERT_EQUAL( std::string("abc"), n["entry"]["link"]["href"].Value() ) ;
|
||||||
|
/*
|
||||||
|
Node el = n["entry"]["link"] ;
|
||||||
|
Node::iterator i = el.begin() ;
|
||||||
|
while ( i != el.end() )
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL( std::string("href"), (*i).Name() ) ;
|
||||||
|
++i ;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace grut
|
} // end of namespace grut
|
||||||
|
|
Loading…
Reference in New Issue