From 25916051e603a037b54d3ee26e19b52bb7400b00 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Thu, 6 Mar 2025 14:47:57 -0800 Subject: [PATCH] added CGIFormattedData object. --- CGIFormattedData.cpp | 27 +++++++++++++++++++++++++++ CGIFormattedData.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 CGIFormattedData.cpp create mode 100644 CGIFormattedData.h diff --git a/CGIFormattedData.cpp b/CGIFormattedData.cpp new file mode 100644 index 0000000..13448ad --- /dev/null +++ b/CGIFormattedData.cpp @@ -0,0 +1,27 @@ +#include "CGIFormattedData.h" +#include "ZString.h" + +namespace coreutils { + + CGIFormattedData::CGIFormattedData() {} + + CGIFormattedData::CGIFormattedData(ZString cgiData) { + cgiData.split("&"); + for(int ix = 1; ix < cgiData.getList().size(); ++ix) { + cgiData[0].split("="); + data[cgiData[0]] = cgiData[1]; + data[cgiData[0]].fromCGI(); + } + } + + ZString CGIFormattedData::operator=(ZString cgiData) { + cgiData.split("&"); + for(int ix = 1; ix < cgiData.getList().size(); ++ix) { + cgiData[0].split("="); + data[cgiData[0]] = cgiData[1]; + data[cgiData[0]].fromCGI(); + } + return cgiData; + } + +} diff --git a/CGIFormattedData.h b/CGIFormattedData.h new file mode 100644 index 0000000..e6a3fc8 --- /dev/null +++ b/CGIFormattedData.h @@ -0,0 +1,29 @@ +#ifndef __CGIFormattedData_h__ +# define __CGIFormattedData_h__ + +# include "MString.h" +# include + +namespace coreutils { + + /// + /// Use the CGIFormattedData object to store and process data that + /// interfaces to the CGI format. Value pairs are accessible using + /// a common map interface. + /// + + class CGIFormattedData { + + public: + CGIFormattedData(); + CGIFormattedData(ZString cgiData); + + ZString operator=(ZString cgiData); + + std::map data; + + }; + +} + +#endif