本文整理汇总了C++中CLStatus::isSuccess方法的典型用法代码示例。如果您正苦于以下问题:C++ CLStatus::isSuccess方法的具体用法?C++ CLStatus::isSuccess怎么用?C++ CLStatus::isSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLStatus
的用法示例。
在下文中一共展示了CLStatus::isSuccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeLog
CLStatus CLLogger::writeLog(const char *msg, long errorCode){
if(msg == 0)
return CLStatus(-1,0);
if(strlen(msg) == 0)
return CLStatus(-1,0);
if(fileFd == -1)
return CLStatus(-1,0);
//带缓冲区的日志类代码实现
unsigned int nLeftRoom = BUFFER_SIZE_LOG_FILE - usedByteForBuffer;
unsigned int lengthOfMsg = strlen(msg);
char buf[MAX_LINE];
snprintf(buf,MAX_LINE," Error code:%d\r\n",errorCode);
unsigned int lengthOfCode = strlen(buf);
unsigned int totalLen = lengthOfMsg + lengthOfCode;
if(totalLen > BUFFER_SIZE_LOG_FILE){
CLStatus s = flush();
if(!s.isSuccess())
return CLStatus(-1,0);
ssize_t r = write(fileFd,msg,lengthOfMsg);
if(r == -1)
return CLStatus(-1,errno);
r = write(fileFd,buf,lengthOfCode);
if(r == -1)
return CLStatus(-1,errno);
}
if(totalLen > nLeftRoom){
CLStatus s = flush();
if(!s.isSuccess())
return CLStatus(-1,0);
}
memcpy(logBuffer + usedByteForBuffer,msg,lengthOfMsg);
usedByteForBuffer += lengthOfMsg;
memcpy(logBuffer + usedByteForBuffer,buf,lengthOfCode);
usedByteForBuffer += lengthOfCode;
/*不带缓冲区的日志类代码实现。
* ssize_t n = write(fileFd,msg,strlen(msg));
if(n < 0)
return CLStatus(-1,errno);
char buf[MAX_LINE];
snprintf(buf,MAX_LINE," Error code:%d\r\n",errorCode);
n = write(fileFd, buf, strlen(buf));
if(n < 0){
return CLStatus(-1,errno);
}*/
return CLStatus(0,0);
}
示例2: writeLogMessage
CLStatus CLLogger::writeLogMessage(const char *msg, long errorCode){
CLLogger *log = CLLogger::getInstance();
if(log == 0)
return CLStatus(0,0);
CLStatus s = log->writeLog(msg,errorCode);
if(s.isSuccess())
return CLStatus(0,0);
else
return CLStatus(-1,0);
}