• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ poco::DateTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中poco::DateTime的典型用法代码示例。如果您正苦于以下问题:C++ DateTime类的具体用法?C++ DateTime怎么用?C++ DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: toStr

	string HRCReport::toStr(const Poco::DateTime& date) const{
            std::ostringstream ostr;
			string sDate;
			ostr << date.day() << "/" << date.month() << "/" << date.year();
			sDate = ostr.str();
			return sDate;
	}
开发者ID:tsela85,项目名称:SplAssignment2,代码行数:7,代码来源:HRCReport.cpp


示例2: PopulateIDList

void InactiveIdentityRequester::PopulateIDList()
{
	Poco::DateTime weekago;
	int id;
	int count=0;
	SQLite3DB::Transaction trans(m_db);

	weekago-=Poco::Timespan(7,0,0,0,0);
	weekago.assign(weekago.year(),weekago.month(),weekago.day(),0,0,0);

	// only selects, deferred OK
	trans.Begin();

	// select identities we want to query (haven't seen yet today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)
	SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen IS NOT NULL AND LastSeen<? AND tblIdentity.FailureCount<=(SELECT OptionValue FROM tblOption WHERE Option='MaxFailureCount') AND (PurgeDate IS NULL OR PurgeDate>datetime('now')) ORDER BY RANDOM();");
	st.Bind(0, Poco::DateTimeFormatter::format(weekago,"%Y-%m-%d %H:%M:%S"));
	trans.Step(st);

	m_ids.clear();

	while(st.RowReturned())
	{
		st.ResultInt(0,id);
		m_ids[std::pair<long,long>(count,id)].m_requested=false;
		trans.Step(st);
		count+=1;
	}

	trans.Finalize(st);
	trans.Commit();
}
开发者ID:steveatinfincia,项目名称:fms,代码行数:31,代码来源:inactiveidentityrequester.cpp


示例3: startElement

	void ForecastParser::startElement(const Poco::XML::XMLString& namespaceURI, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname,
			const Poco::XML::Attributes& attributes) {

		static std::map <int, int> hmap = hourMap();

		if (localName == "time"){
			int tz = 0;
			data.dateStr =  attributes.getValue("", "from");
			std::cout << data.dateStr << std::endl;
			Poco::DateTime dt;
			Poco::DateTimeParser::parse(data.dateStr, dt, tz);
			data.date = Poco::DateTime(
					dt.year(),
					dt.month(),
					dt.day(),
					hmap[dt.hour()]
			);
		}
		if (localName == "temperature"){
			data.temperature = Poco::NumberParser::parse(attributes.getValue("", "value"));
		}
		if (localName == "symbol"){
			data.img = Poco::NumberParser::parse(attributes.getValue("", "number"));
			data.info = attributes.getValue("", "name");
		}
		if (localName == "windSpeed"){
			data.wind = Poco::NumberParser::parseFloat(attributes.getValue("", "mps"));
		}
		if (localName == "precipitation"){
			data.precipitation = Poco::NumberParser::parseFloat(attributes.getValue("", "value"));
		}
	}
开发者ID:hadzim,项目名称:bb,代码行数:32,代码来源:ForecastParser.cpp


示例4: parseNew

void SyslogParser::parseNew(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos)
{
	Poco::Message::Priority prio = convert(severity);
	// rest of the unparsed header is:
	// VERSION SP TIMESTAMP SP HOSTNAME SP APP-NAME SP PROCID SP MSGID
	std::string versionStr(parseUntilSpace(msg, pos));
	std::string timeStr(parseUntilSpace(msg, pos)); // can be the nilvalue!
	std::string hostName(parseUntilSpace(msg, pos));
	std::string appName(parseUntilSpace(msg, pos));
	std::string procId(parseUntilSpace(msg, pos));
	std::string msgId(parseUntilSpace(msg, pos));
	std::string message(msg.substr(pos));
	pos = msg.size();
	Poco::DateTime date;
	int tzd = 0;
	bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::SYSLOG_TIMEFORMAT, timeStr, date, tzd);
	Poco::Message logEntry(msgId, message, prio);
	logEntry["host"] = hostName;
	logEntry["app"] = appName;
	
	if (hasDate)
		logEntry.setTime(date.timestamp());
	int lval(0);
	Poco::NumberParser::tryParse(procId, lval);
	logEntry.setPid(lval);
	_pListener->log(logEntry);
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:27,代码来源:RemoteSyslogListener.cpp


