CoreUtils/IMFMultipart.cpp

35 lines
734 B
C++

#include "IMFMultipart.h"
#include "PString.h"
namespace coreutils {
IMFMultipart::IMFMultipart() {
buffer = "";
}
IMFMultipart::IMFMultipart(PString &in, std::string boundary) {
buffer = in.str();
in.cursor -= 2;
sections = in.split("\r\n--" + boundary);
for(int ix = 0; ix < sections.size(); ++ix) {
if(sections[ix].str() == "--\r\n")
sections[ix] = PString("");
if(sections[ix].str().substr(0, 2) == "\r\n")
sections[ix].cursor += 2;
}
}
std::string IMFMultipart::toString() {
return buffer;
}
int IMFMultipart::getCount() {
return sections.size();
}
PString IMFMultipart::getSectionAt(int index) {
return sections[index];
}
}