1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/*
** 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 1, 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.
*/
/*
* Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- March 1998
*/
/*
* ImportFilter.h : filter the imported files before importing
*/
#if !defined(AFX_IMPORTFILTER_H__98CCBD22_845B_11D1_8949_444553540000__INCLUDED_)
#define AFX_IMPORTFILTER_H__98CCBD22_845B_11D1_8949_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <vector>
#include "TextBinary.h"
#include "CPStr.h"
#include "FileTraversal.h"
#ifdef _MSC_VER
using namespace std;
#endif
// include a type (like *.c or ChangeLog) + several informations
// like : if several files of this type are conflicting (i.e. are
// binary AND text), if it is a binary or text type...
class ReportConflict
{
public:
ReportConflict(int mac_type, int mac_creator);
~ReportConflict();
ReportConflict *next;
enum
{
noConflict = 0x0000,
hasConflict = 0x0001,
hasExtension = 0x0002,
isBinary = 0x0004,
forceBinary = 0x0008,
forceText = 0x0010,
hasIgnore = 0x0020,
hasTypeCreatorConflict = 0x0040, /* mac only */
forceNoKeywords = 0x0080,
isUnicode = 0x0100,
forceUnicode = 0x0200,
userFlags = forceText | forceBinary | forceUnicode | hasIgnore | forceNoKeywords
};
void AddPattern(const char *newpat, kFileType fileType, bool isExtension, const char *sample);
void SetConflict(const char *sample);
void SetTypeCreatorConflict(const char *sample); /* mac only */
bool Match(const char *pat);
inline bool HasConflict(void) const
{
return (status & hasConflict) != 0;
}
inline bool HasTypeCreatorConflict(void) const /* mac only */
{
return (status & hasTypeCreatorConflict) != 0;
}
inline bool IsBinary(void) const
{
return (status & isBinary) != 0;
}
inline bool IsUnicode(void) const
{
return (status & isUnicode) != 0;
}
inline bool IsExtension(void) const
{
return (status & hasExtension) != 0;
}
inline const char *GetPattern(void) const
{
return pattern;
}
inline int GetMacType(void) const /* mac only */
{
return ftype;
}
inline int GetMacCreator(void) const /* mac only */
{
return fcreator;
}
inline void ForceBinary(void)
{
status &= ~(int)userFlags;
status |= (int)forceBinary;
}
inline void ForceText(void)
{
status &= ~(int)userFlags;
status |= (int)forceText;
}
inline void ForceUnicode(void)
{
status &= ~(int)userFlags;
status |= (int)forceUnicode;
}
inline void Ignore(void)
{
status &= ~(int)userFlags;
status |= (int)hasIgnore;
}
inline void ForceNoKeywords(void)
{
status &= ~(int)userFlags;
status |= (int)forceNoKeywords;
}
inline bool HasForceBinary(void) const
{
return (status & forceBinary) != 0;
}
inline bool HasForceText(void) const
{
return (status & forceText) != 0;
}
inline bool HasForceUnicode(void) const
{
return (status & forceUnicode) != 0;
}
inline bool HasIgnore(void) const
{
return (status & hasIgnore) != 0;
}
inline bool HasForceNoKeywords(void) const
{
return (status & forceNoKeywords) != 0;
}
inline void DisableUserSettings(void)
{
status &= ~(int)userFlags;
}
void PrintOut(CStr & out) const;
#if qCvsDebug
void PrintOut(void) const;
#endif /* qCvsDebug */
protected:
int status;
CStr pattern;
// an extension or a whole name (hasExtension)
CStr sample1;
// a sample for this entry
CStr sample2;
// another sample (if hasConflict)
int ftype, fcreator; /* mac only */
};
// a warning contains a kind of warning (i.e. wrong line feed,
// has escape characters...) + a set of files which illustrates
// this warning.
class ReportWarning
{
public:
ReportWarning(kTextBinTYPE akind);
~ReportWarning();
ReportWarning *next;
static const size_t maxWarnings;
void AddWarning(const char *sample);
inline kTextBinTYPE Kind(void) const {return kind;}
void PrintOut(CStr & out) const;
#if qCvsDebug
void PrintOut(void) const;
#endif /* qCvsDebug */
protected:
kTextBinTYPE kind;
std::vector<CStr> samples;
bool tooMuchWarnings;
};
kTraversal list_all_types_recur(const char *path, ReportWarning *& warnings,
ReportConflict *& conflicts);
void free_list_types(ReportWarning * warnings, ReportConflict * conflicts);
#if qCvsDebug
bool list_all_types(const char *path);
#endif /* qCvsDebug */
#endif // !defined(AFX_IMPORTFILTER_H__98CCBD22_845B_11D1_8949_444553540000__INCLUDED_)
|