本文整理汇总了C++中EventData::getAsLog方法的典型用法代码示例。如果您正苦于以下问题:C++ EventData::getAsLog方法的具体用法?C++ EventData::getAsLog怎么用?C++ EventData::getAsLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventData
的用法示例。
在下文中一共展示了EventData::getAsLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertXmlParameterToEvent
void convertXmlParameterToEvent(EventData &eventdata, XmlParameter const &xmlparameter)
{
eventdata.clear();
EventData::DType dtype = (EventData::DType)xmlparameter.getParameter("dtype").getAsInt();
EventData::EType etype = (EventData::EType)xmlparameter.getParameter("etype").getAsInt();
eventdata.getEventType() = etype;
eventdata.setType(dtype);
double miliss = xmlparameter.getParameter("etime").getAsDate();
if (miliss > 0)
eventdata.setEventDate( miliss/ 1000.0 );
else
eventdata.setEventDate(-1);
eventdata.eventSource_m = xmlparameter.getParameter("source").getAsString();
eventdata.parentUid_m = xmlparameter.getParameter("puid").getAsUid();
eventdata.uid_m = xmlparameter.getParameter("uid").getAsUid();
if (dtype==EventData::DT_Log) {
XmlParameter const& logParam = xmlparameter.getXmlParameter("log");
CommonLog& log = eventdata.getAsLog(true);
double miliss = logParam.getParameter("time").getAsDate();
if (miliss > 0)
log.logDate_m = miliss / 1000.0;
else
log.logDate_m = -1;
log.logLevel_m = logParam.getParameter("level").getAsInt();
log.context_m = logParam.getParameter("context").getAsString();
log.content_m = logParam.getParameter("content").getAsString();
log.session_m = logParam.getParameter("session").getAsString();
log.logThread_m = logParam.getParameter("thread").getAsInt();
}
else if (dtype==EventData::DT_CommonXml) {
eventdata.getAsXmlParameter(true) = xmlparameter.getXmlParameter("commonxml");
}
else if (dtype==EventData::DT_String) {
eventdata.getAsString(true) = xmlparameter.getParameter("str").getAsString();
}
else if (dtype==EventData::DT_StringList) {
eventdata.getAsStringList(true) = xmlparameter.getParameter("strlist").getAsStringList();
}
else if (dtype==EventData::DT_StringMap) {
CppUtils::StringMap& strmap = eventdata.getAsStringMap(true);
XmlParameter const& strMapParam = xmlparameter.getXmlParameter("strmap");
CppUtils::StringList keys;
strMapParam.getValueKeys(keys);
for(int i = 0; i < keys.size(); i++) {
strmap[ keys[ i ] ] = strMapParam.getParameter(keys[ i ]).getAsString();
}
}
else if (dtype==EventData::DT_Ticker) {
convertFromXmlParameter( eventdata.getAsRtData(), xmlparameter.getXmlParameter("ticker"));
}
else if (eventdata.getType()==EventData::DT_TickerList) {
RtDataList& rtlist = eventdata.getAsRtDataList(true);
XmlParameter::XmlParameterList const& tickerMapParamList = xmlparameter.getXmlParameterList("tickerlist");
RtData rtdata;
for(int i = 0; i < tickerMapParamList.size(); i++) {
convertFromXmlParameter( rtdata, tickerMapParamList[ i ]);
rtlist.push_back(rtdata);
}
}
else if (dtype==EventData::DT_Level2Data) {
//convertLevel2FromXmlParameter( eventdata.getAsLevel2Data(), xmlparameter.getXmlParameter("level2data"));
HTASSERT(false);
}
else if (dtype==EventData::DT_Level1Data) {
convertLevel1FromXmlParameter( eventdata.getAsLevel1Data(), xmlparameter.getXmlParameter("level1data"));
}
else if (dtype==EventData::DT_DrawableObject) {
convertDrawableObjFromXmlParameter( eventdata.getAsDrawableObject(), xmlparameter.getXmlParameter("drawobj"));
}
else {
HTASSERT(false);
}
}
示例2: convertEventToXmlParameter
// conversion functions
void convertEventToXmlParameter(EventData const& eventdata, XmlParameter &xmlparameter)
{
xmlparameter.clear();
xmlparameter.getName() = "event_packet";
xmlparameter.getParameter("source").getAsString(true) = eventdata.getSource();
xmlparameter.getParameter("puid").getAsUid(true) = eventdata.getParentEventUid();
xmlparameter.getParameter("uid").getAsUid(true) = eventdata.getEventUid();
xmlparameter.getParameter("etype").getAsInt(true) = eventdata.getEventType();
xmlparameter.getParameter("dtype").getAsInt(true) = eventdata.getType();
double sec = eventdata.getEventDate();
if (sec <= 0)
xmlparameter.getParameter("etime").getAsDate(true) =-1;
else
xmlparameter.getParameter("etime").getAsDate(true) = sec * 1000.0;
if (eventdata.getType()==EventData::DT_Log) {
XmlParameter logParam;
CommonLog const& log = eventdata.getAsLog();
double sec = log.logDate_m;
if (sec <= 0)
logParam.getParameter("time").getAsDate(true) = -1;
else
logParam.getParameter("time").getAsDate(true) = sec * 1000.0;
logParam.getParameter("level").getAsInt(true) = log.logLevel_m;
logParam.getParameter("context").getAsString(true) = log.context_m;
logParam.getParameter("content").getAsString(true) = CppUtils::wrapToCDataTags(log.content_m);
logParam.getParameter("session").getAsString(true) = log.session_m;
logParam.getParameter("thread").getAsInt(true) = log.logThread_m;
xmlparameter.getXmlParameter("log") = logParam;
}
else if (eventdata.getType()==EventData::DT_CommonXml) {
xmlparameter.getXmlParameter("commonxml") = eventdata.getAsXmlParameter();
}
else if (eventdata.getType()==EventData::DT_String) {
xmlparameter.getParameter("str").getAsString(true) = eventdata.getAsString();
}
else if (eventdata.getType()==EventData::DT_StringList) {
xmlparameter.getParameter("strlist").getAsStringList(true) = eventdata.getAsStringList();
}
else if (eventdata.getType()==EventData::DT_StringMap) {
XmlParameter strMapParam;
CppUtils::StringMap const& strmap = eventdata.getAsStringMap();
for(CppUtils::StringMap::const_iterator it = strmap.begin(); it != strmap.end(); it++) {
strMapParam.getParameter(it->first).getAsString(true) = it->second;
}
xmlparameter.getXmlParameter("strmap") = strMapParam;
}
else if (eventdata.getType()==EventData::DT_Ticker) {
convertToXmlParameter(eventdata.getAsRtData(), xmlparameter.getXmlParameter("ticker"));
}
else if (eventdata.getType()==EventData::DT_TickerList) {
XmlParameter tickerParam;
RtDataList const& rtlist = eventdata.getAsRtDataList();
for(int i = 0; i < rtlist.size(); i++) {
convertToXmlParameter(rtlist[ i ], tickerParam);
xmlparameter.getXmlParameterList("tickerlist").push_back(tickerParam);
}
}
else if (eventdata.getType()==EventData::DT_Dummy) {
// no-op
}
else if (eventdata.getType()==EventData::DT_Level2Data) {
//convertLevel2ToXmlParameter(eventdata.getAsLevel2Data(), xmlparameter.getXmlParameter("level2data"));
HTASSERT(false);
}
else if (eventdata.getType()==EventData::DT_Level1Data) {
convertLevel1ToXmlParameter(eventdata.getAsLevel1Data(), xmlparameter.getXmlParameter("level1data"));
}
else if (eventdata.getType()==EventData::DT_DrawableObject) {
convertDrawableObjToXmlParameter(eventdata.getAsDrawableObject(), xmlparameter.getXmlParameter("drawobj"));
}
else {
// dummy
HTASSERT(false);
}
}