示例5: testInsertRequest

void MongoDBTest::testInsertRequest()
{
	if (!_connected)
	{
		std::cout << "Not connected, test skipped." << std::endl;
		return;
	}

	Poco::MongoDB::Document::Ptr player = new Poco::MongoDB::Document();
	player->add("lastname", std::string("Braem"));
	player->add("firstname", std::string("Franky"));

	Poco::DateTime birthdate;
	birthdate.assign(1969, 3, 9);
	player->add("birthdate", birthdate.timestamp());

	player->add("start", 1993);
	player->add("active", false);

	Poco::DateTime now;
	std::cout << now.day() << " " << now.hour() << ":" << now.minute() << ":" << now.second() << std::endl;
	player->add("lastupdated", now.timestamp());

	player->add("unknown", NullValue());

	Poco::MongoDB::InsertRequest request("team.players");
	request.documents().push_back(player);
	_mongo.sendRequest(request);
}
开发者ID:12307,项目名称:poco,代码行数:29,代码来源:MongoDBTest.cpp


示例6: run

	void run()
	{
		for(int i=0; i<kNumEnqueueByChild; ++i)
		{
			int counter = ++m_counter;
			Poco::DateTime datetime;
			datetime += Poco::Timespan(m_rnd.next(kScheduleMaxTime)*1000);
			m_queue.enqueueNotification(new ChildNotification(counter, m_name, datetime), datetime.timestamp());
			datetime.makeLocal(Poco::Timezone::tzd());
			m_msg.Message(Poco::format("   enqueueNotification #%d from %s (%s)"
										, counter
										, m_name
										, Poco::DateTimeFormatter::format(datetime.timestamp(), "%H:%M:%S.%i")));
		}
	}
开发者ID:schidler,项目名称:MeCloud,代码行数:15,代码来源:TimedNotificationQueueTest.cpp


示例7: main

int main()
{
	Poco::DateTime now;
	char szClientName[256] = { 0, };
	sprintf_s(szClientName, 256 - 1, "(%d-%d)", now.second(), now.millisecond());
		
	std::cout << "clinet(" << szClientName << ") 서버에 연결 시도..." << std::endl;
	Poco::Net::StreamSocket ss;

	try
	{
		ss.connect(Poco::Net::SocketAddress("localhost", PORT));

		for (int i = 0; i < 7; ++i)
		{
			char szMessage[256] = { 0, };
			sprintf_s(szMessage, 256 - 1, "%d, Send Message From %s", i, szClientName);
			auto nMsgLen = (int)strnlen_s(szMessage, 256 - 1);

			ss.sendBytes(szMessage, nMsgLen);

			std::cout << "서버에 보낸 메시지: " << szMessage << std::endl;


			char buffer[256] = { 0, };
			auto len = ss.receiveBytes(buffer, sizeof(buffer));

			if (len <= 0)
			{
				std::cout << "서버와 연결이 끊어졌습니다" << std::endl;
				break;
			}

			std::cout << "서버로부터 받은 메시지: " << buffer << std::endl;

			Poco::Thread::sleep(256);
		}

		ss.close();
	}
	catch (Poco::Exception& exc)
	{
		std::cout << "서버 접속 실패: " << exc.displayText() << std::endl;
	}
		
	getchar();
	return 0;
}
开发者ID:jacking75,项目名称:Poco_network_sample,代码行数:48,代码来源:multi_session_client.cpp


示例8: Stop

void ClearHistory::Stop()
{


	if (!_stopped) {

		_rdbmsClearHis->stop();

		_stopped = true;
		Poco::DateTime dataTime;
		dataTime +=	10;
		ClearQueue.enqueueNotification(new ClearNotofication(0 ),dataTime.timestamp());
		_thread.join();
		ClearQueue.clear();
		g_pClearHistory = NULL;
	}
}
开发者ID:timercrack,项目名称:uarc,代码行数:17,代码来源:ClearHistory.cpp


示例9: dump

    void TextSerializer::dump()
    {
        if (buffer.size() == 0)
            return;

        Poco::DateTime date = buffer[0]->DateTime;
        string file = Poco::format("%s/%04d%02d%02d.csv", path, date.year(), date.month(), date.day());

        std::ofstream os;
        os.open (file, std::ofstream::out | std::ofstream::app);

        for (int i = 0; i < buffer.size(); i++)
            os << serTick(buffer[i]);

        os << std::flush;
        os.close();
    }
