📄 compare.cc
字号:
// -*- C++ -*-//// This file is part of Siena, a wide-area event notification system.// See http://www.cs.colorado.edu/serl/dot/siena.html//// Author: Antonio Carzaniga <carzanig@cs.colorado.edu>// See the file AUTHORS for full details. //// Copyright (C) 1998-1999 University of Colorado//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,// USA, or send email to serl@cs.colorado.edu.////// $Id: compare.cc,v 1.2 2002/11/22 20:57:46 carzanig Exp $//#include <siena.h>#include <iostream>#include <fstream>#include <exception>using namespace std;class Pub {public: Request r; Event e; bool operator == (const Pub &x) { return r == x.r && e == x.e; };};istream & operator >> (istream &is, Pub & p){ return is >> p.r >> p.e;};ostream & operator << (ostream &os, const Pub & p){ return os << p.r << p.e;};int main (int argc, char *argv[]){ Event e; Request r; iostream *s = NULL; list<Pub> outl; if (argc != 3) { cerr << "usage: " << argv[0] << " <output> <expected>" << endl; exit(-1); } ifstream output(argv[1]); if (!output) { cerr << "can't open file " << argv[1] << endl; exit(-1); } ifstream expected(argv[2]); if (!expected) { cerr << "can't open file " << argv[2] << endl; exit(-1); } int res = 0; try { Pub p; while(output >> p) { p.r.erase(SENP::Ttl); outl.push_back(p); } list<Pub>::iterator lpi; while(expected >> p) { bool found = false; for(lpi = outl.begin(); lpi != outl.end(); ++lpi) if (*lpi == p) { outl.erase(lpi); found = true; break; } if (!found) { if (res == 0) { res = 1; cout << ">>> MISSING >>>" << endl; } cout << p << endl; } } if (!outl.empty()) { res = 1; cout << "<<< EXTRA <<<" << endl; for(lpi = outl.begin(); lpi != outl.end(); ++lpi) cout << *lpi << endl; } } catch (exception &ex) { cerr << "error: " << ex.what() << endl; if (s != NULL) delete(s); // // yeah, whatever! // return -1; } return res;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -