unrarsrc  6.1.7
About: unrar extracts, views and tests the contents of archives created with the RAR archiver.
  Fossies Dox: unrarsrc-6.1.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

strlist.cpp
Go to the documentation of this file.
1#include "rar.hpp"
2
4{
5 Reset();
6}
7
8
10{
11 Rewind();
15}
16
17
18void StringList::AddStringA(const char *Str)
19{
20 Array<wchar> StrW(strlen(Str));
21 CharToWide(Str,&StrW[0],StrW.Size());
22 AddString(&StrW[0]);
23}
24
25
27{
28 if (Str==NULL)
29 Str=L"";
30
31 size_t PrevSize=StringData.Size();
32 StringData.Add(wcslen(Str)+1);
33 wcscpy(&StringData[PrevSize],Str);
34
36}
37
38
39bool StringList::GetStringA(char *Str,size_t MaxLength)
40{
41 Array<wchar> StrW(MaxLength);
42 if (!GetString(&StrW[0],StrW.Size()))
43 return false;
44 WideToChar(&StrW[0],Str,MaxLength);
45 return true;
46}
47
48
49bool StringList::GetString(wchar *Str,size_t MaxLength)
50{
51 wchar *StrPtr;
52 if (!GetString(&StrPtr))
53 return false;
54 wcsncpyz(Str,StrPtr,MaxLength);
55 return true;
56}
57
58
59#ifndef SFX_MODULE
60bool StringList::GetString(wchar *Str,size_t MaxLength,int StringNum)
61{
63 Rewind();
64 bool RetCode=true;
65 while (StringNum-- >=0)
66 if (!GetString(Str,MaxLength))
67 {
68 RetCode=false;
69 break;
70 }
72 return RetCode;
73}
74#endif
75
76
78{
79 wchar *Str;
80 GetString(&Str);
81 return Str;
82}
83
84
86{
87 if (CurPos>=StringData.Size()) // No more strings left unprocessed.
88 {
89 if (Str!=NULL)
90 *Str=NULL;
91 return false;
92 }
93
94 wchar *CurStr=&StringData[CurPos];
95 CurPos+=wcslen(CurStr)+1;
96 if (Str!=NULL)
97 *Str=CurStr;
98
99 return true;
100}
101
102
104{
105 CurPos=0;
106}
107
108
109#ifndef SFX_MODULE
110bool StringList::Search(const wchar *Str,bool CaseSensitive)
111{
112 SavePosition();
113 Rewind();
114 bool Found=false;
115 wchar *CurStr;
116 while (GetString(&CurStr))
117 {
118 if (Str!=NULL && CurStr!=NULL)
119 if ((CaseSensitive ? wcscmp(Str,CurStr):wcsicomp(Str,CurStr))!=0)
120 continue;
121 Found=true;
122 break;
123 }
125 return Found;
126}
127#endif
128
129
130#ifndef SFX_MODULE
132{
134 {
137 }
138}
139#endif
140
141
142#ifndef SFX_MODULE
144{
145 if (SavePosNumber>0)
146 {
149 }
150}
151#endif
size_t Size()
Definition: array.hpp:94
void Add(size_t Items)
Definition: array.hpp:100
void Reset()
Definition: array.hpp:148
void AddStringA(const char *Str)
Definition: strlist.cpp:18
Array< wchar > StringData
Definition: strlist.hpp:7
void RestorePosition()
Definition: strlist.cpp:143
size_t SavePosNumber
Definition: strlist.hpp:12
bool GetStringA(char *Str, size_t MaxLength)
Definition: strlist.cpp:39
bool Search(const wchar *Str, bool CaseSensitive)
Definition: strlist.cpp:110
size_t CurPos
Definition: strlist.hpp:8
void Rewind()
Definition: strlist.cpp:103
void AddString(const wchar *Str)
Definition: strlist.cpp:26
StringList()
Definition: strlist.cpp:3
wchar * GetString()
Definition: strlist.cpp:77
void Reset()
Definition: strlist.cpp:9
size_t StringsCount
Definition: strlist.hpp:10
size_t SaveCurPos[16]
Definition: strlist.hpp:12
void SavePosition()
Definition: strlist.cpp:131
#define ASIZE(x)
Definition: rardefs.hpp:10
wchar_t wchar
Definition: rartypes.hpp:13
void wcsncpyz(wchar *dest, const wchar *src, size_t maxlen)
Definition: strfn.cpp:275
bool WideToChar(const wchar *Src, char *Dest, size_t DestSize)
Definition: unicode.cpp:20
int wcsicomp(const wchar *s1, const wchar *s2)
Definition: unicode.cpp:425
bool CharToWide(const char *Src, wchar *Dest, size_t DestSize)
Definition: unicode.cpp:85