Files
BuildTools
Qt
Src
Agave
Components
Elevator
Mastering
Plugins
ReplayGainAnalysis
WAT
Wasabi
Lib
Wasabi.xcodeproj
api
bfc
bfc.xcodeproj
draw
file
parse
Makefile.am
Makefile.in
PathParseW.cpp
hierarchyparser.cpp
hierarchyparser.h
paramparser.cpp
paramparser.h
pathparse.cpp
pathparse.h
platform
string
util
assert.cpp
assert.h
bfc.sln
bfc.vcxproj
bfc.vcxproj.filters
bfc_assert.h
bitlist.h
common.h
critsec.cpp
critsec.h
depend.cpp
depend.h
depview.cpp
depview.h
dispatch.h
error.h
foreach.cpp
foreach.h
freelist.cpp
freelist.h
loadlib.cpp
loadlib.h
memblock.cpp
memblock.h
multipatch.h
named.h
node.cpp
node.h
nsguid.cpp
nsguid.h
pair.h
precomp_wasabi_bfc.cpp
precomp_wasabi_bfc.h
ptrlist.cpp
ptrlist.h
reentryfilter.h
stack.cpp
stack.h
std_file.cpp
std_file.h
std_keyboard.cpp
std_keyboard.h
std_math.cpp
std_math.h
std_mem.h
std_mkncc.h
std_string.cpp
std_string.h
std_wnd.cpp
test.cpp
thread.cpp
thread.h
tlist.h
wasabi_std.cpp
wasabi_std.h
wasabi_std_rect.cpp
wasabi_std_rect.h
wasabi_std_wnd.h
wasabicfg
Wasabi.sln
Wasabi.vcxproj
Wasabi.vcxproj.filters
api.h
mc.exe
nscrt.dll
precomp.cpp
precomp.h
wasabicfg.h
wasabitest.cpp
Wasabi2
Winamp
aacPlus
aacdec
aacdec-mft
adpcm
alac
albumart
apev2
auth
bmp
burnlib
codesign
config
devices
external_dependencies
f263
filereader
freetypewac
gif
gracenote
h264
h264dec
id3v2
ie_plugin
installer
jpeg
libvp6
libvpShared
mp3-mpg123
mp4v
mpeg4dec
nde
nprt_plugin
ns-eel
ns-eel2
nsavi
nsmkv
nsutil
nsv
nsvdec_vp3
nsvdec_vp5
nsvdec_vp6
nswasabi
nu
omBrowser
pcm
pfc
playlist
plist
png
replicant
resources
tagz
tataki
theora
timer
vlb
vp32
vp6
vp8x
wbm
winampAll
winampa
xml
xspf
vcpkg-ports
.gitignore
LICENSE.md
README.md
automate-git.py
cef_x86.bat
install-packages.cmd
vcpkg_version_finder.py
winampAll_2019.sln
winamp/Src/Wasabi/bfc/parse/pathparse.h
2024-09-24 14:54:57 +02:00

153 lines
4.0 KiB
C++

#ifndef _PATHPARSE_H
#define _PATHPARSE_H
#include <bfc/ptrlist.h>
#include <bfc/string/bfcstring.h>
#include <bfc/string/StringW.h>
/**
PathParser is a class that parses a DOS/Windows (example: C:\DOS)
style path as well as a UNIX style path (example: /usr/local/bin/).
@short Path parser for Windows and UNIX style paths.
@author Nullsoft
@ver 1.0
*/
class PathParser
{
public:
/**
When PathParser is instantiated, the contructor takes the path to
parse and the separators to use to parse the path. It will then
parse the path using the separators and make the parsed elements
available. If no separators are given \ and / are used.
@param str The path to parse.
@param separators String that contains the separators to use. Single character separators only.
No delimiters between separators in the string.
*/
PathParser(const char *_str, const char *sep = "\\/", int uniquestrs = 0);
void setString(const char *string, const char *separators = "\\/");
/**
Gets the number of path elements found in the path.
@ret The number of path elements found.
*/
int getNumStrings();
/**
Gets the number of path elements found in the path.
@ret The number of path elements found.
*/
char *enumString(int i);
char *enumStringSafe(int i, char *def_val="");
/**
Gets the last path element from the parsed path.
@ret The last path element from the parsed path.
*/
char *getLastString() { return enumString(getNumStrings()-1); }
protected:
/**
Override available for pre-processing of the
string before it's split. This is done at the start
of the process() call.
@param str A reference to the string to pre-process.
*/
virtual void preProcess(String &str) { }
/**
Override available for post-processing of the pieces
of the command line that are obtained after it's
been split.
@param str The command line piece to post-process.
*/
virtual void postProcess(char *str) { }
private:
void process();
int processed;
String str;
String separators;
PtrList<char> strings;
int uniques;
};
class PathParserW
{
public:
/**
When PathParser is instantiated, the contructor takes the path to
parse and the separators to use to parse the path. It will then
parse the path using the separators and make the parsed elements
available. If no separators are given \ and / are used.
@param str The path to parse.
@param separators String that contains the separators to use. Single character separators only.
No delimiters between separators in the string.
*/
PathParserW(const wchar_t *_str, const wchar_t *sep = L"\\/", int uniquestrs = 0);
void setString(const wchar_t *string, const wchar_t *separators = L"\\/");
/**
Gets the number of path elements found in the path.
@ret The number of path elements found.
*/
int getNumStrings();
/**
Gets the number of path elements found in the path.
@ret The number of path elements found.
*/
wchar_t *enumString(int i);
wchar_t *enumStringSafe(int i, wchar_t *def_val=L"");
/**
Gets the last path element from the parsed path.
@ret The last path element from the parsed path.
*/
wchar_t *getLastString() { return enumString(getNumStrings()-1); }
protected:
/**
Override available for pre-processing of the
string before it's split. This is done at the start
of the process() call.
@param str A reference to the string to pre-process.
*/
virtual void preProcess(StringW &str) { }
/**
Override available for post-processing of the pieces
of the command line that are obtained after it's
been split.
@param str The command line piece to post-process.
*/
virtual void postProcess(wchar_t *str) { }
private:
void process();
int processed;
StringW str;
StringW separators;
PtrList<wchar_t> strings;
int uniques;
};
#endif