int CSVSnmpOID::GetResult(MonitorResult &ResultList) { m_bSum = false; int nResult = -1; if(m_szOID.empty()) return nResult; sprintf(str,"Type:%d\n",m_nType); if(m_nType == 0) {//如果OID类型是简单变量 SetOID(m_szOID.c_str()); nResult = GetRequest(ResultList); } else {//如果是表格变量 if(m_szOIDIndex.empty()) {//如果索引值为空,取表格变量 SetOID(m_szOID.c_str()); nResult = GetBulkRequest(ResultList);//获得表格变量结果 } else {//索引值不为空,取简单变量 char chOIDTmp[MAX_BUFF_LEN] = {0}; sprintf(chOIDTmp, "%s.%s", m_szOID.c_str(), m_szOIDIndex.c_str()); SetOID(chOIDTmp);//重新设置OID nResult = GetRequest(ResultList);//获得简单变量结果 } } return nResult;//返回结果 }
static void Interleave() { /* ---- */ /* Open */ /* ---- */ int nf = gArgs.infile.size(); vector<XML_TKEM> xml; vector<TiXmlElement*> layer( nf ); for( int i = 0; i < nf; ++i ) { xml.push_back( XML_TKEM( gArgs.infile[i], flog ) ); layer[i] = xml[i].GetFirstLayer(); } /* --------------------------------------------- */ /* Interleave, adopting layer structure of file0 */ /* --------------------------------------------- */ TiXmlNode* lyrset0 = layer[0]->Parent(); TiXmlElement* next0; int nextoid = xml[0].NextOID(); for( ;; ) { // next layer0 before adding anything next0 = layer[0]->NextSiblingElement(); // set z and add with locally reversed order for( int i = nf - 1; i > 0; --i ) { layer[i]->SetAttribute( "z", layer[0]->Attribute( "z" ) ); nextoid = SetOID( layer[i], nextoid ); lyrset0->InsertBeforeChild( layer[0], *layer[i] ); } //advance layers if( !(layer[0] = next0) ) goto save; for( int i = 1; i < nf; ++i ) { if( !(layer[i] = layer[i]->NextSiblingElement()) ) goto save; } } /* ---- */ /* Save */ /* ---- */ save: xml[0].Save( "xmltmp.txt", true ); }
// If par object has an 'oid' set it to nextoid and recursively // do the same for all children of par. // // Return highest applied oid + 1. // int SetOID( TiXmlNode* par, int nextoid ) { const char* s; s = ((TiXmlElement*)par)->Attribute( "oid" ); if( s ) ((TiXmlElement*)par)->SetAttribute( "oid", nextoid++ ); TiXmlNode* ch = par->FirstChild(); for( ; ch; ch = par->IterateChildren( ch ) ) nextoid = SetOID( ch, nextoid ); return nextoid; }