本文整理汇总了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;
}
示例2: rename
bool KDirectory::rename(const KData& from, const KData& to)
{
if (rename(from.getData(), to.getData()) == 0)
return true;
else
return false;
}
示例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 );
}
}
示例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;
}
示例5: while
void KFile::replaceAll(KData& str)
{
int pos;
KData dtKData = "\\";
while ((pos = str.find(dtKData)) != -1)
{
str.replace(pos, 1, "/");
}
}
示例6: deleteFile
bool KFile::deleteFile(const KData& fullFilePath)
{
if (remove(fullFilePath.getData()) == 0)
return true;
else
return false;
}
示例7: chDir
bool KDirectory::chDir(const KData& dir)
{
if (chdir(dir.getData()) == 0)
return true;
else
return false;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}