1 #include <portability.h>
33 #include "soar_TraceNames.h"
35 #include "ElementXML.h"
41 using namespace soar_TraceNames;
42 namespace stn = soar_TraceNames;
52 soarxml::XMLTrace* pTrace =
new soarxml::XMLTrace();
53 soarxml::XMLTrace* pCommands =
new soarxml::XMLTrace();
71 soarxml::XMLTrace* pTrace =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_trace );
72 soarxml::XMLTrace* pCommands =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_commands );
88 soarxml::XMLTrace* pTrace =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_trace );
89 soarxml::XMLTrace* pCommands =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_commands );
102 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
103 pXML->BeginTag( pTag ) ;
108 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
109 pXML->EndTag( pTag ) ;
116 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
117 pXML->MoveCurrentToParent();
122 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
123 pXML->MoveCurrentToChild( index );
128 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
129 pXML->MoveCurrentToLastChild();
135 SNPRINTF(buf, 50,
"%llu", static_cast<long long unsigned>(value));
137 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
138 pXML->AddAttribute( pAttribute, buf ) ;
144 SNPRINTF(buf, 50,
"%d", value);
146 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
147 pXML->AddAttribute( pAttribute, buf ) ;
153 SNPRINTF(buf, 50,
"%lld", static_cast<long long>(value));
155 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
156 pXML->AddAttribute( pAttribute, buf ) ;
162 SNPRINTF(buf, 50,
"%f", value);
164 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
165 pXML->AddAttribute( pAttribute, buf ) ;
170 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
171 pXML->AddAttribute( pAttribute, pValue ) ;
178 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
179 pXML->AddAttribute( pAttribute,
symbol_to_string( pAgent, pSymbol,
true, 0, 0 ) ) ;
184 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
186 pXML->BeginTag( pTag ) ;
187 pXML->EndTag( pTag ) ;
190 void xml_object(
agent* pAgent,
char const* pTag,
char const* pAttribute,
char const* pValue )
192 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
194 pXML->BeginTag( pTag ) ;
195 pXML->AddAttribute( pAttribute, pValue ) ;
196 pXML->EndTag( pTag ) ;
199 void xml_object(
agent* pAgent,
char const* pTag,
char const* pAttribute, uint64_t value )
201 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
203 pXML->BeginTag( pTag ) ;
205 pXML->EndTag( pTag ) ;
208 void xml_object(
agent* pAgent,
char const* pTag,
char const* pAttribute, int64_t value )
210 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
212 pXML->BeginTag( pTag ) ;
214 pXML->EndTag( pTag ) ;
217 void xml_object(
agent* pAgent,
char const* pTag,
char const* pAttribute,
double value )
219 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
221 pXML->BeginTag( pTag ) ;
223 pXML->EndTag( pTag ) ;
229 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
231 pXML->BeginTag( stn::kTagWME ) ;
248 pXML->EndTag( stn::kTagWME ) ;
253 xml_object( pAgent, stn::kTagWarning, stn::kTypeString, pMessage );
258 xml_object( pAgent, stn::kTagError, stn::kTypeString, pMessage );
263 xml_object( pAgent, stn::kTagMessage, stn::kTypeString, pMessage );
268 xml_object( pAgent, stn::kTagVerbose, stn::kTypeString, pMessage );
273 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
274 if ( pXML->IsEmpty() )
279 soarxml::ElementXML* pResult = pXML->DetatchObject();
283 char* pStr = pResult->GenerateXMLString(
true ) ;
284 pResult->DeleteString( pStr ) ;
291 soarxml::ElementXML* pCallbackData =
new soarxml::ElementXML( pResult->GetXMLHandle() );
292 pCallbackData->AddRefOnHandle();
297 cb->
function( pAgent, cb->
eventid, cb->
data, static_cast< soar_call_data >( pCallbackData ) );
312 soarxml::XMLTrace* pXML =
static_cast< soarxml::XMLTrace*
>( pAgent->
xml_destination );
314 soarxml::ElementXML* pReturn = pXML->DetatchObject();
341 soarxml::ElementXML* pReturn =
xml_get_xml( pAgent );