本文整理汇总了C++中Scan类的典型用法代码示例。如果您正苦于以下问题:C++ Scan类的具体用法?C++ Scan怎么用?C++ Scan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
//以文件方式输出结果
void Print::ToPrintIs_f(string sText_txt, string sResult_txt)
{
ifstream in;
ofstream out;
//打开文件
in.open(sText_txt.c_str(), ios::in);
out.open(sResult_txt.c_str(), ios::out);
while (!in.eof())
{
Scan scan;
Calculation calculate;
string sExperssion;
//从sText_txt路径获取数据
getline(in, sExperssion, '\n');
//拆分表达式
scan.ToStringQueue(sExperssion);
//计算表达式的值
calculate.ToCalculate(scan.q);
//在sResult_txt路径下输出结果
out << calculate.m_dResult << endl;
}
//关闭文件
in.close();
out.close();
}
示例2: PrintStringQueue
//--------1 输出表达式;
void Print::PrintStringQueue(string input)
{
/*创建Scan对象s*/
Scan s;
Calculate c;
/*获得Scan里所扫描的队列*/
queue<string> tmp = s.ToStringQueue(input);
//---- 除数为0或超出十位数输ERROR
if (s.IsError() == true )
{
cout << "ERROR" <<endl;
}
else
{
if (c.iserror() == false)
{
/*依次输出符合要求的元素*/
while ( !tmp.empty() )
{
cout << tmp.front() ;
tmp.pop();
}
cout << " " << c.Calculater(input);
}
else
{
cout << "ERROR" << endl;
}
}
}
示例3: Fileoperate
void File_Operate::Fileoperate()
{
Scan Sc;
Print Put;
Calculation Ca;
ifstream infile;
ofstream outfile;
//打开文件
infile.open(getsfile.c_str(),ios::in);
outfile.open(putsfile.c_str(),ios::out);
string get_str;
while(!infile.eof()) //未处理到文件尾
{
getline(infile,get_str); //读入数据
queue<string> que;
que = Sc.ToStringQueue(get_str);
double result=0;
result = Ca.carryout(que);
outfile << result << endl;
}
//关闭文件
infile.close();
outfile.close();
}
示例4: main
int main(int argc, char* argv[])
{
Scan in;
Calculation cal;
string input;
//将传入表达式赋给input
if(strcmp(argv[1], "-a") == 0)
{
cout << argv[2] << "= ";
input = argv[2];
}
else
{
input = argv[1];
}
//首先判断输入字符串中数字串长度不超过10位
if (!in.checkNumberLen(input))
{
return 0;
}
cal.getQueue(in.ToStringQueue(input));
return 0;
}
示例5: findBestFragmentScan
int ScanUtils::findBestFragmentScan(RawDataFile dataFile, boost::numeric::interval<double> rtRange, boost::numeric::interval<double> mzRange) {
int bestFragmentScan = -1;
double topBasePeak = 0;
std::vector<int> fragmentScanNumbers = dataFile.getScanNumbers(2, rtRange);
for (int number : fragmentScanNumbers) {
Scan scan = dataFile.getScan(number);
double lb = mzRange.lower, up = mzRange.upper, ppp = scan.getPrecursorMz;
if (lb < ppp && up > ppp)
{
//if (mzRange.lower() < scan.getPrecursorMz() && mzRange.upper() > scan.getPrecursorMz) {
DataPoint basePeak = scan.getHighestDataPoint();
// If there is no peak in the scan, basePeak can be null
if (DataPoint* v = dynamic_cast<DataPoint*>(&basePeak))
continue;
if (basePeak.getIntensity() > topBasePeak) {
bestFragmentScan = scan.getScanNumber();
topBasePeak = basePeak.getIntensity();
}
}
}
return bestFragmentScan;
}
示例6: main
int main(int argc, char* argv[])
{
bool flag = false;
stack <double>result;
string character;
queue<string>que_character;
Scan INPUT;
//Print OUTPUT;
Calculation CAL;
Calculation RES;
character = argv[1];
if(character == "-a")
{
character = argv[2];
flag = true;
}
if(flag)
{
cout << character << "=";
}
que_character = INPUT.ToStringQueue (character);
result = CAL.Separate (que_character);
RES.CoutResult(result);
//OUTPUT.print(que_character);
return 0;
}
示例7: while
//-------------------------------------------------------------------
// Sort::PassOneAndBeyond
//
// Input : Number of files generated by Pass 0
// Output : None
// Return : OK if Pass 1 and beyond succeed, FAIL otherwise
//-------------------------------------------------------------------
Status Sort::PassOneAndBeyond(int numFiles) {
passOneBeyondRuns = 0;
int numPass = 1, numStartFiles = passZeroRuns, numEndFiles;
do {
numEndFiles = 0;
if (OneMergePass(numStartFiles, numPass, numEndFiles) != OK ) return ReturnFAIL("OneMergePass failed.");
numStartFiles = numEndFiles;
numPass++;
} while (numEndFiles > 1);
// Write out
Status s;
RecordID rid; char *recPtr = (char *)malloc(_recLength); int recLen = _recLength;
char *fileName = CreateTempFilename(_outFile,numPass-1,passOneBeyondRuns);
HeapFile file(fileName,s); // read temp file
if (s != OK) return ReturnFAIL("Opening PassOneAndBeyond temp file failed.");
Scan *scan = file.OpenScan(s);
if (s != OK) return ReturnFAIL("Opening scan in PassOneAndBeyond failed.");
HeapFile output(_outFile, s);
if (s != OK) return ReturnFAIL("Opening output file in PassOneAndBeyond failed.");
while (scan->GetNext(rid,recPtr,recLen) == OK) {
output.InsertRecord(recPtr,recLen,rid);
}
delete fileName;
delete scan;
free(recPtr);
file.DeleteFile();
return OK;
}
示例8: CCMPASSERT
// Get the scan expression for given jbbc
// if jbbc is not a scan or predIdSet is NULL
// then the original JBBC expression is returned
RelExpr * AppliedStatMan::getExprForCANodeId(
CANodeId jbbc,
const EstLogPropSharedPtr &inLP,
const ValueIdSet * predIdSet)
{
RelExpr * jbbcExpr = NULL;
// should not happen but a check just in case
CCMPASSERT(jbbc.getNodeAnalysis());
//if specified by the user apply those predicates,
// else apply predicates in the original expr
NodeAnalysis * jbbcNode = jbbc.getNodeAnalysis();
TableAnalysis * tableAnalysis = jbbcNode->getTableAnalysis();
if (tableAnalysis && predIdSet)
{
TableDesc * tableDesc = tableAnalysis->getTableDesc();
const CorrName& name = tableDesc->getNATable()->getTableName();
Scan *scanExpr = new STMTHEAP Scan(name, tableDesc, REL_SCAN, STMTHEAP);
scanExpr->setBaseCardinality(MIN_ONE (tableDesc->getNATable()->getEstRowCount())) ;
GroupAttributes * gaExpr = new STMTHEAP GroupAttributes();
scanExpr->setSelectionPredicates(*predIdSet);
ValueIdSet requiredOutputs = jbbc.getNodeAnalysis()->\
getOriginalExpr()->getGroupAttr()->getCharacteristicOutputs();
gaExpr->setCharacteristicOutputs(requiredOutputs);
ValueIdSet requiredInputs = jbbc.getNodeAnalysis()->\
getOriginalExpr()->getGroupAttr()->getCharacteristicInputs();
gaExpr->setCharacteristicInputs(requiredInputs);
scanExpr->setGroupAttr(gaExpr);
gaExpr->setLogExprForSynthesis(scanExpr);
scanExpr->synthLogProp();
jbbcExpr = scanExpr;
}
else
{
NodeAnalysis * nodeAnalysis = jbbc.getNodeAnalysis();
RelExpr * relExpr = nodeAnalysis->getModifiedExpr();
if (relExpr == NULL)
relExpr = nodeAnalysis->getOriginalExpr();
jbbcExpr = relExpr;
}
return jbbcExpr;
} // getExprForCANodeId
示例9: BTreeFile
HeapFile *SortFile(HeapFile *S, int len, int offset)
{
Status s;
Scan *scan;
scan = S->OpenScan(s);
if (s != OK)
{
cerr << "ERROR : cannot open scan on the heapfile to sort.\n";
}
//
// Scan the HeapFile S, new a B+Tree and insert the records into B+Tree.
//
BTreeFile *btree;
btree = new BTreeFile (s, "BTree", ATTR_INT, sizeof(int));
char *recPtr = new char[len];
int recLen = len;
RecordID rid;
while (scan->GetNext(rid, recPtr, recLen) == OK)
{
btree->Insert(recPtr + offset, rid);
}
delete scan;
HeapFile *sorted;
sorted = new HeapFile(NULL, s); // create a temp HeapFile
if (s != OK)
{
cerr << "Cannot create new file for sortedS\n";
}
//
// Now scan the B+-Tree and insert the records into a
// new (sorted) HeapFile.
//
BTreeFileScan *btreeScan;
btreeScan = (BTreeFileScan *)btree->OpenScan(NULL, NULL);
int key;
while (btreeScan->GetNext(rid, &key) == OK)
{
S->GetRecord (rid, recPtr, recLen);
sorted->InsertRecord (recPtr, recLen, rid);
}
btree->DestroyFile();
delete btree;
delete btreeScan;
delete [] recPtr;
return sorted;
}
示例10: f
//*********************************************
//*** Test 5: Test some error conditions ***
bool HeapDriver::Test5()
{
cout << "\n Test 5: Test some error conditions\n";
Status status = OK;
Scan* scan = 0;
RecordID rid;
// Open the heap file
HeapFile f("file_1", status);
if (status != OK)
cerr << "*** Error opening heap file\n";
if ( status == OK )
{
cout << " - Try to change the size of a record\n";
scan = f.OpenScan(status);
if (status != OK)
cerr << "*** Error opening scan\n";
}
// Try to change the size of a record -- should fail
if ( status == OK )
{
int len;
Rec rec;
len = sizeof(rec);
status = scan->GetNext(rid, (char *)&rec, len);
if ( status != OK )
cerr << "*** Error reading first record\n";
else
{
status = f.UpdateRecord( rid, (char*)&rec, len-1 );
TestFailure( status, HEAPFILE, "Shortening a record" );
if ( status == OK )
{
status = f.UpdateRecord( rid, (char*)&rec, len+1 );
TestFailure( status, HEAPFILE, "Lengthening a record" );
}
}
}
delete scan;
// Try to insert a too long record -- should fail
if ( status == OK )
{
cout << " - Try to insert a record that's too long\n";
char record[MINIBASE_PAGESIZE] = "";
status = f.InsertRecord( record, MINIBASE_PAGESIZE, rid );
TestFailure( status, HEAPFILE, "Inserting a too-long record" );
}
if ( status == OK )
cout << " Test 5 completed successfully.\n";
return (status == OK);
}
示例11: Usedfile
//-----3 采用文件读取的方法
void Print::Usedfile(string input, string read, string ans)
{
Calculate c;
Scan ss;
//---- 3-1 文件声明及打开;
ifstream in;
ofstream out;
//调用.c_str()接受字符串作为文件名;
in.open (read.c_str(),ios::in );
out.open(ans.c_str() ,ios::out);
//----3-2 文件的读写;
while ( !in.eof() )
{
int flag1 = 0;
input.clear();
getline(in, input, '\n');
double answer = 0;
//---- 3-2-1 判断是否超出十位;
if (ss.IsError() == true)
{
flag1 = 1;
// out << "ERROR" << endl;
}
if (ss.IsError() == false)
{
answer = c.Calculater(input);
//---- 3-2-2 判断除数是否为0;
if (c.iserror() == true )
{
out << "ERROR" << endl;
}
else
{
//---- 3-2-3 输出答案;
if (flag1 == 1)
{
out << "ERROR" << endl;
flag1 = 0;
}
else
{
out << answer << endl;
}
}
}
}
//-----3-3 关闭文件;
in.close() ;
out.close();
}
示例12: binaryStream
void VdyneScanCloud::readBinary(std::istream& stream) {
BinaryStreamReader<std::istream> binaryStream(stream);
size_t numScans;
binaryStream >> mTimestamp >> mStartRotationAngle >> mEndRotationAngle
>> numScans;
for (size_t i = 0; i < numScans; ++i) {
Scan scan;
scan.readBinary(stream);
mScans.push_back(scan);
}
}
示例13: CreateTempFilename
Sort::Sort(
char *inFile, // Name of unsorted heapfile.
char *outFile, // Name of sorted heapfile.
int numFields, // Number of fields in input records.
AttrType fieldTypes[], // Array containing field types of input records.
// i.e. index of in[] ranges from 0 to (len_in - 1)
short fieldSizes[], // Array containing field sizes of input records.
int sortKeyIndex, // The number of the field to sort on.
// fld_no ranges from 0 to (len_in - 1).
TupleOrder sortOrder, // ASCENDING, DESCENDING
int numBufPages, // Number of buffer pages available for sorting.
Status &s)
{
// Initialize private instance variables
_recLength = 0;
for (int i=0;i<numFields;i++) {
_recLength += fieldSizes[i];
}
for (int i=0;i<sortKeyIndex;i++) {
_sortKeyOffset += fieldSizes[i];
}
_numBufPages = numBufPages;
_inFile = inFile;
_outFile = outFile;
_fieldSizes = fieldSizes;
_sortKeyIndex = sortKeyIndex;
_sortType = fieldTypes[_sortKeyIndex];
_sortOrder = sortOrder;
// Pass 0
int numTempFiles = 0;
if (PassZero(numTempFiles) != OK) { std::cerr << "PassZero failed." << std::endl; return; }
if (numTempFiles == 1) { // done, write out
RecordID rid; char *recPtr = (char *)malloc(_recLength); int recLen = _recLength;
char *fileName = CreateTempFilename(_outFile,0,0);
HeapFile passZeroFile(fileName,s); // read temp file
if (s != OK) { std::cerr << "Opening PassZero temp file failed." << std::endl; return; }
Scan *scan = passZeroFile.OpenScan(s);
if (s != OK) { std::cerr << "Opening scan in PassZero failed." << std::endl; return; }
HeapFile output(_outFile, s);
if (s != OK) { std::cerr << "Opening output file in PassZero failed." << std::endl; return; }
while (scan->GetNext(rid,recPtr,recLen) == OK) {
output.InsertRecord(recPtr,recLen,rid);
}
delete fileName;
delete scan;
free(recPtr);
passZeroFile.DeleteFile();
s = OK;
} else { // more passes
if (PassOneAndBeyond(numTempFiles) != OK) { std::cerr << "PassOneAndBeyond failed." << std::endl; return; }
s = OK;
}
}
示例14: main
int main() {
Scan ltest;
string s;
cout << "input the code file: ";
cin >> s;
ltest.srcfile = s;
ltest.outfile = "/Users/James/Open_Source/Debug/out.txt";
ltest.getToken();
Parse ptest(ltest.list_token, "/Users/James/Open_Source/Debug/asm.txt",
"/Users/James/Open_Source/Debug/main.txt");
ptest.test();
return 0;
}
示例15: main
int main(int argc, char* argv[])
{
string input;
Scan scan;
Paint print;
if (argc == 2)//无-a -f
{
input = argv[1];
scan.ToStringQueue(input);
print.Printqueue();
}
else if (argc == 3 )//第二个参数-a
{
input = argv[2];
cout << input << " ";
scan.ToStringQueue(input);
print.Printqueue();
}
else// -f的情况
{
fout.open(argv[3]);
flag = 4;
ifstream fin;
fin.open(argv[2]);
if (fin.is_open())
{
while (fin.good() && !fin.eof())//读取到文件尾停止读入
{
string message;//先将运算式存入message 再转存如input进行操作
fin >> message;
input = message;
ssss = argv[3];
scan.ToStringQueue(input);
print.Printqueue();
}
}
}
system("pause");
return 0;
}