ardour
tape_file_matcher.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 Tim Mayberry
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 #include "pbd/error.h"
20 
22 
23 #include "i18n.h"
24 
25 using namespace std;
26 
27 namespace {
28 
29 const char* const tape_file_regex_string = X_("/T[0-9][0-9][0-9][0-9]-");
30 
31 }
32 
33 namespace ARDOUR {
34 
35 TapeFileMatcher::TapeFileMatcher()
36 {
37  int err;
38 
39  if ((err = regcomp (&m_compiled_pattern,
40  tape_file_regex_string, REG_EXTENDED|REG_NOSUB)))
41  {
42  char msg[256];
43 
44  regerror (err, &m_compiled_pattern, msg, sizeof (msg));
45 
46  PBD::error << string_compose (_("Cannot compile tape track regexp for use (%1)"), msg) << endmsg;
47  // throw
48  }
49 
50 }
51 
52 bool
53 TapeFileMatcher::matches (const string& audio_filename) const
54 {
55 
56  if (regexec (&m_compiled_pattern, audio_filename.c_str(), 0, 0, 0) == 0)
57  {
58  // matches
59  return true;
60  }
61  return false;
62 }
63 
64 } // namespace ARDOUR
Definition: Beats.hpp:239
LIBPBD_API Transmitter error
std::ostream & endmsg(std::ostream &ostr)
Definition: transmitter.h:71
#define _(Text)
Definition: i18n.h:11
#define X_(Text)
Definition: i18n.h:13
Definition: amp.h:29
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208