本文整理汇总了C++中currentDateTime函数的典型用法代码示例。如果您正苦于以下问题:C++ currentDateTime函数的具体用法?C++ currentDateTime怎么用?C++ currentDateTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了currentDateTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: printf
/*-------------------------------------------------------
Upstream MQTTSnRegister
-------------------------------------------------------*/
void GatewayControlTask::handleSnRegister(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){
printf(FORMAT2, currentDateTime(), "REGISTER", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg));
MQTTSnRegister* snMsg = new MQTTSnRegister();
MQTTSnRegAck* respMsg = new MQTTSnRegAck();
snMsg->absorb(msg);
respMsg->setMsgId(snMsg->getMsgId());
uint16_t tpId = clnode->getTopics()->createTopic(snMsg->getTopicName());
respMsg->setTopicId(tpId);
respMsg->setReturnCode(MQTTSN_RC_ACCEPTED);
clnode->setClientSendMessage(respMsg);
Event* evrg = new Event();
evrg->setClientSendEvent(clnode);
printf(FORMAT1, currentDateTime(), "REGACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(respMsg));
_res->getClientSendQue()->post(evrg);
delete snMsg;
}
开发者ID:comrit,项目名称:MQTT-SN,代码行数:28,代码来源:GatewayControlTask.cpp
示例2: theLogfile
/**
* Function: Logger::WriteToFile()
* Description: Writes a specific message to a logFile and the generic logfile.
* Based on the messageType it also writes the message to a specific log file
*/
void Logger::WriteToFile(MessageType newType, const std::string& message)
{
std::fstream theLogfile (genericlogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
if (theLogfile.is_open())
{
theLogfile << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl;
theLogfile.close();
}
else
{
std::cout << "Error: unable to open logfile '" << genericlogfile << "'!" << std::endl;
}
if (newType == Success)
{
std::fstream specialisedLog(succeslogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
if (specialisedLog.is_open())
{
specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl;
specialisedLog.close();
}
else
{
std::cout << "Error: unable to open logfile '" << succeslogfile << "'!" << std::endl;
}
}
else if (newType == Error || newType == FatalError)
{
std::fstream specialisedLog(errorlogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
if (specialisedLog.is_open())
{
specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl;
specialisedLog.close();
}
else
{
std::cout << "Error: unable to open logfile '" << errorlogfile << "'!" << std::endl;
}
}
else if (newType == Warning)
{
std::fstream specialisedLog(warninglogfile.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
if (specialisedLog.is_open())
{
specialisedLog << "[" << currentDateTime() << "] " << toString(newType) << ": " << message << std::endl;
specialisedLog.close();
}
else
{
std::cout << "Error: unable to open logfile '" << warninglogfile << "'!" << std::endl;
}
}
}
开发者ID:gamer145,项目名称:KB01,代码行数:61,代码来源:Logger.cpp
示例3: MQTTSnPublish
/*-------------------------------------------------------
Downstream MQTTPublish
-------------------------------------------------------*/
void GatewayControlTask::handlePublish(Event* ev, ClientNode* clnode, MQTTMessage* msg){
MQTTPublish* mqMsg = static_cast<MQTTPublish*>(msg);
MQTTSnPublish* snMsg = new MQTTSnPublish();
string* tp = mqMsg->getTopic();
uint16_t tpId;
if(tp->size() == 2){
tpId = getUint16((uint8_t*)tp);
snMsg->setFlags(MQTTSN_TOPIC_TYPE_SHORT);
}else{
tpId = clnode->getTopics()->getTopicId(tp);
snMsg->setFlags(MQTTSN_TOPIC_TYPE_NORMAL);
}
if(tpId == 0){
/* ----- may be a publish message response of subscribed with '#' or '+' -----*/
tpId = clnode->getTopics()->createTopic(tp);
if(tpId > 0){
MQTTSnRegister* regMsg = new MQTTSnRegister();
regMsg->setTopicId(tpId);
regMsg->setTopicName(tp);
printf(FORMAT2, currentDateTime(), "REGISTER", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(regMsg));
clnode->setClientSendMessage(regMsg);
Event* evrg = new Event();
evrg->setClientSendEvent(clnode);
_res->getClientSendQue()->post(evrg); // Send Register first.
}else{
printf("GatewayControlTask Can't create Topic %s\n", tp->c_str());
return;
}
}
snMsg->setTopicId(tpId);
snMsg->setMsgId(mqMsg->getMessageId());
snMsg->setData(mqMsg->getPayload(),mqMsg->getPayloadLength());
snMsg->setQos(mqMsg->getQos());
if(mqMsg->isDup()){
snMsg->setDup();
}
if(mqMsg->isRetain()){
snMsg->setDup();
}
clnode->setClientSendMessage(snMsg);
printf(GREEN_FORMAT1, currentDateTime(), "PUBLISH", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(snMsg));
Event* ev1 = new Event();
ev1->setClientSendEvent(clnode);
_res->getClientSendQue()->post(ev1);
}
开发者ID:comrit,项目名称:MQTT-SN,代码行数:58,代码来源:GatewayControlTask.cpp
示例4: log
void CoreServer::write_log (log PRIORTY,std::string logtxt)
{
std::fstream log("ArmaEasyDB.log",std::ios::out | std::ios::app);
switch(PRIORTY) {
case INFO :
if(debug) {
std::cout << "[" << currentDateTime() <<"]" << " [INFO]: " << logtxt << std::endl;
}
log << "[" << currentDateTime() <<"]" << " [INFO]: " << logtxt << std::endl;
break;
case WARNING :
if(debug) {
std::cout << "[" << currentDateTime() <<"]" << " [WARNING]: " << logtxt << std::endl;
}
log << "[" << currentDateTime() <<"]" << " [WARNING]: " << logtxt << std::endl;
break;
case _ERROR:
if(debug) {
std::cout << "[" << currentDateTime() <<"]" << " [ERROR]: " << logtxt << std::endl;
}
log << "[" << currentDateTime() <<"]" << " [ERROR]: " << logtxt << std::endl;
break;
case OUTPUT:
if(debug) {
std::cout << "[" << currentDateTime() <<"]" << " [OUTPUT]: " << logtxt << std::endl;
}
log << "[" << currentDateTime() <<"]" << " [OUTPUT]: " << logtxt << std::endl;
break;
}
}
开发者ID:CoreDevTeam,项目名称:ArmaEasyDB,代码行数:35,代码来源:coreserver_main_source.cpp
示例5: sendMessageHidden
void sendMessageHidden(string str,string message){
vector<string> temp;
string ret;
//string message;
//cout << "Please enter your message to " << str << " : ";
//getline(cin >> ws,message);
temp.push_back("MSG");
temp.push_back(username);
temp.push_back(str);
temp.push_back(currentDateTime());
temp.push_back(message);
ret = protocolMaker(temp);
if (sendToServer(ret) == 0){
string path = "bin/client/message_history/";
path += username;
path += "-";
path += str;
path += ".txt";
vector<string> data = readExternalFileAutoCreate(path);
data.push_back(ret);
//moveToBottom(path);
//writeExternalFile(path,data);
writeExternalFile2(path,ret); //append data baru aja
}
else{
cout << "Failed to send messages or the user does not exist!" << endl << endl;
}
}
开发者ID:ClearingPath,项目名称:Linker-Messeger,代码行数:28,代码来源:client.cpp
示例6: initialize
// Initializes LOG.txt file with some info for the session
void initialize(FILE *file)
{
char* dateTime = currentDateTime();
fprintf(file, "\n\n");
fprintf(file, "|***********************************************************|\n");
fprintf(file, "| _ _ _____ _ ___ _ _ |\n");
fprintf(file, "| | | | | |_ _|| | / _ \\ | || | |\n");
fprintf(file, "| | |_| | ___ __ _ _ __ | | | |_ / /_\\ \\| || | |\n");
fprintf(file, "| | _ | / _ \\ / _` || '__| | | | __| | _ || || | |\n");
fprintf(file, "| | | | || __/| (_| || | _| |_ | |_ | | | || || | |\n");
fprintf(file, "| \\_| |_/ \\___| \\__,_||_| \\___/ \\__| \\_| |_/|_||_| |\n");
fprintf(file, "| |\n");
fprintf(file, "| |\n");
fprintf(file, "| Windows version |\n");
fprintf(file, "| |\n");
fprintf(file, "|***********************************************************|\n");
fprintf(file, "| |\n");
fprintf(file, "| Created by: Ander Granado |\n");
fprintf(file, "| |\n");
fprintf(file, "| Avaiable here: |\n");
fprintf(file, "| https://github.com/ander94lakx/HearItAllLinux |\n");
fprintf(file, "| |\n");
fprintf(file, "| Session timestamp: " + dateTime + " |\n");
fprintf(file, "| |\n");
fprintf(file, "|***********************************************************|\n\n");
}
开发者ID:ander94lakx,项目名称:HearItAllLinux,代码行数:27,代码来源:HearItAllLinux.c
示例7: sprintf
void TMesh::logToFileAndExit(const char *s)
{
static char msg[2048];
sprintf(msg, "%s\nFILE: %s\nRETURN VALUE: %s\n\n", currentDateTime(), (filename) ? (filename) : ("unknown"), s);
addMessageToLogFile(msg);
TMesh::error(msg);
}
开发者ID:MarcoAttene,项目名称:MeshFix-V2.0,代码行数:7,代码来源:tmesh.cpp
示例8: currentDateTime
void Logger::print(LogLevel level, std::string message, const char* file, int line)
{
if(!m_file.is_open() || level > m_level)
return;
m_file << currentDateTime();
switch(level)
{
case INFO:
{
m_file<<" [INFO] ";
break;
}
case WARN:
{
m_file<<" [WARN] ";
break;
}
case ERROR:
{
m_file<<" [ERROR] ";
break;
}
default:
{
m_file<<" [INFO] ";
break;
}
}
m_file<<"- "<<file<<":"<<line<<" - "<<message<<std::endl;
}
开发者ID:hudovisk,项目名称:MyGE,代码行数:30,代码来源:Logger.cpp
示例9: ReportFailure
void ReportFailure(const char * condition, const char * file, int line, const char * msg, ...)
{
char messageBuffer[1024] = "";
if (msg != NULL)
{
va_list args;
va_start(args, msg);
//vsprintf(messageBuffer, msg, args);
vsnprintf_s(messageBuffer, 1024, msg, args);
va_end(args);
}
std::stringstream ss;
ss << std::endl;
ss << "!Assert: " << condition << std::endl;
ss << "File: " << file << std::endl;
ss << "Message: " << messageBuffer << std::endl;
ss << "Line: " << line << std::endl;
ss << "Time: " << currentDateTime() << std::endl;
lastErrorMessage = messageBuffer;
std::cerr << ss.str();
BWAPI::Broodwar->printf("%s", ss.str().c_str());
Logger::LogAppendToFile(Config::Debug::ErrorLogFilename, ss.str());
}
开发者ID:nateheat,项目名称:ualbertabot,代码行数:26,代码来源:UABAssert.cpp
示例10: ReportFailure
void ReportFailure(const char * condition, const char * file, int line, const char * msg, ...)
{
char messageBuffer[1024] = "";
if (msg != NULL)
{
va_list args;
va_start(args, msg);
//vsprintf(messageBuffer, msg, args);
vsnprintf_s(messageBuffer, 1024, msg, args);
va_end(args);
}
std::stringstream ss;
ss << std::endl;
ss << "!Assert: " << condition << std::endl;
ss << "File: " << file << std::endl;
ss << "Message: " << messageBuffer << std::endl;
ss << "Line: " << line << std::endl;
ss << "Time: " << currentDateTime() << std::endl;
lastErrorMessage = messageBuffer;
std::cerr << ss.str();
throw BOSSException(ss.str());
}
开发者ID:Cdingram,项目名称:GGEZ-Bot,代码行数:26,代码来源:BOSSAssert.cpp
示例11: generateReport
string generateReport(string filePath)
{
TCHAR szEXEPath[2048];
char applicationPath[2048];
string mes;
GetModuleFileName(NULL, szEXEPath, 2048);
int j;
for (j = 0; szEXEPath[j] != 0; j++)
{
applicationPath[j] = szEXEPath[j];
}
applicationPath[j] = '\0';
Json::Value incident;
incident["appTitle"] = GetActiveWindowTitle();
incident["appPID"] = ::getpid();
incident["currentUser"] = getUserName();
incident["incidentTime"] = currentDateTime();
incident["actionTaken"] = 1;
incident["fileTried"] = filePath;
incident["appPath"] = applicationPath;
incident["ruleId"] = crValidator->getLastIncidentId();
ostringstream inc;
inc << incident;
string json = inc.str();
return json;
}
开发者ID:GuyGoldenberg,项目名称:EasyDLP,代码行数:29,代码来源:hook.cpp
示例12: Donkers
void CityGMLWriter::writeHeader(){
gml_ofstream << indent << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"<< std::endl;
gml_ofstream << indent << "<!-- CityGML Dataset produced with the IfCity-Converter developed by Sjors Donkers ([email protected]) -->"<< std::endl;
gml_ofstream << indent << "<!-- Created: "<<currentDateTime()<<" -->"<<std::endl;
gml_ofstream << indent++ << "<CityModel" << std::endl;
gml_ofstream << indent << "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << std::endl;
gml_ofstream << indent << "xmlns:xAL=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\"" << std::endl;
gml_ofstream << indent << "xmlns:app=\"http://www.opengis.net/citygml/appearance/2.0\"" << std::endl;
gml_ofstream << indent << "xmlns:xlink=\"http://www.w3.org/1999/xlink\"" << std::endl;
gml_ofstream << indent << "xmlns:gml=\"http://www.opengis.net/gml\"" << std::endl;
gml_ofstream << indent << "xmlns=\"http://www.opengis.net/citygml/2.0\"" << std::endl;
gml_ofstream << indent << "xmlns:bldg=\"http://www.opengis.net/citygml/building/2.0\"" << std::endl;
gml_ofstream << indent << "xsi:schemaLocation=\"http://www.opengis.net/citygml/2.0 http://schemas.opengis.net/citygml/2.0/cityGMLBase.xsd" << std::endl;
gml_ofstream << indent << "\thttp://www.opengis.net/citygml/appearance/2.0 http://schemas.opengis.net/citygml/appearance/2.0/appearance.xsd" << std::endl;
gml_ofstream << indent << "\thttp://www.opengis.net/citygml/building/2.0 http://schemas.opengis.net/citygml/building/2.0/building.xsd\">" << std::endl;
gml_ofstream << indent << "<gml:name>3D city model LOD3/4</gml:name>"<<std::endl;
// gml_ofstream << indent++ << "<gml:boundedBy>"<<std::endl;
// gml_ofstream << indent++ << "<gml:Envelope srsDimension=\"3\" srsName=\"urn:ogc:def:crs,crs:EPSG::25832,crs:EPSG::5783\">"<<std::endl;
// gml_ofstream << indent << "<gml:lowerCorner>-50 -50 -50</gml:lowerCorner>"<<std::endl;
// gml_ofstream << indent << "<gml:upperCorner>50 50 50</gml:upperCorner>"<<std::endl;
// gml_ofstream << --indent << "</gml:Envelope>"<<std::endl;
// gml_ofstream << --indent << "</gml:boundedBy>"<<std::endl;
}
开发者ID:ManderYao,项目名称:PrintX,代码行数:26,代码来源:WriteCityGML.cpp
示例13: insertOid
int insertOid(Oid oid)
{
sqlite3_stmt * stmt;
std::string time = currentDateTime();
int rc = sqlite3_prepare_v2(db, sql_insert.c_str(), -1, &stmt, NULL);
if (rc != SQLITE_OK)
{
sqlite3_finalize(stmt);
return rc;
}
// (\'device_id\', \'oid\', \'translate\', \'active\', \'created_at\', \'updated_at\')
rc |= sqlite3_bind_int(stmt, 1, oid.getDeviceId());
rc |= sqlite3_bind_text(stmt, 2, oid.getOid().c_str(), oid.getOid().length(), SQLITE_STATIC);
rc |= sqlite3_bind_text(stmt, 3, oid.getTranslate().c_str(), oid.getTranslate().length(), SQLITE_STATIC);
rc |= sqlite3_bind_int(stmt, 4, oid.getPingRequest());
rc |= sqlite3_bind_text(stmt, 5, oid.getActive() ? "t" : "f", 1, SQLITE_STATIC);
rc |= sqlite3_bind_text(stmt, 6, time.c_str(), time.length(), SQLITE_STATIC);
rc |= sqlite3_bind_text(stmt, 7, time.c_str(), time.length(), SQLITE_STATIC);
if (rc != SQLITE_OK)
{
sqlite3_finalize(stmt); // formatting problems and SQL
return rc;
}
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);
return rc;
}
开发者ID:Yashchuk,项目名称:diplom-1,代码行数:31,代码来源:oidORM.cpp
示例14: m_outcome
EntityEvent::EntityEvent(Outcome outcome, EventActionCode eventActionCode, CodedValueType eventId)
: m_outcome(outcome),
m_eventActionCode(eventActionCode),
m_eventId(std::move(eventId)),
m_eventDateTime(currentDateTime())
{
}
开发者ID:Blubbz0r,项目名称:AuditTrail,代码行数:7,代码来源:EntityEvent.cpp
示例15: if
Notebook::Notebook() {
pugi::xml_node note = XmlInterface::get()->GetDocument()->child("Configuration").child("Notebook");
file_name_ = std::string(note.attribute("file").as_string());
mode_ = std::string(note.attribute("mode").as_string("a"));
Messenger m;
m.detail("Notebook: " + file_name_ + " mode: " + mode_);
std::ofstream note_file;
if (mode_ == "r") {
note_file.open(file_name_.c_str(), std::ios::out);
} else if (mode_ == "a") {
note_file.open(file_name_.c_str(), std::ios::out | std::ios::app);
} else {
std::stringstream ss;
ss << "Notebook: unknown mode";
ss << " : " << mode_;
throw IOException(ss.str());
}
if (!note_file.good()) {
std::stringstream ss;
ss << "Notebook: error opening output file";
ss << " : " << file_name_;
throw IOException(ss.str());
}
note_file << "# Starting notebook on : " << currentDateTime() << std::endl;
note_file.close();
}
开发者ID:spaulaus,项目名称:paass,代码行数:31,代码来源:Notebook.cpp
示例16: printf
// Capture video and create data for report.
void frm::startWork(char * haarcascade_frontalface_alt, int cameraId, char * noderedApi, bool isShowVideo) {
try {
m_face_cascade = new cv::CascadeClassifier(haarcascade_frontalface_alt);
if (m_face_cascade->empty()) {
printf("Error on loading face cascade");
}
VideoCapture cameraRecord(cameraId); //0 is the id of video device.0 if you have only one camera.
if (!cameraRecord.isOpened()) { //check if video device has been initialised
cout << "cannot open camera cameraId=" << cameraId << endl;
exit(1);
}
// set up parameter :
cameraRecord.set(CV_CAP_PROP_FRAME_WIDTH, CAMERA_WIDTH); //set camera frame width and height
cameraRecord.set(CV_CAP_PROP_FRAME_HEIGHT, CAMERA_HEIGHT);
int waitInterval = 1000 / CAMERA_FPS;
while (!isRunning) {
// Create image from cropped area.
Mat imageCaptureFull;
cameraRecord.read(imageCaptureFull);
if (imageCaptureFull.empty())
break;
int winX = 0;
int winY = 0;
int winW = imageCaptureFull.cols;
int winH = imageCaptureFull.rows;
calculateCropROI(imageCaptureFull, winX, winY, winW, winH);
Mat imageCrop = imageCaptureFull(cv::Rect(winX, winY, winW, winH));
if (isShowVideo) {
imshow("camera", imageCrop); //show camera for verification
waitKey(waitInterval);
}
//Create report data
bool status = false;
checkEyesBlinkStatus(imageCrop, status);
if (status) {
cout << "1" << endl;
int pidId = fork();
if (pidId == 0) {
try {
execl("/usr/bin/curl", "curl", noderedApi, (char *) 0);
} catch (Exception e) {
}
}
} else {
cout << currentDateTime() << "\t0" << endl;
}
this_thread::sleep_for(chrono::milliseconds(waitInterval));
}
} catch (int e) {
printf("read file error\n");
}
}
开发者ID:fpt-software,项目名称:FPTDrivePlugins,代码行数:60,代码来源:frm.cpp
示例17: SetFiles
/**
* Function: Logger::currentDateTime()
* Description: Function that creates a datetime and returns it. Used for logging purposes, hence why it's here
*/
void Logger::SetFiles()
{
std::string formattedDatetime = EngineTextHandling::ReplaceCharsInString(currentDateTime(), ':', '_');
genericlogfile = "../Logs/Log " + formattedDatetime + ".txt";
errorlogfile = "../Logs/Error/Log " + formattedDatetime + ".txt";
succeslogfile = "../Logs/Success/Log " + formattedDatetime + ".txt";
warninglogfile = "../Logs/Warning/Log " + formattedDatetime + ".txt";
}
开发者ID:gamer145,项目名称:KB01,代码行数:12,代码来源:Logger.cpp
示例18: m_stream
inline LogMessage::LogMessage(const LoggerTypes& type, const std::string& file,
const int& i) : m_stream(), m_type(type)
{
//build the logstring
m_stream << "[" + LoggerTypeMap::get(type) + "][File:" + file + "][Line:" +
std::to_string(i) + "][thread:" << std::this_thread::get_id() <<
"]" + currentDateTime() + " ";
}
开发者ID:JIM-DB,项目名称:Server,代码行数:8,代码来源:logmessage.hpp
示例19: currentDateTime
void Log::debug(const std::string msg)
{
#ifdef DEBUG
std::cout << currentDateTime() << " [DEBUG]:\t" << msg << std::endl;
#else
(void) msg;
#endif
}
开发者ID:TheFlow0360,项目名称:Grundlagen_Cpp,代码行数:8,代码来源:log.cpp
示例20: currentDateTime
/**
* @brief updates the time
* Color and font settings can be configured in Qt CSS
*/
void LxQtClock::updateTime()
{
QDateTime now = currentDateTime();
if (now.time().msec() > 500)
restartTimer(now);
showTime(now);
}
开发者ID:MoonLightDE,项目名称:lxqt-panel,代码行数:13,代码来源:lxqtclock.cpp
注:本文中的currentDateTime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论