1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007, 2012, 2015 - 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.
25 * static helper methods for ResText.
32 static void StringExtend(LPTSTR str
);
33 static void StringCollapse(LPTSTR str
);
35 static void SearchReplace(std::wstring
& str
, const std::wstring
& toreplace
, const std::wstring
& replacewith
);
40 inline std::string
<rim(std::string
&s
)
42 s
.erase(s
.cbegin(), std::find_if(s
.cbegin(), s
.cend(), [](const auto& c
) { return !iswspace(c
); }));
47 inline std::string
&rtrim(std::string
&s
)
49 s
.erase(std::find_if(s
.crbegin(), s
.crend(), [](const auto& c
) { return !iswspace(c
); }).base(), s
.cend());
53 // trim from both ends
54 inline std::string
&trim(std::string
&s
)
56 return ltrim(rtrim(s
));
60 inline std::wstring
<rim(std::wstring
&s
)
62 s
.erase(s
.cbegin(), std::find_if(s
.cbegin(), s
.cend(), [](const auto& c
) { return !iswspace(c
); }));
67 inline std::wstring
&rtrim(std::wstring
&s
)
69 s
.erase(std::find_if(s
.crbegin(), s
.crend(), [](const auto& c
) { return !iswspace(c
); }).base(), s
.cend());
73 // trim from both ends
74 inline std::wstring
&trim(std::wstring
&s
)
76 return ltrim(rtrim(s
));