MCPcopy Create free account
hub / github.com/SoarGroup/Soar / GetLastResultSML

Method GetLastResultSML

Core/CLI/src/cli_CommandLineInterface.cpp:282–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void CommandLineInterface::GetLastResultSML(sml::Connection* pConnection, soarxml::ElementXML* pResponse, bool echoResults)
283{
284 assert(pConnection);
285 assert(pResponse);
286
287 // Log output
288 if (m_pLogFile)
289 {
290 (*m_pLogFile) << m_Result.str() << std::endl;
291 }
292
293 if (m_LastError.empty())
294 {
295 if (m_RawOutput)
296 {
297 pConnection->AddSimpleResultToSMLResponse(pResponse, m_Result.str().c_str());
298 }
299 else
300 {
301 // If there are tags in the response list, add them
302 if (!m_ResponseTags.empty())
303 {
304 TagResult* pTag = new TagResult();
305
306 ElementXMLListIter iter = m_ResponseTags.begin();
307 while (iter != m_ResponseTags.end())
308 {
309 pTag->AddChild(*iter);
310 m_ResponseTags.erase(iter);
311 iter = m_ResponseTags.begin();
312 }
313
314 pResponse->AddChild(pTag);
315 }
316 else
317 {
318 pConnection->AddSimpleResultToSMLResponse(pResponse, sml_Names::kTrue);
319 }
320 }
321 }
322 else
323 {
324 pConnection->AddErrorToSMLResponse(pResponse, m_Result.str().c_str(), 1);
325 }
326
327 if (echoResults && m_pAgentSML)
328 {
329 m_pAgentSML->FireEchoEvent(pConnection, m_Result.str().c_str()) ;
330 }
331
332 // reset state
333 m_Result.str("");
334
335 // Delete all remaining xml objects
336 for (ElementXMLListIter cleanupIter = m_ResponseTags.begin(); cleanupIter != m_ResponseTags.end(); ++cleanupIter)
337 {
338 delete *cleanupIter;
339 }

Callers

nothing calls this directly

Calls 5

endMethod · 0.80
AddErrorToSMLResponseMethod · 0.80
AddChildMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected