GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
glob-match.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <fnmatch.h>
28 
29 #include "glob-match.h"
30 #include "oct-glob.h"
31 
32 bool
33 glob_match::match (const std::string& str) const
34 {
35  return octave_fnmatch (pat, str, fnmatch_flags);
36 }
37 
39 glob_match::glob (void) const
40 {
41  return octave_glob (pat);
42 }
43 
44 int
45 glob_match::opts_to_fnmatch_flags (unsigned int xopts) const
46 {
47  int retval = 0;
48 
49  if (xopts & pathname)
50  retval |= FNM_PATHNAME;
51 
52  if (xopts & noescape)
53  retval |= FNM_NOESCAPE;
54 
55  if (xopts & period)
56  retval |= FNM_PERIOD;
57 
58  return retval;
59 }
string_vector octave_glob(const string_vector &pat)
Definition: oct-glob.cc:66
int opts_to_fnmatch_flags(unsigned int xopts) const
Definition: glob-match.cc:45
bool octave_fnmatch(const string_vector &pat, const std::string &str, int fnmatch_flags)
Definition: oct-glob.cc:51
bool match(const std::string &str) const
Definition: glob-match.cc:33
int fnmatch_flags
Definition: glob-match.h:96
string_vector pat
Definition: glob-match.h:93
string_vector glob(void) const
Definition: glob-match.cc:39