开发者ID:Ainstain,项目名称:pheux,代码行数:17,代码来源:TextSerializer.cpp


示例10: main

//----------------------------------------
//	main
//----------------------------------------
int main(int /*argc*/, char** /*argv*/)
{
	PrepareConsoleLogger logger(Poco::Logger::ROOT, Poco::Message::PRIO_INFORMATION);

	ScopedLogMessage msg("DateTimeTest ", "start", "end");

	Poco::DateTime dateTime;

	msg.Message("  Current DateTime (UTC)");
	DisplayDateTime(dateTime, msg);

	msg.Message(Poco::format("  Current DateTime (Locat Time: %s [GMT%+d])", Poco::Timezone::name(), Poco::Timezone::tzd()/(60*60)));
	dateTime.makeLocal(Poco::Timezone::tzd());
	DisplayDateTime(dateTime, msg);

	msg.Message(Poco::format(Poco::DateTimeFormatter::format(dateTime, "  DateTimeFormatter: %w %b %e %H:%M:%S %%s %Y")
				,	Poco::Timezone::name()));

	return 0;
}
开发者ID:schidler,项目名称:MeCloud,代码行数:23,代码来源:DateTimeTest.cpp


示例11: CheckForNeededInsert

void TrustListInserter::CheckForNeededInsert()
{
	Poco::DateTime date;
	int currentday=date.day();
	date-=Poco::Timespan(0,6,0,0,0);
	// insert trust lists every 6 hours - if 6 hours ago was different day then set to midnight of current day to insert list today ASAP
	if(currentday!=date.day())
	{
		date.assign(date.year(),date.month(),currentday,0,0,0);
	}

	SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, PrivateKey FROM tblLocalIdentity WHERE tblLocalIdentity.Active='true' AND PrivateKey IS NOT NULL AND PrivateKey <> '' AND PublishTrustList='true' AND InsertingTrustList='false' AND (LastInsertedTrustList<=? OR LastInsertedTrustList IS NULL);");
	st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S"));
	st.Step();

	if(st.RowReturned())
	{
		int lid=0;
		std::string pkey("");
		st.ResultInt(0,lid);
		st.ResultText(1,pkey);
		StartInsert(lid,pkey);
	}

}
开发者ID:SeekingFor,项目名称:FMS,代码行数:25,代码来源:trustlistinserter.cpp


示例12: GenTick

    CThostFtdcDepthMarketDataField* Exchange::GenTick()
    {
        Poco::DateTime now;
        string date = Poco::format("%02d%02d%02d", now.year(), now.month(), now.day());
        string time = Poco::format("%02d:%02d:%02d", now.hour(), now.minute(), now.second());

        strcpy(tick->TradingDay, date.c_str());
        strcpy(tick->UpdateTime, time.c_str());
        strcpy(tick->InstrumentID, INSTRUMENT);
        tick->UpdateMillisec = now.millisecond();
        tick->LastPrice = RandomWalk(tick->LastPrice);
        tick->Volume = tick->Volume;
        return tick;
    }
开发者ID:Ainstain,项目名称:pheux,代码行数:14,代码来源:Exchange.cpp


示例13: prefix

    char* prefix(char* buffer, const std::size_t len, const char* level)
    {
        const char *threadName = Util::getThreadName();
#ifdef __linux
        const long osTid = Util::getThreadId();
#elif defined IOS
        const auto osTid = pthread_mach_thread_np(pthread_self());
#endif
        Poco::DateTime time;
        snprintf(buffer, len, "%s-%.05lu %.4u-%.2u-%.2u %.2u:%.2u:%.2u.%.6u [ %s ] %s  ",
                    (Source.getInited() ? Source.getId().c_str() : "<shutdown>"),
                    osTid,
                    time.year(), time.month(), time.day(),
                    time.hour(), time.minute(), time.second(),
                    time.millisecond() * 1000 + time.microsecond(),
                    threadName, level);
        return buffer;
    }
开发者ID:LibreOffice,项目名称:online,代码行数:18,代码来源:Log.cpp


示例14: CheckForNeededInsert

