mirror of https://github.com/vitalif/grive2
implementing iterator for XML nodes
parent
f987888cac
commit
1aaca87ad0
|
@ -22,6 +22,7 @@
|
|||
#include "File.hh"
|
||||
|
||||
#include "http/HTTP.hh"
|
||||
#include "http/XmlResponse.hh"
|
||||
#include "protocol/Json.hh"
|
||||
#include "protocol/JsonResponse.hh"
|
||||
#include "protocol/OAuth2.hh"
|
||||
|
@ -29,6 +30,7 @@
|
|||
#include "util/DateTime.hh"
|
||||
#include "util/OS.hh"
|
||||
#include "util/Path.hh"
|
||||
#include "xml/Node.hh"
|
||||
|
||||
// standard C++ library
|
||||
#include <algorithm>
|
||||
|
@ -55,11 +57,21 @@ Drive::Drive( OAuth2& auth ) :
|
|||
http::Agent agent ;
|
||||
agent.Get( root_url + "?alt=json&showfolders=true", &str, m_http_hdr ) ;
|
||||
Json resp = str.Response() ;
|
||||
|
||||
/*
|
||||
http::XmlResponse xml ;
|
||||
agent.Get( root_url, &xml, m_http_hdr ) ;
|
||||
xml::Node nroot = xml.Response() ;
|
||||
*/
|
||||
Json resume_link ;
|
||||
if ( resp["feed"]["link"].FindInArray( "rel", "http://schemas.google.com/g/2005#resumable-create-media", resume_link ) )
|
||||
m_resume_link = resume_link["href"].As<std::string>() ;
|
||||
|
||||
/*
|
||||
std::string next_link ;
|
||||
Json next_link_json ;
|
||||
if ( resp["feed"]["link"].FindInArray( "rel", "next", next_link_json ) )
|
||||
next_link = next_link_json["href"].As<std::string>() ;
|
||||
std::cout << "next link = " << next_link << std::endl ;
|
||||
*/
|
||||
Json::Array entries = resp["feed"]["entry"].As<Json::Array>() ;
|
||||
ConstructDirTree( entries ) ;
|
||||
|
||||
|
|
|
@ -311,7 +311,10 @@ std::vector<Node> Node::Children() const
|
|||
|
||||
std::ostream& operator<<( std::ostream& os, const Node& node )
|
||||
{
|
||||
os << '<' << node.Name() << '>' ;
|
||||
if ( node.GetType() == Node::element )
|
||||
{
|
||||
os << '<' << node.Name() << ' ' ;
|
||||
}
|
||||
|
||||
std::vector<Node> c = node.Children() ;
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ namespace gr { namespace xml {
|
|||
|
||||
class Node
|
||||
{
|
||||
public :
|
||||
class iterator ;
|
||||
|
||||
public :
|
||||
Node() ;
|
||||
Node( const Node& node ) ;
|
||||
|
@ -57,8 +60,23 @@ public :
|
|||
// TODO: implement iterator begin/end functions instead
|
||||
std::vector<Node> Children() const ;
|
||||
|
||||
// TODO: implement iterator begin/end functions instead
|
||||
std::vector<Node> Attr() const ;
|
||||
|
||||
private :
|
||||
class Impl ;
|
||||
typedef std::vector<Impl*> ImplVec ;
|
||||
|
||||
public :
|
||||
class iterator
|
||||
{
|
||||
public :
|
||||
iterator( ImplVec::iterator *impl ) ;
|
||||
|
||||
private :
|
||||
ImplVec::iterator *m_node ;
|
||||
} ;
|
||||
|
||||
|
||||
private :
|
||||
explicit Node( Impl *impl ) ;
|
||||
|
|
Loading…
Reference in New Issue