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
|
#pragma once
/*
strmix.hpp
Куча разных вспомогательных функций по работе со строками
*/
/*
Copyright (c) 1996 Eugene Roshal
Copyright (c) 2000 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string>
#include <WinCompat.h>
#include "FARString.hpp"
enum
{
COLUMN_MARK = 0x80000000,
COLUMN_NAMEONLY = 0x40000000,
COLUMN_RIGHTALIGN = 0x20000000,
COLUMN_FORMATTED = 0x10000000,
COLUMN_COMMAS = 0x08000000,
COLUMN_THOUSAND = 0x04000000,
COLUMN_BRIEF = 0x02000000,
COLUMN_MONTH = 0x01000000,
COLUMN_FLOATSIZE = 0x00800000,
COLUMN_ECONOMIC = 0x00400000,
COLUMN_MINSIZEINDEX = 0x00200000,
COLUMN_SHOWBYTESINDEX = 0x00100000,
COLUMN_FULLOWNER = 0x00080000,
//MINSIZEINDEX может быть только 0, 1, 2 или 3 (K,M,G,T)
COLUMN_MINSIZEINDEX_MASK = 0x00000003,
};
std::string EscapeUnprintable(const std::string &str);
std::string UnescapeUnprintable(const std::string &str);
FARString &EscapeSpace(FARString &strStr);
wchar_t* WINAPI InsertQuote(wchar_t *Str);
FARString& InsertQuote(FARString& strStr);
void WINAPI Unquote(FARString &strStr);
void WINAPI Unquote(wchar_t *Str);
wchar_t * WINAPI InsertRegexpQuote(wchar_t *Str);
FARString& InsertRegexpQuote(FARString& strStr);
void UnquoteExternal(FARString &strStr);
wchar_t* WINAPI RemoveLeadingSpaces(wchar_t *Str);
FARString& WINAPI RemoveLeadingSpaces(FARString &strStr);
wchar_t *WINAPI RemoveTrailingSpaces(wchar_t *Str);
FARString& WINAPI RemoveTrailingSpaces(FARString &strStr);
wchar_t* WINAPI RemoveExternalSpaces(wchar_t *Str);
FARString & WINAPI RemoveExternalSpaces(FARString &strStr);
FARString & WINAPI RemoveUnprintableCharacters(FARString &strStr);
wchar_t* WINAPI QuoteSpaceOnly(wchar_t *Str);
FARString& WINAPI QuoteSpaceOnly(FARString &strStr);
FARString &RemoveChar(FARString &strStr,wchar_t Target,BOOL Dup=TRUE);
wchar_t *InsertString(wchar_t *Str,int Pos,const wchar_t *InsStr,int InsSize=0);
int ReplaceStrings(FARString &strStr,const wchar_t *FindStr,const wchar_t *ReplStr,int Count=-1,BOOL IgnoreCase=FALSE);
const wchar_t *GetCommaWord(const wchar_t *Src,FARString &strWord,wchar_t Separator=L',');
FARString& WINAPI FarFormatText(const wchar_t *SrcText, int Width, FARString &strDestText, const wchar_t* Break, DWORD Flags);
void PrepareUnitStr();
FARString& WINAPI FileSizeToStr(FARString &strDestStr, uint64_t Size, int Width=-1, int ViewFlags=COLUMN_COMMAS);
bool CheckFileSizeStringFormat(const wchar_t *FileSizeStr);
uint64_t ConvertFileSizeString(const wchar_t *FileSizeStr);
FARString &FormatNumber(const wchar_t *Src, FARString &strDest, int NumDigits=0);
FARString &InsertCommas(uint64_t li, FARString &strDest);
inline bool IsWordDiv(const wchar_t *WordDiv, wchar_t Chr)
{ return wcschr(WordDiv, Chr) != nullptr; }
inline bool IsWordDivSTNR(const wchar_t *WordDiv, wchar_t Chr)
{ return wcschr(WordDiv, Chr) != nullptr || wcschr(L" \t\n\r", Chr) != nullptr; }
// WordDiv - набор разделителей слова в кодировке OEM
// возвращает указатель на начало слова
const wchar_t * CalcWordFromString(const wchar_t *Str,int CurPos,int *Start,int *End,const wchar_t *WordDiv);
wchar_t* WINAPI TruncStr(wchar_t *Str,int MaxLength);
FARString& WINAPI TruncStr(FARString &strStr,int MaxLength);
wchar_t* WINAPI TruncStrFromEnd(wchar_t *Str,int MaxLength);
FARString& WINAPI TruncStrFromEnd(FARString &strStr, int MaxLength);
wchar_t* TruncStrFromCenter(wchar_t *Str, int MaxLength);
FARString& TruncStrFromCenter(FARString &strStr, int MaxLength);
wchar_t* WINAPI TruncPathStr(wchar_t *Str, int MaxLength);
FARString& WINAPI TruncPathStr(FARString &strStr, int MaxLength);
BOOL IsCaseMixed(const FARString &strStr);
BOOL IsCaseLower(const FARString &strStr);
FARString& CenterStr(const wchar_t *Src, FARString &strDest,int Length);
FARString FixedSizeStr(FARString str, size_t Length, bool RAlign);
void Transform(FARString &strBuffer,const wchar_t *ConvStr,wchar_t TransformType);
wchar_t GetDecimalSeparator();
FARString ReplaceBrackets(const FARString& SearchStr,const FARString& ReplaceStr,RegExpMatch* Match,int Count);
bool SearchString(const wchar_t *Source, int StrSize, const FARString& Str, FARString& ReplaceStr,int& CurPos, int Position,int Case,int WholeWords,int Reverse,int Regexp, int *SearchLength,const wchar_t* WordDiv=nullptr);
|