void IntroductionPuzzleInserter::CheckForNeededInsert()
{
	// only do 1 insert at a time
	if(m_inserting.size()==0)
	{
		// select all local ids that aren't single use and that aren't currently inserting a puzzle and are publishing a trust list
		SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity WHERE tblLocalIdentity.Active='true' AND PublishTrustList='true' AND SingleUse='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;");
		st.Step();

		// FIXME Convert to nested SELECT
		SQLite3DB::Statement st2=m_db->Prepare("SELECT UUID FROM tblIntroductionPuzzleInserts WHERE Day=? AND FoundSolution='false' AND LocalIdentityID=?;");

		while(st.RowReturned())
		{
			int localidentityid=0;
			std::string localidentityidstr="";
			Poco::DateTime now;
			float minutesbetweeninserts=0;
			minutesbetweeninserts=1440.0/(float)m_maxpuzzleinserts;
			Poco::DateTime lastinsert=now;
			lastinsert-=Poco::Timespan(0,0,minutesbetweeninserts,0,0);

			st.ResultInt(0, localidentityid);
			StringFunctions::Convert(localidentityid, localidentityidstr);

			// if this identity has any non-solved puzzles for today, we don't need to insert a new puzzle
			st2.Bind(0, Poco::DateTimeFormatter::format(now,"%Y-%m-%d"));
			st2.Bind(1, localidentityid);
			st2.Step();

			// identity doesn't have any non-solved puzzles for today - start a new insert
			if(!st2.RowReturned())
			{
				// make sure we are on the next day or the appropriate amount of time has elapsed since the last insert
				std::map<int,Poco::DateTime>::iterator i;
				if((i=m_lastinserted.find(localidentityid))==m_lastinserted.end() || (*i).second<=lastinsert || (*i).second.day()!=now.day())
				{
					StartInsert(localidentityid);
					m_lastinserted[localidentityid]=now;
				}
				else
				{
					m_log->trace("IntroductionPuzzleInserter::CheckForNeededInsert waiting to insert puzzle for "+localidentityidstr);
				}
			} else {
				st2.Reset();
			}

			st.Step();
		}
	}
}
开发者ID:SeekingFor,项目名称:FMS,代码行数:52,代码来源:introductionpuzzleinserter.cpp


示例15: testInsertRequest

void MongoDBTest::testInsertRequest()
{
	Poco::MongoDB::Document::Ptr player = new Poco::MongoDB::Document();
	player->add("lastname", std::string("Braem"));
	player->add("firstname", std::string("Franky"));

	Poco::DateTime birthdate;
	birthdate.assign(1969, 3, 9);
	player->add("birthdate", birthdate.timestamp());

	player->add("start", 1993);
	player->add("active", false);

	Poco::DateTime now;
	player->add("lastupdated", now.timestamp());

	player->add("unknown", NullValue());

	Poco::MongoDB::InsertRequest request("team.players");
	request.documents().push_back(player);
	_mongo->sendRequest(request);
}
开发者ID:Kampbell,项目名称:poco,代码行数:22,代码来源:MongoDBTest.cpp


示例16: dateTimeSync

void Utility::dateTimeSync(SQL_TIMESTAMP_STRUCT& ts, const Poco::DateTime& dt)
{
	ts.year = dt.year();
	ts.month = dt.month();
	ts.day = dt.day();
	ts.hour = dt.hour();
	ts.minute = dt.minute();
	ts.second = dt.second();
	// Fraction support is limited to milliseconds due to MS SQL Server limitation
	// see http://support.microsoft.com/kb/263872
	ts.fraction = (dt.millisecond() * 1000000);// + (dt.microsecond() * 1000);
}
开发者ID:lilinghui,项目名称:poco,代码行数:12,代码来源:Utility.cpp


示例17: GetSolarNoon

Poco::DateTime CSunRiseSet::GetSolarNoon(double dLon, Poco::DateTime time) 
{ 
	bool bLeap = IsLeapYear(time.year()); 
	 
	int iJulianDay = CalcJulianDay(time.month(),time.day(),bLeap); 
 
	double timeGMT = calcSolNoonGMT(iJulianDay, dLon);  
 
	double dHour = timeGMT / 60; 
	int iHour = (int)dHour; 
	double dMinute = 60 * (dHour - iHour); 
	int iMinute = (int)dMinute; 
	double dSecond = 60 * (dMinute - iMinute); 
	int iSecond = (int)dSecond; 
	 
	Poco::DateTime NewTime(time.year(),time.month(),time.day(),iHour,iMinute,iSecond); 
	NewTime.makeLocal(Poco::Timezone::tzd() - Poco::Timezone::dst()); 
	return NewTime;
} 
开发者ID:leomeyer,项目名称:OPDI,代码行数:19,代码来源:SunRiseSet.cpp


