Continued refinement of IMF objects.

This commit is contained in:
Brad Arant 2020-05-04 10:02:52 -07:00
parent 018c130df1
commit f4496fc682
2 changed files with 19 additions and 9 deletions

View File

@ -9,14 +9,23 @@ namespace coreutils {
IMFHeader::IMFHeader(PString &in) { IMFHeader::IMFHeader(PString &in) {
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"); key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-");
if(key.length() != 0) {
if(!in.ifNext(":")) { if(!in.ifNext(":")) {
printf("%02X\n", in.str()[0]); printf("%02X\n", in.str()[0]);
throw coreutils::Exception("Invalid character in expected header token."); throw coreutils::Exception("Invalid character in expected header token.");
} }
in.skipWhitespace(); in.skipWhitespace();
value = in.getTokenExclude("\r\n"); value = in.str();
if(!in.ifNext("\r\n")) }
throw coreutils::Exception("Expected CRLF."); else if(in.skipWhitespace() > 0) {
}
else if(in.str() == "") {
}
} }
IMFHeader::IMFHeader(std::string key, std::string value) { IMFHeader::IMFHeader(std::string key, std::string value) {

View File

@ -76,8 +76,9 @@ namespace coreutils {
return test; return test;
} }
void PString::skipWhitespace() { int PString::skipWhitespace() {
cursor = pstring.find_first_not_of(" \t", cursor); size_t found = pstring.find_first_not_of(" \t", cursor);
return found != cursor::npos ? cursor + found: 0;
} }
int PString::size() { int PString::size() {