1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #define _tcswildcmp wcswildcmp
24 #define _tcswildcmp strwildcmp
29 * Performs a wild card compare of two strings.
30 * \param wild the wild card string
31 * \param string the string to compare the wild card to
32 * \return TRUE if the wild card matches the string, 0 otherwise
35 * if (strwildcmp("bl?hblah.*", "bliblah.jpeg"))
36 * printf("success\n");
38 * printf("not found\n");
39 * if (strwildcmp("bl?hblah.*", "blabblah.jpeg"))
40 * printf("success\n");
42 * printf("not found\n");
44 * The output of the above code would be:
50 int strwildcmp(const char * wild
, const char * string
);
51 int wcswildcmp(const wchar_t * wild
, const wchar_t * string
);
56 * string helper functions
62 static BOOL
WildCardMatch(const CString
& wildcard
, const CString
& string
);
63 static CString
LinesWrap(const CString
& longstring
, int limit
= 80, bool bCompactPaths
= false);
64 static CString
WordWrap(const CString
& longstring
, int limit
= 80, bool bCompactPaths
= false);
67 * Removes all '&' chars from a string.
69 static void RemoveAccelerators(CString
& text
);
72 * Writes an ASCII CString to the clipboard in CF_TEXT format
74 static bool WriteAsciiStringToClipboard(const CStringA
& sClipdata
, LCID lcid
, HWND hOwningWnd
= NULL
);
76 * Writes a String to the clipboard in both CF_UNICODETEXT and CF_TEXT format
78 static bool WriteAsciiStringToClipboard(const CStringW
& sClipdata
, HWND hOwningWnd
= NULL
);
81 * Writes an ASCII CString to the clipboard in TSVN_UNIFIEDDIFF format, which is basically the patch file
84 static bool WriteDiffToClipboard(const CStringA
& sClipdata
, HWND hOwningWnd
= NULL
);
87 * Reads the string \text from the file \path in utf8 encoding.
89 static bool ReadStringFromTextFile(const CString
& path
, CString
& text
);
93 * Writes the string \text to the file \path, either in utf16 or utf8 encoding,
94 * depending on the \c bUTF8 param.
96 static bool WriteStringToTextFile(const std::wstring
& path
, const std::wstring
& text
, bool bUTF8
= true);
99 * Compares strings while trying to parse numbers in it too.
100 * This function can be used to sort numerically.
101 * For example, strings would be sorted like this:
105 * If a normal text like comparison is used for sorting, the Version_10.0.2
106 * would not be the last in the above example.
108 static int CompareNumerical(LPCTSTR str1
, LPCTSTR str2
);