示例18: GetSunrise

Poco::DateTime CSunRiseSet::GetSunrise(double dLat,double dLon, Poco::DateTime time) 
{ 
	bool bLeap = IsLeapYear(time.year()); 
	 
	int iJulianDay = CalcJulianDay(time.month(),time.day(),bLeap); 
 
	double timeGMT = calcSunriseGMT(iJulianDay, dLat,dLon);  
 
 
	// if Northern hemisphere and spring or summer, use last sunrise and next sunset 
	if ((dLat > 66.4) && (iJulianDay > 79) && (iJulianDay < 267)) 
		timeGMT = findRecentSunrise(iJulianDay, dLat, dLon); 
	// if Northern hemisphere and fall or winter, use next sunrise and last sunset 
	else if ((dLat > 66.4) && ((iJulianDay < 83) || (iJulianDay > 263))) 
		timeGMT = findNextSunrise(iJulianDay, dLat, dLon); 
	// if Southern hemisphere and fall or winter, use last sunrise and next sunset 
	else if((dLat < -66.4) && ((iJulianDay < 83) || (iJulianDay > 263))) 
		timeGMT = findRecentSunrise(iJulianDay, dLat, dLon); 
	// if Southern hemisphere and spring or summer, use next sunrise and last sunset 
	else if((dLat < -66.4) && (iJulianDay > 79) && (iJulianDay < 267)) 
		timeGMT = findNextSunrise(iJulianDay, dLat, dLon); 
//	else  
//	{ 
		//("Unaccountable Missing Sunrise!"); 
//	} 
	 
	 
	double dHour = timeGMT / 60; 
	int iHour = (int)dHour; 
	double dMinute = 60 * (dHour - iHour); 
	int iMinute = (int)dMinute; 
	double dSecond = 60 * (dMinute - iMinute); 
	int iSecond = (int)dSecond; 
	 
	Poco::DateTime NewTime(time.year(),time.month(),time.day(),iHour,iMinute,iSecond); 
	NewTime.makeLocal(Poco::Timezone::tzd() - Poco::Timezone::dst()); 
	return NewTime;
} 
开发者ID:leomeyer,项目名称:OPDI,代码行数:38,代码来源:SunRiseSet.cpp


示例19: extractExifData


