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


C++ KData类代码示例

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


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

示例1: while

/*
 bool KDirectory::isDirEmpty( const KData& fullDir )
 {
 KData dtDir = fullDir;
 dtDir.makePath( true );
 DIR* dir;
 if ( (dir=opendir(dtDir.getData())) == NULL )
 return false;
 struct dirent *pDirent;
 while( ( pDirent = readdir(dir) ) != NULL  )
 {
 struct stat statbuf;
 KData dtPath = dtDir;
 dtPath += pDirent->d_name;
 if ( stat(dtPath.getData(),&statbuf) == -1 )
 continue;
 if ( S_ISDIR(statbuf.st_mode) )
 {
 if ( pDirent->d_name && strcmp(pDirent->d_name,".") && strcmp(pDirent->d_name,"..") )
 {
 if ( !isDirEmpty(dtPath) )
 {
 closedir( dir );
 return false;
 }
 }
 }
 else
 {
 closedir( dir );
 return false;
 }
 }
 closedir( dir );
 return true;

 }
 */
bool KDirectory::open(const KData& directory, bool create)
{
	if (directory.isEmpty())
	{
		return false;
	}

	KData dir = directory;
	int pos;
	KData dtKData = "\\";
	while ((pos = dir.find(dtKData)) != -1)
	{
		dir.replace(pos, 1, "/");
	}
	_directory.erase();

	bool bDirExist = isDirectoryExist(dir);
	if (!bDirExist)
	{
		if (create)
		{
			if (!createDir(dir))
				return false;
		}
		else
		{
			return false;
		}
	}
	_directory = dir;
	_directory.makePath();
	return true;
}
开发者ID:korman,项目名称:Temp,代码行数:71,代码来源:KDirectory.cpp

示例2: rename

