#include "CGIFormattedData.h"
#include "ZString.h"

namespace coreutils {
   
   CGIFormattedData::CGIFormattedData() {}
   
   CGIFormattedData::CGIFormattedData(ZString cgiData) {
      if(cgiData != "") {	   
	 cgiData.split("&");
	 for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
	    cgiData[ix].split("=");
	    data[cgiData[ix][0]] = cgiData[ix][1];
	    data[cgiData[ix][0]].fromCGI();
	 }
      }      
   }

   ZString CGIFormattedData::operator=(ZString cgiData) {
      if(cgiData != "") {	   
	 cgiData.split("&");
	 for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
	    cgiData[ix].split("=");
	    data[cgiData[ix][0]] = cgiData[ix][1];
	    data[cgiData[ix][0]].fromCGI();
	 }
      }
      return cgiData;
   }      
}
