本文整理汇总了C++中HttpRequest::GetParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest::GetParameter方法的具体用法?C++ HttpRequest::GetParameter怎么用?C++ HttpRequest::GetParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::GetParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRequest
void AssemblerWebApp::HandleRequest(SOCKET clientSocket, const HttpRequest& httpRequest)
{
const string firstHalf = "<textarea spellcheck='false' rows = '20' cols = '20' name = 'assembledcode'>";
const string secondHalf = "</textarea>";
const string firstHalf2 = "<textarea spellcheck='false' rows = '20' cols = '40' name = 'comment'>";
const string secondHalf2 = "</textarea>";
string errorText = "";
string assembledCode = "";
const bool createStack = httpRequest.GetParameter("stack") == "createstack";
const bool useSimulator = !httpRequest.GetParameter("stepcount").empty();
string code = httpRequest.GetParameter("comment");
const string username = httpRequest.GetParameter("username");
CS350::ENDIANESS endianType = CS350::CS_ORIGINAL;
const string endianness = httpRequest.GetParameter("endian");
if (endianness == "littleendian")
{
endianType = CS350::CS_LITTLE_ENDIAN;
}
else if (endianness == "bigendian")
{
endianType = CS350::CS_BIG_ENDIAN;
}
else
{
}
if (code.empty() && !createStack)
{
errorText += "missing code";
}
if (username.empty())
{
errorText += "missing user name\n";
}
unordered_map<string, string> pageParams;
if (errorText.empty())
{
if (createStack)
{
code = Assembler::GenerateStackCode();
}
else
{
code = HttpUtils::urlDecode(code);
}
Assembler ourAssembler(code, endianType, createStack);
assembledCode = ourAssembler.Assemble();
errorText += ourAssembler.GetErrorText();
Simulator simulator(ourAssembler.GetMachineCode(), ourAssembler.GetLineDataType());
size_t stepCt = ourAssembler.GetMachineCode().size();
string stepCount = to_string(stepCt);
if (useSimulator)
{
const string stepCount2 = httpRequest.GetParameter("stepcount");
stringstream sp(stepCount2);
unsigned int sentStep = 0;
sp >> sentStep;
if (sentStep > stepCt && sentStep < 600)
{
stepCt = sentStep;
stepCount = stepCount2;
}
}
pageParams["stepcount"] = stepCount;
simulator.Run(stepCt);
ProgramState endState = simulator.GetCurrentProgramState();
const string firstHalf = "<pre cols='130' style='border-style:solid; height:500px; overflow-y:scroll; background-color:white;' name='simval'>";
const string secondHalf = "</pre>";
pageParams["simulator"] = firstHalf + simulator.GetOutput() + secondHalf;
//create another textbox if there is expanded code
if (ourAssembler.HasExpandedCode() && errorText == "")
{
const string firstHalf3 = "<textarea spellcheck='false' rows = '20' cols = '40' name = 'expandedcode' readonly>";
const string secondHalf3 = "</textarea>";
pageParams["expansion"] = firstHalf3 + "//Expanded code generated\n//Uses r5 for scratch arithmetic\n\n" + ourAssembler.GetAssemblyCode() + secondHalf3;
}
}
pageParams["username"] = username;
pageParams["code"] = code;
if (errorText == "")
{
pageParams["results"] = firstHalf + assembledCode + secondHalf;
//.........这里部分代码省略.........