diff options
| author | Vincent Richard <[email protected]> | 2006-04-05 17:48:09 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2006-04-05 17:48:09 +0000 |
| commit | b16c5ca684382677ae298eed6253c75d2eaf9806 (patch) | |
| tree | 50f33a0641261ac7e925640ceb142ba0ebc6df44 /src/net/pop3/POP3Utils.cpp | |
| parent | Refactored and cleaned up smart pointers. (diff) | |
| download | vmime-b16c5ca684382677ae298eed6253c75d2eaf9806.tar.gz vmime-b16c5ca684382677ae298eed6253c75d2eaf9806.zip | |
Clean up.
Diffstat (limited to 'src/net/pop3/POP3Utils.cpp')
| -rw-r--r-- | src/net/pop3/POP3Utils.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/net/pop3/POP3Utils.cpp b/src/net/pop3/POP3Utils.cpp new file mode 100644 index 00000000..a2f1857c --- /dev/null +++ b/src/net/pop3/POP3Utils.cpp @@ -0,0 +1,70 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2006 Vincent Richard <[email protected]> +// +// 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; either version 2 of +// the License, or (at your option) any later version. +// +// 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 along +// with this program; if not, write to the Free Software Foundation, Inc., Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.. +// + +#include "vmime/net/pop3/POP3Utils.hpp" + +#include <sstream> + + +namespace vmime { +namespace net { +namespace pop3 { + + +// static +void POP3Utils::parseMultiListOrUidlResponse(const string& response, std::map <int, string>& result) +{ + std::istringstream iss(response); + std::map <int, string> ids; + + string line; + + while (std::getline(iss, line)) + { + string::iterator it = line.begin(); + + while (it != line.end() && (*it == ' ' || *it == '\t')) + ++it; + + if (it != line.end()) + { + int number = 0; + + while (it != line.end() && (*it >= '0' && *it <= '9')) + { + number = (number * 10) + (*it - '0'); + ++it; + } + + while (it != line.end() && !(*it == ' ' || *it == '\t')) ++it; + while (it != line.end() && (*it == ' ' || *it == '\t')) ++it; + + if (it != line.end()) + { + result.insert(std::map <int, string>::value_type(number, string(it, line.end()))); + } + } + } +} + + +} // pop3 +} // net +} // vmime + |
