54 lines
948 B
C++
54 lines
948 B
C++
|
#include "cgi.hpp"
|
||
|
|
||
|
#include <cgicc/Cgicc.h>
|
||
|
|
||
|
#include <exception>
|
||
|
#include <sstream>
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace FediBlock
|
||
|
{
|
||
|
|
||
|
using std::exception;
|
||
|
using std::getline;
|
||
|
using std::string;
|
||
|
using std::string_view;
|
||
|
using std::stringstream;
|
||
|
using std::vector;
|
||
|
|
||
|
entry_type parse_formdata()
|
||
|
{
|
||
|
entry_type answer;
|
||
|
try
|
||
|
{
|
||
|
cgicc::Cgicc cgi;
|
||
|
answer.instance = cgi("instance");
|
||
|
answer.tags = string_to_array(cgi("tags"));
|
||
|
answer.receipts = string_to_array(cgi("receipts"));
|
||
|
answer.description = cgi("description");
|
||
|
}
|
||
|
catch (exception &e)
|
||
|
{
|
||
|
// TODO: Error handling.
|
||
|
}
|
||
|
|
||
|
return answer;
|
||
|
}
|
||
|
|
||
|
vector<string> string_to_array(const string_view str)
|
||
|
{
|
||
|
stringstream input(str.data());
|
||
|
string element;
|
||
|
vector<string> output;
|
||
|
|
||
|
while (getline(input, element, ','))
|
||
|
{
|
||
|
output.push_back(element);
|
||
|
}
|
||
|
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
} // namespace FediBlock
|