Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
65be3e81
Commit
65be3e81
authored
Jun 18, 2011
by
Davis King
Browse files
Added match_endings to the dir_nav utils.
parent
9db07ff3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
dlib/dir_nav/dir_nav_extensions.h
dlib/dir_nav/dir_nav_extensions.h
+35
-0
dlib/dir_nav/dir_nav_extensions_abstract.h
dlib/dir_nav/dir_nav_extensions_abstract.h
+37
-0
No files found.
dlib/dir_nav/dir_nav_extensions.h
View file @
65be3e81
...
...
@@ -8,6 +8,7 @@
#include <algorithm>
#include "dir_nav_extensions_abstract.h"
#include "../dir_nav.h"
#include "../string.h"
namespace
dlib
{
...
...
@@ -83,6 +84,40 @@ namespace dlib
std
::
string
ending
;
};
// ----------------------------------------------------------------------------------------
class
match_endings
{
public:
match_endings
(
const
std
::
string
&
endings_
)
{
const
std
::
vector
<
std
::
string
>&
s
=
split
(
endings_
);
for
(
unsigned
long
i
=
0
;
i
<
s
.
size
();
++
i
)
{
endings
.
push_back
(
match_ending
(
s
[
i
]));
}
}
bool
operator
()
(
const
file
&
f
)
const
{
for
(
unsigned
long
i
=
0
;
i
<
endings
.
size
();
++
i
)
{
if
(
endings
[
i
](
f
))
return
true
;
}
return
false
;
}
private:
std
::
vector
<
match_ending
>
endings
;
};
// ----------------------------------------------------------------------------------------
class
match_all
...
...
dlib/dir_nav/dir_nav_extensions_abstract.h
View file @
65be3e81
...
...
@@ -68,6 +68,43 @@ namespace dlib
!*/
};
// ----------------------------------------------------------------------------------------
class
match_endings
{
/*!
WHAT THIS OBJECT REPRESENTS
This is a simple function object that can be used with the
above get_files_in_directory_tree() function. This object
allows you to look for files with a number of different
endings.
!*/
public:
match_endings
(
const
std
::
string
&
ending_list
);
/*!
ensures
- ending_list is interpreted as a whitespace separated list
of file endings.
- this object will be a function that checks if a file has a
name that ends with one of the strings in ending_list.
!*/
bool
operator
()
(
const
file
&
f
)
const
;
/*!
ensures
- if (the file f has a name that ends with one of the ending strings
given to this object's constructor) then
- returns true
- else
- returns false
!*/
};
// ----------------------------------------------------------------------------------------
class
match_all
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment