本文整理汇总了C++中DataFrame::setValid方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFrame::setValid方法的具体用法?C++ DataFrame::setValid怎么用?C++ DataFrame::setValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFrame
的用法示例。
在下文中一共展示了DataFrame::setValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromDevice
void DevReaderLinuxProc::readFromDevice(DataFrame& dataFrame)
{
if(m_deviceName.empty())
return;
ifstream fin("/proc/net/dev");
if(!fin.is_open())
return;
// skip the two header lines
string line;
getline(fin, line);
getline(fin, line);
if(!fin.good())
return;
// search for device
while(fin.good())
{
getline(fin, line);
if(line.empty())
continue;
string::size_type posEnd = line.find(':');
if(posEnd == string::npos)
continue;
string interfaceName = trim(line.substr(0, posEnd));
if(interfaceName.empty())
continue;
// check if it is the device we want
if(m_deviceName != interfaceName)
continue;
// read device data
unsigned long long bytesIn = 0;
unsigned long long packetsIn = 0;
unsigned long long errorsIn = 0;
unsigned long long dropsIn = 0;
unsigned long long bytesOut = 0;
unsigned long long packetsOut = 0;
unsigned long long errorsOut = 0;
unsigned long long dropsOut = 0;
unsigned long long dummy = 0;
istringstream sin(trim(line.substr(posEnd + 1)));
sin >> bytesIn
>> packetsIn
>> errorsIn
>> dropsIn
>> dummy
>> dummy
>> dummy
>> dummy
>> bytesOut
>> packetsOut
>> errorsOut
>> dropsOut;
if(sin.fail())
break;
dataFrame.setTotalDataIn(bytesIn);
dataFrame.setTotalDataOut(bytesOut);
dataFrame.setTotalPacketsIn(packetsIn);
dataFrame.setTotalPacketsOut(packetsOut);
dataFrame.setTotalErrorsIn(errorsIn);
dataFrame.setTotalErrorsOut(errorsOut);
dataFrame.setTotalDropsIn(dropsIn);
dataFrame.setTotalDropsOut(dropsOut);
dataFrame.setValid(true);
break;
}
}