diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-03-06 14:21:43 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-03-06 14:21:43 +0000 |
| commit | b1713e63738839e861f0b10ef6ad58f0e93aef3e (patch) | |
| tree | f10b44c5e2b06ceb3cbe756fbbc865485c018702 /src/FileEntry.h | |
| parent | 61b2b88c29accbc5a4b04471abbd5cc7e38c4baf (diff) | |
2010-03-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added changeUri XML-RPC method. This method removes/adds URIs
dynamically.
* doc/aria2c.1.txt
* src/AbstractCommand.cc
* src/DownloadContext.cc
* src/DownloadContext.h
* src/FileEntry.cc
* src/FileEntry.h
* src/Request.cc
* src/Request.h
* src/RequestGroup.cc
* src/RequestGroupMan.cc
* src/XmlRpcMethodFactory.cc
* src/XmlRpcMethodImpl.cc
* src/XmlRpcMethodImpl.h
* test/FileEntryTest.cc
* test/XmlRpcMethodTest.cc
Diffstat (limited to 'src/FileEntry.h')
| -rw-r--r-- | src/FileEntry.h | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/FileEntry.h b/src/FileEntry.h index eac6980c..0017c925 100644 --- a/src/FileEntry.h +++ b/src/FileEntry.h @@ -129,15 +129,43 @@ public: return _spentUris; } - void setUris(const std::vector<std::string>& uris) + size_t setUris(const std::vector<std::string>& uris) { - _uris = std::deque<std::string>(uris.begin(), uris.end()); + _uris.clear(); + return addUris(uris.begin(), uris.end()); } template<typename InputIterator> - void addUris(InputIterator first, InputIterator last) + size_t addUris(InputIterator first, InputIterator last) { - _uris.insert(_uris.end(), first, last); + size_t count = 0; + for(; first != last; ++first) { + if(addUri(*first)) { + ++count; + } + } + return count; + } + + bool addUri(const std::string& uri) + { + if(Request().setUrl(uri)) { + _uris.push_back(uri); + return true; + } else { + return false; + } + } + + bool insertUri(const std::string& uri, size_t pos) + { + if(Request().setUrl(uri)) { + pos = std::min(pos, _uris.size()); + _uris.insert(_uris.begin()+pos, uri); + return true; + } else { + return false; + } } // Inserts _uris and _spentUris into uris. @@ -234,6 +262,8 @@ public: { return _originalName; } + + bool removeUri(const std::string& uri); }; // Returns the first FileEntry which isRequested() method returns |
