match.hh revision 1031
15831Sgblack@eecs.umich.edu/* 25831Sgblack@eecs.umich.edu * Copyright (c) 2001-2004 The Regents of The University of Michigan 35831Sgblack@eecs.umich.edu * All rights reserved. 45831Sgblack@eecs.umich.edu * 55831Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65831Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75831Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85831Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95831Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105831Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115831Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125831Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135831Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145831Sgblack@eecs.umich.edu * this software without specific prior written permission. 155831Sgblack@eecs.umich.edu * 165831Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175831Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185831Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195831Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205831Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215831Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225831Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235831Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245831Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255831Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265831Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275831Sgblack@eecs.umich.edu */ 285831Sgblack@eecs.umich.edu 295831Sgblack@eecs.umich.edu/* @file 305831Sgblack@eecs.umich.edu * User Console Definitions 315831Sgblack@eecs.umich.edu */ 325831Sgblack@eecs.umich.edu 335831Sgblack@eecs.umich.edu#ifndef __BASE_MATCH_HH__ 345831Sgblack@eecs.umich.edu#define __BASE_MATCH_HH__ 355831Sgblack@eecs.umich.edu 365831Sgblack@eecs.umich.edu#include <string> 375831Sgblack@eecs.umich.edu#include <vector> 385831Sgblack@eecs.umich.edu 395831Sgblack@eecs.umich.educlass ObjectMatch 405831Sgblack@eecs.umich.edu{ 415831Sgblack@eecs.umich.edu protected: 425831Sgblack@eecs.umich.edu std::vector<std::vector<std::string> > tokens; 435831Sgblack@eecs.umich.edu bool domatch(const std::string &name) const; 445831Sgblack@eecs.umich.edu 455831Sgblack@eecs.umich.edu public: 465831Sgblack@eecs.umich.edu ObjectMatch(); 475831Sgblack@eecs.umich.edu ObjectMatch(const std::string &expression); 485831Sgblack@eecs.umich.edu void setExpression(const std::string &expression); 495831Sgblack@eecs.umich.edu void setExpression(const std::vector<std::string> &expression); 505831Sgblack@eecs.umich.edu bool match(const std::string &name) const 515831Sgblack@eecs.umich.edu { 525831Sgblack@eecs.umich.edu return tokens.empty() ? false : domatch(name); 535831Sgblack@eecs.umich.edu } 545831Sgblack@eecs.umich.edu}; 555831Sgblack@eecs.umich.edu 565831Sgblack@eecs.umich.edu#endif // __BASE_MATCH_HH__ 575831Sgblack@eecs.umich.edu 585831Sgblack@eecs.umich.edu