diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-05 12:15:34 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-05 12:15:34 +0900 |
| commit | 7d68c40a7746121c9e709c173f738c64cfca7603 (patch) | |
| tree | 65fbf7cdea4be59fbf0891684fdae1e550326cf6 /src/bencode2.cc | |
| parent | d1d49036651012433595357ca31e6f65dbec3a6b (diff) | |
Made decoderawstring return pair of iterators, not string.
Diffstat (limited to 'src/bencode2.cc')
| -rw-r--r-- | src/bencode2.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bencode2.cc b/src/bencode2.cc index 1db0ddbe..74198b0d 100644 --- a/src/bencode2.cc +++ b/src/bencode2.cc @@ -57,7 +57,7 @@ decodeiter namespace { template<typename InputIterator> -std::pair<std::string, InputIterator> +std::pair<std::pair<InputIterator, InputIterator>, InputIterator> decoderawstring(InputIterator first, InputIterator last) { InputIterator i = first; @@ -77,7 +77,7 @@ decoderawstring(InputIterator first, InputIterator last) len, static_cast<int>(last-i)), error_code::BENCODE_PARSE_ERROR); } - return std::make_pair(std::string(i, i+len), i+len); + return std::make_pair(std::make_pair(i, i+len), i+len); } } // namespace @@ -86,8 +86,9 @@ template<typename InputIterator> std::pair<SharedHandle<ValueBase>, InputIterator> decodestring(InputIterator first, InputIterator last) { - std::pair<std::string, InputIterator> r = decoderawstring(first, last); - return std::make_pair(String::g(r.first), r.second); + std::pair<std::pair<InputIterator, InputIterator>, InputIterator> r = + decoderawstring(first, last); + return std::make_pair(String::g(r.first.first, r.first.second), r.second); } } // namespace @@ -121,10 +122,11 @@ decodedict if(*first == 'e') { return std::make_pair(dict, ++first); } else { - std::pair<std::string, InputIterator> keyp = decoderawstring(first, last); + std::pair<std::pair<InputIterator, InputIterator>, InputIterator> keyp = + decoderawstring(first, last); std::pair<SharedHandle<ValueBase>, InputIterator> r = decodeiter(keyp.second, last, depth); - dict->put(keyp.first, r.first); + dict->put(std::string(keyp.first.first, keyp.first.second), r.first); first = r.second; } } |
