OSDN Git Service

Move FileFilter and FileFilterElement definitions to own file.
authorKimmo Varis <kimmov@gmail.com>
Thu, 25 Jun 2009 09:54:27 +0000 (09:54 +0000)
committerKimmo Varis <kimmov@gmail.com>
Thu, 25 Jun 2009 09:54:27 +0000 (09:54 +0000)
Src/FileFilter.cpp [new file with mode: 0644]
Src/FileFilter.h [new file with mode: 0644]
Src/FileFilterMgr.cpp
Src/FileFilterMgr.h
Src/Merge.vcproj
Src/Plugins.cpp

diff --git a/Src/FileFilter.cpp b/Src/FileFilter.cpp
new file mode 100644 (file)
index 0000000..f4a0ae8
--- /dev/null
@@ -0,0 +1,54 @@
+/////////////////////////////////////////////////////////////////////////////
+//    License (GPLv2+):
+//    This program is free software; you can redistribute it and/or modify it
+//    under the terms of the GNU General Public License as published by the
+//    Free Software Foundation; either version 2 of the License, or (at your
+//    option) any later version.
+//    This program is distributed in the hope that it will be useful, but
+//    WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    General Public License for more details.
+//    You should have received a copy of the GNU General Public License
+//    along with this program; if not, write to the Free Software
+//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/////////////////////////////////////////////////////////////////////////////
+/**
+ *  @file FileFilter.cpp
+ *
+ *  @brief Implementation of FileFilter.
+ */ 
+// ID line follows -- this is updated by SVN
+// $Id$
+
+#include "stdafx.h"
+#include <vector>
+#include "pcre.h"
+#include "FileFilter.h"
+
+using std::vector;
+
+/**
+ * @brief Destructor, frees created filter lists.
+ */
+FileFilter::~FileFilter()
+{
+       EmptyFilterList(&filefilters);
+       EmptyFilterList(&dirfilters);
+}
+
+/**
+ * @brief Deletes items from filter list.
+ *
+ * @param [in] filterList List to empty.
+ */
+void FileFilter::EmptyFilterList(vector<FileFilterElement*> *filterList)
+{
+       while (!filterList->empty())
+       {
+               FileFilterElement *elem = filterList->back();
+               pcre_free(elem->pRegExp);
+               pcre_free(elem->pRegExpExtra);
+               delete elem;
+               filterList->pop_back();
+       }
+}
\ No newline at end of file
diff --git a/Src/FileFilter.h b/Src/FileFilter.h
new file mode 100644 (file)
index 0000000..bee87de
--- /dev/null
@@ -0,0 +1,68 @@
+/////////////////////////////////////////////////////////////////////////////
+//    License (GPLv2+):
+//    This program is free software; you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation; either version 2 of the License, or
+//    (at your option) any later version.
+//
+//    This program is distributed in the hope that it will be useful, but
+//    WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    General Public License for more details.
+//
+//    You should have received a copy of the GNU General Public License
+//    along with this program; if not, write to the Free Software
+//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/////////////////////////////////////////////////////////////////////////////
+/** 
+ * @file  FileFilter.h
+ *
+ * @brief Declaration file for FileFilter
+ */
+// ID line follows -- this is updated by SVN
+// $Id$
+
+#include <vector>
+#include "pcre.h"
+
+/**
+ * @brief FileFilter rule.
+ *
+ * Contains one filtering element definition (rule). In addition to
+ * regular expression there is boolean value for defining if rule
+ * is inclusive or exclusive. File filters have global inclusive/exclusive
+ * selection but this per-rule setting overwrites it.
+ *
+ * We are using PCRE for regular expressions and pRegExp points to compiled
+ * regular expression. pRegExpExtra contains additional information about
+ * the expression used to optimize matching.
+ */
+struct FileFilterElement
+{
+       pcre *pRegExp; /**< Compiled regular expression */
+       pcre_extra *pRegExpExtra; /**< Additional information got from regex study */
+       FileFilterElement() : pRegExp(NULL), pRegExpExtra(NULL) { };
+};
+
+/**
+ * @brief One actual filter.
+ *
+ * For example, this might be a GNU C filter, excluding *.o files and CVS
+ * directories. That is to say, a filter is a set of file masks and
+ * directory masks. Usually FileFilter contains rules from one filter
+ * definition file. So it can be thought as filter file contents.
+ * @sa FileFilterList
+ */
+struct FileFilter
+{
+       bool default_include;   /**< If true, filter rules are inclusive by default */
+       CString name;                   /**< Filter name (shown in UI) */
+       CString description;    /**< Filter description text */
+       CString fullpath;               /**< Full path to filter file */
+       std::vector<FileFilterElement*> filefilters; /**< List of rules for files */
+       std::vector<FileFilterElement*> dirfilters;  /**< List of rules for directories */
+       FileFilter() : default_include(true) { }
+       ~FileFilter();
+       
+       static void EmptyFilterList(std::vector<FileFilterElement*> *filterList);
+};
index 7f9b51d..a950ebb 100644 (file)
@@ -1,7 +1,4 @@
 /////////////////////////////////////////////////////////////////////////////
