grive2/libgrive/src/xml/NodeSet.hh

71 lines
1.7 KiB
C++
Raw Normal View History

2012-05-12 06:48:54 +04:00
/*
grive: an GPL program to sync a local directory with Google Drive
Copyright (C) 2012 Wan Wai Ho
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
2013-04-28 19:50:20 +04:00
#include "util/Exception.hh"
2012-05-12 06:48:54 +04:00
#include "Node.hh"
#include <cstddef>
#include <iosfwd>
2012-05-12 07:09:31 +04:00
#include <string>
2012-05-12 06:48:54 +04:00
namespace gr { namespace xml {
class NodeSet
{
public :
typedef Node::iterator iterator ;
2013-04-28 19:50:20 +04:00
typedef boost::error_info<struct EmptyNodeSet, int> EmptyNodeSet_ ;
2012-05-12 06:48:54 +04:00
public :
2012-05-12 07:47:51 +04:00
NodeSet() ;
2012-05-12 08:27:35 +04:00
NodeSet( const NodeSet& n ) ;
2012-05-12 06:48:54 +04:00
NodeSet( iterator first, iterator last ) ;
2012-05-12 07:47:51 +04:00
2012-05-12 08:27:35 +04:00
NodeSet& operator=( const NodeSet& ns ) ;
void Swap( NodeSet& ns ) ;
2012-05-12 07:47:51 +04:00
void Add( const Node& n ) ;
2012-05-12 06:48:54 +04:00
iterator begin() const ;
iterator end() const ;
bool empty() const ;
std::size_t size() const ;
2012-05-12 07:09:31 +04:00
Node front() const ;
2012-05-12 06:48:54 +04:00
2012-05-12 07:47:51 +04:00
NodeSet Find( const std::string& name, const std::string& value ) const ;
2012-05-12 06:48:54 +04:00
2012-05-12 07:09:31 +04:00
// forwarding common Node operations to Node
operator std::string() const ;
NodeSet operator[]( const std::string& name ) const ;
bool operator==( const std::string& value ) const ;
2012-05-12 06:48:54 +04:00
private :
2012-05-12 07:47:51 +04:00
Node m_tmp ;
2012-05-12 06:48:54 +04:00
iterator m_first ;
iterator m_last ;
} ;
std::ostream& operator<<( std::ostream& os, const NodeSet& node ) ;
} } // end of namespace