Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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,
00040 noescape = 2,
00041 period = 4
00042 };
00043
00044 glob_match (const std::string& p,
00045 unsigned int xopts = pathname|noescape|period)
00046 : pat (p), fnmatch_flags (opts_to_fnmatch_flags (xopts)) { }
00047
00048 glob_match (const string_vector& p = string_vector (),
00049 unsigned int xopts = pathname|noescape|period)
00050 : pat (p), fnmatch_flags (opts_to_fnmatch_flags (xopts)) { }
00051
00052 glob_match (const glob_match& gm)
00053 : pat (gm.pat), fnmatch_flags (gm.fnmatch_flags) { }
00054
00055 glob_match& operator = (const glob_match& gm)
00056 {
00057 if (this != &gm)
00058 {
00059 pat = gm.pat;
00060 fnmatch_flags = gm.fnmatch_flags;
00061 }
00062 return *this;
00063 }
00064
00065 ~glob_match (void) { }
00066
00067 void set_pattern (const std::string& p) { pat = p; }
00068
00069 void set_pattern (const string_vector& p) { pat = p; }
00070
00071 bool match (const std::string& str) const;
00072
00073 Array<bool> match (const string_vector& str) const
00074 {
00075 int n = str.length ();
00076
00077 Array<bool> retval (dim_vector (n, 1));
00078
00079 for (int i = 0; i < n; i++)
00080 retval(i) = match (str[i]);
00081
00082 return retval;
00083 }
00084
00085
00086
00087
00088 string_vector glob (void) const;
00089
00090 private:
00091
00092
00093 string_vector pat;
00094
00095
00096 int fnmatch_flags;
00097
00098 int opts_to_fnmatch_flags (unsigned int xopts) const;
00099 };
00100
00101 #endif