2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
25 * @file ProGeScriptGenerator.icc
27 * Implementation of ProGeScriptGenerator class template part.
29 * @author Esa Määttä 2007 (esa.maatta-no.spam-tut.fi)
33 #include "CompilerWarnings.hh"
34 IGNORE_CLANG_WARNING("-Wkeyword-macro")
35 #include <boost/regex.hpp>
38 #include "FileSystem.hh"
41 * Finds regex matching strings from a container.
43 * Finds std::string entries from containers that match given regex.
44 * Case is ignored when matching.
46 * @param perlre Perl syntax regex.
47 * @param files Container for strings to match against.
48 * @param found Strings that matched are appended to this list.
51 void ProGeScriptGenerator::findFiles(
52 const std::string& perlre,
54 std::list<std::string>& found) {
56 static const boost::regex re(perlre,
57 boost::regex::perl|boost::regex::icase);
59 typename T::const_iterator iter = files.begin();
60 while (iter != files.end()) {
61 if (regex_match(*iter, re)) {
62 found.push_back(*iter);
69 * Removes regex matching strings from a container.
71 * Finds std::string entries from containers that don't match given regex.
72 * Case is ignored when matching. Strings that do not match are removed from
75 * @param perlre Perl syntax regex.
76 * @param files Container of strings.
79 void ProGeScriptGenerator::findFiles(
80 const std::string& perlre,
83 static const boost::regex re(perlre,
84 boost::regex::perl|boost::regex::icase);
86 typename T::iterator iter = files.begin();
87 while (iter != files.end()) {
88 if (!regex_match(*iter, re)) {
89 iter = files.erase(iter);
97 * Removes duplicate filenames considering their path from a container.
99 * @param files Container holding the filenames.
100 * @param rootDirectory Base directory for relative paths in files container.
102 template <typename CONT>
103 void ProGeScriptGenerator::uniqueFileNames(
105 const std::string& rootDirectory) {
107 typename CONT::iterator ito = files.begin();
108 typename CONT::iterator iti;
109 while (ito != files.end()) {
111 while (iti != files.end()) {
113 FileSystem::compareFileNames(*ito, *iti, rootDirectory)) {
114 iti = files.erase(iti);