#include "IMFMultipart.h"

namespace coreutils {
   
   IMFMultipart::IMFMultipart() {}
   
   IMFMultipart::IMFMultipart(ZString &in, ZString boundary) {
      std::stringstream temp;
      temp << "\r\n--" << boundary;
      sections = in.split((char *)temp.str().c_str());
      for(int ix = 0; ix < sections.size(); ++ix) {
         if(sections[ix].equals((char *)"--\r\n"))
           sections[ix] = ZString((char *)"");
         sections[ix].ifNext((char *)"\r\n");           
      }
   }
   
   std::string IMFMultipart::toString() {
      return std::string(getData(), getLength());
   }
   
   int IMFMultipart::getCount() {
      return sections.size();
   }
   
   ZString IMFMultipart::getSectionAt(int index) {
      return sections[index];
   }
   
}
