covers.cc

来自「发布/订阅系统中间件」· CC 代码 · 共 85 行

CC
85
字号
// -*- 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: covers.cc,v 1.2 2002/11/22 20:57:46 carzanig Exp $//#include <siena.h>#include <string>#include <iostream>#include <sstream>#include <exception>using namespace std;#include "CoveringRelations.h"void print_usage(const char *programname) {    cerr << "Usage: " << programname << " [options...]\n\options:\n\t-f filters\n\t-o\n" << endl;    exit(-1);}int main (int argc, char *argv[]){    bool quiet = true;    Filter f1, f2;    istream * is = &cin;    for (int i=1; i< argc; i++) {		// parses command-line parameters	if (strcmp(argv[i], "-f")==0) {	    if (++i < argc) {		is = new istringstream(argv[i]);	    } else {		print_usage(argv[0]);	    }	} else if (strcmp(argv[i], "-o")==0) {	    quiet = false;	} else {	    print_usage(argv[0]);	}    }    try {	*is >> f1 >> f2;	if (is != &cin) delete(is);	if (covers(f1, f2)) {	    if (!quiet)		cout << "yes" << endl;	    return 0;	} else {	    if (!quiet)		cout << "no" << endl;	    return 1;	}	return 0;    } catch (exception &ex) {	cerr << "error: " << ex.what() << endl;	return 2;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?