-// FileFilterMgr.cpp : implementation file
-// see FileFilterMgr.h for description
-/////////////////////////////////////////////////////////////////////////////
 //    License (GPLv2+):
 //    This program is free software; you can redistribute it and/or modify it
 //    under the terms of the GNU General Public License as published by the
@@ -27,6 +24,7 @@
 #include <string.h>
 #include <vector>
 #include "UnicodeString.h"
+#include "FileFilter.h"
 #include "pcre.h"
 #include "FileFilterMgr.h"
 #include "UniFile.h"
@@ -42,53 +40,6 @@ static char THIS_FILE[] = __FILE__;
 using std::vector;
 
 /**
- * @brief Deletes items from filter list.
- *
- * @param [in] filterList List to empty.
- */
-void EmptyFilterList(vector<FileFilterElement*> *filterList)
-{
-       while (!filterList->empty())
-       {
-               FileFilterElement *elem = filterList->back();
-               pcre_free(elem->pRegExp);
-               pcre_free(elem->pRegExpExtra);
-               delete elem;
-               filterList->pop_back();
-       }
-}
-
-/**
- * @brief One actual filter.
- *
- * For example, this might be a GNU C filter, excluding *.o files and CVS
- * directories. That is to say, a filter is a set of file masks and
- * directory masks. Usually FileFilter contains rules from one filter
- * definition file. So it can be thought as filter file contents.
- * @sa FileFilterList
- */
-struct FileFilter
-{
-       bool default_include;   /**< If true, filter rules are inclusive by default */
-       CString name;                   /**< Filter name (shown in UI) */
-       CString description;    /**< Filter description text */
-       CString fullpath;               /**< Full path to filter file */
-       vector<FileFilterElement*> filefilters; /**< List of rules for files */
-       vector<FileFilterElement*> dirfilters;  /**< List of rules for directories */
-       FileFilter() : default_include(true) { }
-       ~FileFilter();
-};
-
-/**
- * @brief Destructor, frees created filter lists.
- */
-FileFilter::~FileFilter()
-{
-       EmptyFilterList(&filefilters);
-       EmptyFilterList(&dirfilters);
-}
-
-/**
  * @brief Destructor, frees all filters.
  */
 FileFilterMgr::~FileFilterMgr()
index 4cc78e3..179d40d 100644 (file)
@@ -29,6 +29,7 @@
 #include "pcre.h"
 
 struct FileFilterElement;
+struct FileFilter;
 
 /**
  * @brief Return values for many filter functions.
@@ -41,27 +42,6 @@ enum FILTER_RETVALUE
 };
 
 /**
- * @brief FileFilter rule.
- *
- * Contains one filtering element definition (rule). In addition to
- * regular expression there is boolean value for defining if rule
- * is inclusive or exclusive. File filters have global inclusive/exclusive
- * selection but this per-rule setting overwrites it.
- *
- * We are using PCRE for regular expressions and pRegExp points to compiled
- * regular expression. pRegExpExtra contains additional information about
- * the expression used to optimize matching.
- */
-struct FileFilterElement
-{
-       pcre *pRegExp; /**< Compiled regular expression */
-       pcre_extra *pRegExpExtra; /**< Additional information got from regex study */
-       FileFilterElement() : pRegExp(NULL), pRegExpExtra(NULL) { };
-};
-
-struct FileFilter;
-
-/**
  * @brief File filter manager for handling filefilters.
  *
  * The FileFilterMgr loads a collection of named file filters from disk,
index 0c227f2..1a09546 100644 (file)
                                </FileConfiguration>
                        </File>
                        <File
+                               RelativePath="FileFilter.cpp">
+                               <FileConfiguration
+                                       Name="UnicodeRelease|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="1"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""/>
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="UnicodeDebug|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="0"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               BrowseInformation="1"/>
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="0"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               BrowseInformation="1"/>
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32">
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="1"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""/>
+                               </FileConfiguration>
+                       </File>
+                       <File
                                RelativePath="FileFilterHelper.cpp">
                                <FileConfiguration
                                        Name="UnicodeRelease|Win32">
                                RelativePath="FileActionScript.h">
                        </File>
                        <File
+                               RelativePath="FileFilter.h">
+                       </File>
+                       <File
                                RelativePath="FileFilterHelper.h">
                        </File>
                        <File
index b80cd53..aa19003 100644 (file)
@@ -43,6 +43,7 @@
 #include "Exceptions.h"
 #include "RegKey.h"
 #include "paths.h"
+#include "FileFilter.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -697,7 +698,7 @@ static void FreeAllScripts(PluginArray *& pArray)
        {
                pArray->GetAt(i).m_lpDispatch->Release();
                if (pArray->GetAt(i).m_filters)
-                       EmptyFilterList(pArray->GetAt(i).m_filters);
+                       FileFilter::EmptyFilterList(pArray->GetAt(i).m_filters);
                delete pArray->GetAt(i).m_filters;
        }