diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-10-17 13:11:03 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-10-17 13:11:03 +0000 |
| commit | 10e371c25a9185d3d2d02ddd3d40dfcbc49967d5 (patch) | |
| tree | 5e2726c3fce612a2c85c6ec0db7d12c1cc4fc216 /src/Util.h | |
| parent | ac63a32c4811803eb892e244a022ae263c0e6e70 (diff) | |
2009-10-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that Netrc::parse() cannot recognize comment line.
* src/Netrc.cc
* src/Util.h
* test/NetrcTest.cc
* test/sample.netrc
Diffstat (limited to 'src/Util.h')
| -rw-r--r-- | src/Util.h | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -140,6 +140,37 @@ public: static void slice(std::deque<std::string>& result, const std::string& src, char delim, bool trim = false); + template<typename OutputIterator> + static OutputIterator split(const std::string& src, OutputIterator out, + const std::string& delims, bool doTrim = false) + { + std::string::size_type p = 0; + while(1) { + std::string::size_type np = src.find_first_of(delims, p); + if(np == std::string::npos) { + std::string term = src.substr(p); + if(doTrim) { + term = trim(term); + } + if(!term.empty()) { + *out = term; + ++out; + } + break; + } + std::string term = src.substr(p, np-p); + if(doTrim) { + term = trim(term); + } + p = np+1; + if(!term.empty()) { + *out = term; + ++out; + } + } + return out; + } + static const std::string DEFAULT_TRIM_CHARSET; static std::string trim(const std::string& src, |
