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) {
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-");
if(!in.ifNext(":")) {
printf("%02X\n", in.str()[0]);
throw coreutils::Exception("Invalid character in expected header token.");
if(key.length() != 0) {
if(!in.ifNext(":")) {
printf("%02X\n", in.str()[0]);
throw coreutils::Exception("Invalid character in expected header token.");
}
in.skipWhitespace();
value = in.str();
}
in.skipWhitespace();
value = in.getTokenExclude("\r\n");
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) {

View File

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