bool KDirectory::rename(const KData& from, const KData& to)
{
	if (rename(from.getData(), to.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KDirectory.cpp

示例3: 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

示例4: Q_UNUSED

bool AnimalFeed::calculate(const KCalculationInfo& ci, const KLocation & loc, KDataArray * calcResult)
{
    Q_UNUSED(loc);
    Q_UNUSED(ci);

    qreal fp = userInputs()->numericValueOf(Srs19::AnnualPastureFraction);
    KData Cvi = _inpPorts.at(0)->data(Srs19::ConcentrationInVegetation);
    KData Cpi = _inpPorts.at(1)->data(Srs19::ConcentrationInStoredAnimalFeed);

    if (Cvi.isValid()) {
        for(int k = 0; k < Cvi.count(); k++) {
            const KDataItem & CviItem = Cvi.at(k);
            qreal vCvi = CviItem.numericValue();
            qreal vCpi = Cpi.numericValue(CviItem.name());

            qreal Cai = fp * vCvi + (1-fp)*vCpi;
            calcResult->appendOrMerge(&Srs19::ConcentrationInAnimalFeed,
                            CviItem.name(), Cai, KData::Radionuclide);
        }
    }
    else if (Cpi.isValid()) {
        for(int k = 0; k < Cpi.count(); k++) {
            const KDataItem & CpiItem = Cvi.at(k);
            qreal vCvi = Cvi.numericValue(CpiItem.name());
            qreal vCpi = CpiItem.numericValue();

            qreal Cai = fp * vCvi + (1-fp)*vCpi;
            calcResult->appendOrMerge(&Srs19::ConcentrationInAnimalFeed,
                            CpiItem.name(), Cai, KData::Radionuclide);
        }
    }

    return true;
}
开发者ID:ipsusila,项目名称:radenv,代码行数:34,代码来源:animalfeed.cpp

示例5: while

void KFile::replaceAll(KData& str)
{
	int pos;
	KData dtKData = "\\";
	while ((pos = str.find(dtKData)) != -1)
	{
		str.replace(pos, 1, "/");
	}
}
开发者ID:korman,项目名称:Temp,代码行数:9,代码来源:KFile.cpp

示例6: deleteFile

bool KFile::deleteFile(const KData& fullFilePath)
{
	if (remove(fullFilePath.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KFile.cpp

示例7: chDir

bool KDirectory::chDir(const KData& dir)
{
	if (chdir(dir.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KDirectory.cpp

示例8: fclose

bool KFile::setFile(KData fullFilePath, int mode)
{
	if (m_bIsOpen)
	{
		fclose (m_hFile);
		m_bIsOpen = false;
	}

#ifndef WIN32
	replaceAll(fullFilePath);
#endif

	if (fullFilePath.find("/") == -1)			//斜杠……
	{
		m_kFilePath = "./";
		m_kFileName = fullFilePath;
	}
	else
	{
		KData tStr = fullFilePath;
		if (tStr[tStr.length() - 1] == '/')
		{
			return false;
		}
		else
		{
			int pos = tStr.findlast("/");
			m_kFilePath = tStr.substr(0, pos + 1);
			m_kFileName = tStr.substr(pos + 1, tStr.length() - pos - 1);
		}
	}
	return open(mode);
}
开发者ID:korman,项目名称:Temp,代码行数:33,代码来源:KFile.cpp

示例9: Trim

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

示例10: setData

void DischargeItemTable::setData(const KData& d)
{
    if (d.isEmpty())
        return;

    //set row count
    this->setRowCount(d.count()+1);

    //setup data
    for(int k = 0; k < d.count(); k++) {
        const KDataItem &item = d.at(k);
        QTableWidgetItem * cell = new QTableWidgetItem(item.name());
        setItem(k, 0, cell);

        cell = new QTableWidgetItem(item.value().toString());
        setItem(k, 1, cell);
    }
}
开发者ID:ipsusila,项目名称:radenv,代码行数:18,代码来源:dischargeitemtable.cpp

示例11: isExcludeFile

bool KDirectory::isExcludeFile(const KData& file)
{
	for (vector<KData>::iterator iter = _vecExcludeFile.begin();
			iter != _vecExcludeFile.end(); iter++)
	{
		if (file.isEndWith(*iter, false))
			return true;
	}
	return false;
}
开发者ID:korman,项目名称:Temp,代码行数:10,代码来源:KDirectory.cpp

示例12: isDirectoryExist

bool KDirectory::isDirectoryExist(const KData& dir)
{
	struct stat statbuf;
	if (stat(dir.getData(), &statbuf) == -1)
		return false;
	if (S_ISDIR(statbuf.st_mode))
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:10,代码来源:KDirectory.cpp

示例13: CalulateAMA

double TechUtils::CalulateAMA(const std::vector<KData>& data, const KData& current, size_t mins){
	double totalExchangePrice = current.TurnOver();
	long long totalVolume = current.Volume();

	long long leftedge = current.Timestamp() - mins * 60 - 1;
	for (auto it = data.rbegin(); it != data.rend(); it++)
	{
		if (it->Timestamp() > leftedge){
			totalExchangePrice += it->TurnOver();
			totalVolume += it->Volume();
		}
		else{
			break;
		}
	}

	//assert(totalVolume != 0);
	//assert(totalExchangePrice >= 0.0);

	return totalExchangePrice / totalVolume;
}
开发者ID:AutoCoder,项目名称:AutoTrader,代码行数:21,代码来源:TechUtils.cpp

示例14: CalulateMA

double TechUtils::CalulateMA(const std::vector<KData>& data, const KData& current, size_t mins){
	//datetime to timestamp
	double totalExchangeLastPrice = current.LastPrice();
	long long count = 1;

	long long leftedge = current.Timestamp() - mins * 60 - 1;
	for (auto it = data.rbegin(); it != data.rend(); it++)
	{
		if (it->Timestamp() > leftedge){
			totalExchangeLastPrice += it->LastPrice();
			++count;
		}
		else{
			break;
		}
	}

	//assert(totalVolume != 0);
	//assert(totalExchangePrice >= 0.0);

	return totalExchangeLastPrice / count;
}
开发者ID:AutoCoder,项目名称:AutoTrader,代码行数:22,代码来源:TechUtils.cpp

示例15: getContext

void ConstantValue::_calculate(const Indicator& data) {
    double value = getParam<double>("value");
    int discard = getParam<int>("discard");

    size_t total = 0;
    if (isLeaf()) {
        //叶子节点
        KData k = getContext();
        if (k.getStock().isNull()) {
            _readyBuffer(1, 1);
            if (discard < 1) {
                m_discard = 0;
                _set(value, 0, 0);
            } else {
                m_discard = 1;
            }
            return;
        }

        total = k.size();
        if (0 == total) {
            return;
        }

        _readyBuffer(total, 1);
    
    } else {
        //非叶子节点
        total = data.size();
        discard = data.discard() > discard ? data.discard() : discard;
    }

    m_discard = discard > total ? total : discard;

    for (size_t i = m_discard; i < total; ++i) {
        _set(value, i, 0);
    }
}
开发者ID:fasiondog,项目名称:hikyuu,代码行数:38,代码来源:ConstantValue.cpp


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