1 // DAVMultiStatus.hxx -- parser for WebDAV MultiStatus XML data
3 // Copyright (C) 2012 James Turner <zakalawe@mac.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef SG_IO_DAVMULTISTATUS_HXX
21 #define SG_IO_DAVMULTISTATUS_HXX
25 #include <memory> // for auto_ptr
35 DAVResource(const std::string& url);
36 virtual ~DAVResource() { }
43 const Type type() const
46 const std::string& url() const
49 std::string name() const;
52 * SVN servers use this field to expose the head revision
53 * of the resource, which is useful
55 const std::string& versionName() const
56 { return _versionName; }
58 void setVersionName(const std::string& aVersion);
60 DAVCollection* container() const
61 { return _container; }
63 virtual bool isCollection() const
66 void setVersionControlledConfiguration(const std::string& vcc);
67 const std::string& versionControlledConfiguration() const
70 void setMD5(const std::string& md5Hex);
71 const std::string& md5() const
74 friend class DAVCollection;
78 std::string _versionName;
81 DAVCollection* _container;
84 typedef std::vector<DAVResource*> DAVResourceList;
86 class DAVCollection : public DAVResource
89 DAVCollection(const std::string& url);
90 virtual ~DAVCollection();
92 DAVResourceList contents() const;
94 void addChild(DAVResource* res);
95 void removeChild(DAVResource* res);
97 DAVCollection* createChildCollection(const std::string& name);
100 * find the collection member with the specified URL, or return NULL
101 * if no such member of this collection exists.
103 DAVResource* childWithUrl(const std::string& url) const;
106 * find the collection member with the specified name, or return NULL
108 DAVResource* childWithName(const std::string& name) const;
111 * wrapper around URL manipulation
113 std::string urlForChildWithName(const std::string& name) const;
115 virtual bool isCollection() const
118 DAVResourceList _contents;
127 // incremental XML parsing
128 void parseXML(const char* data, int size);
132 bool isValid() const;
134 DAVResource* resource();
136 class DAVMultiStatusPrivate;
138 std::auto_ptr<DAVMultiStatusPrivate> _d;
141 } // of namespace simgear
143 #endif // of SG_IO_DAVMULTISTATUS_HXX