//.........这里部分代码省略.........
                float decDegrees = getDecimalDegrees(tag_data);

                char refValue[2];

                if (it->first == EXIF_TAG_GPS_LATITUDE)
                {
                    // Get the latitude reference value; used to determine if positive or negative decimal value
                    ExifEntry * latitudeRef = exif_data_get_entry(exifData, it->first);
                    exif_entry_get_value(latitudeRef, refValue,2);

                    if (strcmp(refValue, "S") == 0)
                        decDegrees *= -1;
                }
                else
                {
                    // Get the longitude reference value; used to determine if positive or negative decimal value
                    ExifEntry * longitudeRef = exif_data_get_entry(exifData, it->first);
                    exif_entry_get_value(longitudeRef, refValue,2);

                    if (strcmp(refValue, "W") == 0)
                        decDegrees *= -1;
                }
                
                TskBlackboardAttribute attr(it->second, name(), "", decDegrees);
                attrs.push_back(attr);                
            }
            else if (it->first == EXIF_TAG_GPS_SPEED)
            {
                // Check for the EXIF_IFD_GPS image file directory to avoid interoperability value
                ExifIfd ifd = exif_entry_get_ifd(exifEntry);
                if (ifd != EXIF_IFD_GPS)
                    continue;

                //Get the GPS speed value
                exif_entry_get_value(exifEntry, tag_data, 256);

                float speed = getGPSSpeed(tag_data);

                char refValue[2];

                //Get the GPS speed reference value
                ExifEntry * speedRef = exif_data_get_entry(exifData, it->first);
                exif_entry_get_value(speedRef, refValue,2);

                //Convert Kilometers per hour to meters per second 
                if (strcmp(refValue, "K") == 0)
                {
                     speed *= 0.277778;
                }
                //Convert Miles per hour to meters per second 
                if (strcmp(refValue, "M") == 0)
                {
                    speed *= 0.44704;
                }
                //Convert Knots to meters per second
                if (strcmp(refValue, "N") == 0)
                {
                    speed *= 0.514444;
                }
                
                TskBlackboardAttribute attr(it->second, name(), "", speed);
                attrs.push_back(attr);
            }
            else if (it->first == EXIF_TAG_DATE_TIME_ORIGINAL) 
            {
                exif_entry_get_value(exifEntry, tag_data, 256);
                datetime = std::string(tag_data);
            }
            else if(it->first == EXIF_TAG_TIME_ZONE_OFFSET){
                exif_entry_get_value(exifEntry, tag_data, 256);
                timezone = atoi(tag_data);
            }
            else
            {   
                // Get the tag's data
                exif_entry_get_value(exifEntry, tag_data, 256);

                // Add tag data to blackboard
                TskBlackboardAttribute attr(it->second, name(), "", tag_data);
                attrs.push_back(attr);
            }
        }
        if(!datetime.empty()){
            Poco::DateTime parsedDT;
            int tzd;
            Poco::DateTimeParser::tryParse(datetime, parsedDT, tzd);
            if(timezone)
                parsedDT.makeUTC(timezone);
            else
                parsedDT.makeUTC(tzd);
            TskBlackboardAttribute attr(TSK_DATETIME, name(), "", (uint64_t)parsedDT.utcTime());
            attrs.push_back(attr);
        }
        if(attrs.size() > 0){
            TskBlackboardArtifact art = pFile->createArtifact(TSK_METADATA_EXIF);
            for(size_t i = 0; i < attrs.size(); i++){
                art.addAttribute(attrs[i]);
            }
        }
    }
开发者ID:aoighost,项目名称:c_LibExifModule,代码行数:101,代码来源:LibExifModule.cpp


示例20: parseBSD

void SyslogParser::parseBSD(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos)
{
	Poco::Message::Priority prio = convert(severity);
	// rest of the unparsed header is:
	// "%b %f %H:%M:%S" SP hostname|ipaddress
	// detect three spaces
	int spaceCnt = 0;
	std::size_t start = pos;
	while (spaceCnt < 3 && pos < msg.size())
	{
		if (msg[pos] == ' ')
		{
			spaceCnt++;
			if (spaceCnt == 1)
			{
				// size must be 3 chars for month
				if (pos - start != 3)
				{
					// probably a shortened time value, or the hostname
					// assume hostName
					Poco::Message logEntry(msg.substr(start, pos-start), msg.substr(pos+1), prio);
					_pListener->log(logEntry);
					return;
				}
			}
			else if (spaceCnt == 2)
			{
				// a day value!
				if (!(std::isdigit(msg[pos-1]) && (std::isdigit(msg[pos-2]) || std::isspace(msg[pos-2]))))
				{
					// assume the next field is a hostname
					spaceCnt = 3;
				}
			}
			if (pos + 1 < msg.size() && msg[pos+1] == ' ')
			{
				// we have two spaces when the day value is smaller than 10!
				++pos; // skip one
			}
		}
		++pos;
	}
	std::string timeStr(msg.substr(start, pos-start-1));
	int tzd(0);
	Poco::DateTime date;
	int year = date.year(); // year is not included, use the current one
	bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::BSD_TIMEFORMAT, timeStr, date, tzd);
	if (hasDate)
	{
		int m = date.month();
		int d = date.day();
		int h = date.hour();
		int min = date.minute();
		int sec = date.second();
		date = Poco::DateTime(year, m, d, h, min, sec);
	}
	// next entry is host SP
	std::string hostName(parseUntilSpace(msg, pos));

	// TAG: at most 32 alphanumeric chars, ANY non alphannumeric indicates start of message content
	// ignore: treat everything as content
	std::string message(msg.substr(pos));
	pos = msg.size();
	Poco::Message logEntry(hostName, message, prio);
	logEntry.setTime(date.timestamp());
	_pListener->log(logEntry);
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:67,代码来源:RemoteSyslogListener.cpp



注:本文中的poco::DateTime类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ poco::File类代码示例发布时间:2022-05-31
下一篇:
C++ po::variables_map类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap