aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/FileManager/StringUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/FileManager/StringUtils.cpp')
-rw-r--r--CPP/7zip/UI/FileManager/StringUtils.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/CPP/7zip/UI/FileManager/StringUtils.cpp b/CPP/7zip/UI/FileManager/StringUtils.cpp
new file mode 100644
index 0000000..0478399
--- /dev/null
+++ b/CPP/7zip/UI/FileManager/StringUtils.cpp
@@ -0,0 +1,65 @@
1// StringUtils.cpp
2
3#include "StdAfx.h"
4
5#include "StringUtils.h"
6
7void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
8{
9 dest1.Empty();
10 dest2.Empty();
11 bool quoteMode = false;
12 for (unsigned i = 0; i < src.Len(); i++)
13 {
14 const wchar_t c = src[i];
15 if (c == '\"')
16 quoteMode = !quoteMode;
17 else if (c == ' ' && !quoteMode)
18 {
19 dest2 = src.Ptr(i + 1);
20 return;
21 }
22 else
23 dest1 += c;
24 }
25}
26
27void SplitString(const UString &srcString, UStringVector &destStrings)
28{
29 destStrings.Clear();
30 unsigned len = srcString.Len();
31 if (len == 0)
32 return;
33 UString s;
34 for (unsigned i = 0; i < len; i++)
35 {
36 wchar_t c = srcString[i];
37 if (c == ' ')
38 {
39 if (!s.IsEmpty())
40 {
41 destStrings.Add(s);
42 s.Empty();
43 }
44 }
45 else
46 s += c;
47 }
48 if (!s.IsEmpty())
49 destStrings.Add(s);
50}
51
52/*
53UString JoinStrings(const UStringVector &srcStrings)
54{
55
56 UString s;
57 FOR_VECTOR (i, srcStrings)
58 {
59 if (i != 0)
60 s.Add_Space();
61 s += srcStrings[i];
62 }
63 return s;
64}
65*/