Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1996, 1997, 2000, 2005, 2006, 2007 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_glob_match_h) 00024 #define octave_glob_match_h 1 00025 00026 #include <string> 00027 00028 #include "Array.h" 00029 #include "str-vec.h" 00030 00031 class 00032 OCTAVE_API 00033 glob_match 00034 { 00035 public: 00036 00037 enum opts 00038 { 00039 pathname = 1, // No wildcard can ever match `/'. 00040 noescape = 2, // Backslashes don't quote special chars. 00041 period = 4 // Leading `.' is matched only explicitly. 00042 }; 00043 00044 glob_match (const std::string& p, 00045 unsigned int f = pathname|noescape|period) 00046 : pat (p), flags (f) { } 00047 00048 glob_match (const string_vector& p = string_vector (), 00049 unsigned int f = pathname|noescape|period) 00050 : pat (p), flags (f) { } 00051 00052 glob_match (const glob_match& gm) : pat (gm.pat), flags (gm.flags) { } 00053 00054 glob_match& operator = (const glob_match& gm) 00055 { 00056 if (this != &gm) 00057 { 00058 pat = gm.pat; 00059 flags = gm.flags; 00060 } 00061 return *this; 00062 } 00063 00064 ~glob_match (void) { } 00065 00066 void set_pattern (const std::string& p) { pat = p; } 00067 00068 void set_pattern (const string_vector& p) { pat = p; } 00069 00070 bool match (const std::string&); 00071 00072 Array<bool> match (const string_vector&); 00073 00074 string_vector glob (void); 00075 00076 private: 00077 00078 // Globbing pattern(s). 00079 string_vector pat; 00080 00081 // Option flags. 00082 unsigned int flags; 00083 }; 00084 00085 #endif 00086 00087 /* 00088 ;;; Local Variables: *** 00089 ;;; mode: C++ *** 00090 ;;; End: *** 00091 */