当前位置: 首页>>代码示例>>C++>>正文


C++ KData::getDataBuf方法代码示例

本文整理汇总了C++中KData::getDataBuf方法的典型用法代码示例。如果您正苦于以下问题:C++ KData::getDataBuf方法的具体用法?C++ KData::getDataBuf怎么用?C++ KData::getDataBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KData的用法示例。


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

示例1: vCpLog

void vCpLog( int pri, const char* file, int line, const char* fmt, va_list ap )
{
    assert( pri >= 0 && pri <= LAST_PRIORITY );

    char datebuf[ DATEBUF_SIZE ];
	memset(datebuf, 0, DATEBUF_SIZE);
    int datebufCharsRemaining;

    struct timeval tv;
    struct timezone tz;
    int result = gettimeofday( &tv, &tz );
    
    if( result == -1 )
    {
	    datebuf [0] = '\0';
    }
    else
    {
		const time_t timeInSeconds = (time_t) tv.tv_sec;
		strftime( datebuf, DATEBUF_SIZE, "%m-%d %H:%M:%S", localtime ( &timeInSeconds ) );
    }
    char msbuf[10];

    sprintf( msbuf, ".%3.3d", (int)(tv.tv_usec/1000) );
    datebufCharsRemaining = DATEBUF_SIZE - strlen( datebuf );
    strncat( datebuf, msbuf, datebufCharsRemaining - 1 );
    datebuf[DATEBUF_SIZE - 1] = '\0';

	if( bConnServer )
	{
		char outBuff[2048];
		memset(outBuff, 0, 2048);
		KData ret = "[";
		ret = ret + KData(datebuf) + KData("]") + KData(priNameShort[pri]) + KData(" ");
		vsprintf( outBuff, fmt, ap );
		ret += outBuff;
		LogPack *pLogPack = (LogPack*)outBuff;
		pLogPack->lLogMsgSize = htonl( ret.length() ) ;
		strcpy( pLogPack->strLogMsg, ret.getDataBuf() );
		spClientSock->transmit( (char*)pLogPack, sizeof( long )+ret.length() );
	}

	if( mainLogFunc == NULL )
	{
		fprintf( cpLogFd, "[%s] %s: ", datebuf, priNameShort[pri] );
		vfprintf( cpLogFd, fmt, ap );
		fprintf( cpLogFd, "\n" );
		fflush( cpLogFd );
	}
	else
	{
		char outBuff[2048];
		memset(outBuff, 0, 2048);
		KData ret = "[";
		ret = ret + KData(datebuf) + "]" + priNameShort[pri] + "  ";
		vsprintf( outBuff, fmt, ap );
		ret += outBuff;
		mainLogFunc( ret, pri );
	}
}
开发者ID:chaosren,项目名称:HHHH,代码行数:60,代码来源:cpLog.cpp

示例2: getHttpFile

int KHttp::getHttpFile(const KData& fullUrl, const KData& savefile,
		int startpos)
{
	string strPath = fullUrl;
	Trim(strPath);
	KData dtServer;
	KData dtFile;
	KData kDTFullUrl = strPath;

	LOGD("kDTFullUrl is %s",kDTFullUrl.getDataBuf());

	if (isEqualNoCase(kDTFullUrl.substr(0, 7), "http://"))
	{
		kDTFullUrl = kDTFullUrl.substr(7);
	}

	int nPos = kDTFullUrl.find("/");

	if (nPos == -1)
	{
		LOGERROR("nPos = -1");
		return 0;
	}
	else
	{
		dtServer = kDTFullUrl.substr(0, nPos);
		dtFile = kDTFullUrl.substr(nPos);
	}
	return getHttpFile(dtServer, dtFile, savefile, startpos);
}
开发者ID:korman,项目名称:Temp,代码行数:30,代码来源:KHttp.cpp

示例3: write

int KFile::write(const KData& data)
{
	const char* pKData = data.getDataBuf();
	int len = data.length();
	int iWrited = 0;
	while (iWrited < len)
	{
		int iRet = write((unsigned char*) (pKData + iWrited), len - iWrited);
		if (iRet <= 0)
			break;
		iWrited += iRet;
	}
	return iWrited;
}
开发者ID:korman,项目名称:Temp,代码行数:14,代码来源:KFile.cpp


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