aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/bfc/parse
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Wasabi/bfc/parse')
-rw-r--r--Src/Wasabi/bfc/parse/Makefile.am4
-rw-r--r--Src/Wasabi/bfc/parse/Makefile.in372
-rw-r--r--Src/Wasabi/bfc/parse/PathParseW.cpp55
-rw-r--r--Src/Wasabi/bfc/parse/hierarchyparser.cpp99
-rw-r--r--Src/Wasabi/bfc/parse/hierarchyparser.h55
-rw-r--r--Src/Wasabi/bfc/parse/paramparser.cpp20
-rw-r--r--Src/Wasabi/bfc/parse/paramparser.h23
-rw-r--r--Src/Wasabi/bfc/parse/pathparse.cpp54
-rw-r--r--Src/Wasabi/bfc/parse/pathparse.h152
9 files changed, 834 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/parse/Makefile.am b/Src/Wasabi/bfc/parse/Makefile.am
new file mode 100644
index 00000000..ba35f4f9
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/Makefile.am
@@ -0,0 +1,4 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+noinst_HEADERS = hierarchyparser.h paramparser.h pathparse.h
+
diff --git a/Src/Wasabi/bfc/parse/Makefile.in b/Src/Wasabi/bfc/parse/Makefile.in
new file mode 100644
index 00000000..09b532c0
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/Makefile.in
@@ -0,0 +1,372 @@
+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+AR = @AR@
+AS = @AS@
+CC = @CC@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+DLLTOOL = @DLLTOOL@
+ECHO = @ECHO@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
+HAVE_LIB = @HAVE_LIB@
+LIB = @LIB@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIB = @LTLIB@
+MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+RC = @RC@
+STRIP = @STRIP@
+VERSION = @VERSION@
+
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+noinst_LTLIBRARIES = libbfc_parse.la
+libbfc_parse_la_SOURCES = hierarchyparser.cpp paramparser.cpp pathparse.cpp
+noinst_HEADERS = hierarchyparser.h paramparser.h pathparse.h
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../../../config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libbfc_parse_la_LDFLAGS =
+libbfc_parse_la_LIBADD =
+libbfc_parse_la_OBJECTS = hierarchyparser.lo paramparser.lo \
+pathparse.lo
+CXXFLAGS = @CXXFLAGS@
+CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
+HEADERS = $(noinst_HEADERS)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+DEP_FILES = .deps/hierarchyparser.P .deps/paramparser.P \
+.deps/pathparse.P
+SOURCES = $(libbfc_parse_la_SOURCES)
+OBJECTS = $(libbfc_parse_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .cpp .lo .o .obj .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bfc/parse/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLTLIBRARIES:
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+
+distclean-noinstLTLIBRARIES:
+
+maintainer-clean-noinstLTLIBRARIES:
+
+# FIXME: We should only use cygpath when building on Windows,
+# and only if it is available.
+.c.obj:
+ $(COMPILE) -c `cygpath -w $<`
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+ -rm -f *.$(OBJEXT)
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libbfc_parse.la: $(libbfc_parse_la_OBJECTS) $(libbfc_parse_la_DEPENDENCIES)
+ $(CXXLINK) $(libbfc_parse_la_LDFLAGS) $(libbfc_parse_la_OBJECTS) $(libbfc_parse_la_LIBADD) $(LIBS)
+.cpp.o:
+ $(CXXCOMPILE) -c $<
+.cpp.obj:
+ $(CXXCOMPILE) -c `cygpath -w $<`
+.cpp.lo:
+ $(LTCXXCOMPILE) -c $<
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = src/bfc/parse
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/bfc/parse/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+
+%.o: %.cpp
+ @echo '$(CXXCOMPILE) -c $<'; \
+ $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.cpp
+ @echo '$(LTCXXCOMPILE) -c $<'; \
+ $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
+ clean-tags clean-depend clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
+ distclean-libtool distclean-tags distclean-depend \
+ distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
+clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Src/Wasabi/bfc/parse/PathParseW.cpp b/Src/Wasabi/bfc/parse/PathParseW.cpp
new file mode 100644
index 00000000..e60f422a
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/PathParseW.cpp
@@ -0,0 +1,55 @@
+#include <bfc/bfc_assert.h>
+#include "pathparse.h"
+
+PathParserW::PathParserW(const wchar_t *_str, const wchar_t *sep, int uniquestrs) :
+ processed(FALSE), str(_str ? _str : L""), separators(sep), uniques(uniquestrs)
+{
+ ASSERT(sep != NULL);
+}
+
+int PathParserW::getNumStrings() {
+ process();
+ return strings.getNumItems();
+}
+
+wchar_t *PathParserW::enumString(int i) {
+ process();
+ return strings[i];
+}
+
+wchar_t *PathParserW::enumStringSafe(int i, wchar_t *def_val) {
+ wchar_t *ret = enumString(i);
+ if (ret == NULL) ret = def_val;
+ return ret;
+}
+
+void PathParserW::process() {
+ if (processed) return;
+ processed = 1;
+ preProcess(str);
+ wchar_t *nonconst = str.getNonConstVal();
+ wchar_t *context=0;
+
+ wchar_t *pt = WCSTOK(nonconst, separators, &context);
+ if (pt == NULL) return;
+ postProcess(pt);
+ strings.addItem(pt);
+ for (;;) {
+ wchar_t *pt = WCSTOK(NULL, separators, &context);
+ if (pt == NULL) break;
+ postProcess(pt);
+ if (uniques) {
+ int exists = 0;
+ foreach(strings)
+ if (!WCSICMP(strings.getfor(), pt))
+ {
+ exists=1;
+ break;
+ }
+ endfor;
+ if (exists) continue;
+ }
+ strings.addItem(pt);
+ }
+}
+
diff --git a/Src/Wasabi/bfc/parse/hierarchyparser.cpp b/Src/Wasabi/bfc/parse/hierarchyparser.cpp
new file mode 100644
index 00000000..8d07ed82
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/hierarchyparser.cpp
@@ -0,0 +1,99 @@
+#include "precomp_wasabi_bfc.h"
+#include "hierarchyparser.h"
+#include <bfc/nsguid.h>
+#include <wchar.h>
+// This uses an AMAZINGLY inefficient algorithm! woo hoo!
+
+HierarchyParser::HierarchyParser(const wchar_t *str, const wchar_t *_sibling, const wchar_t *_escape, const wchar_t *_parent_open, const wchar_t *_parent_close) {
+ // Create a new rootnode.
+ rootnode = new HPNode(str);
+ // Parse the rootnode's contents into the rootnode's children.
+ HierarchyParser downparse(rootnode, _sibling, _escape, _parent_open, _parent_close);
+ // Set the actual name of the rootnode ("")
+ (*rootnode)() = L"";
+ // Mark that this was our allocation
+ myalloc = 1;
+}
+
+HierarchyParser::~HierarchyParser() {
+ // If we alloc, we must delete.
+ if (myalloc) {
+ delete rootnode;
+ }
+}
+
+HPNode *HierarchyParser::findGuid(GUID g) {
+ return NULL;
+}
+
+HPNode *HierarchyParser::findString(const wchar_t *str) {
+ return NULL;
+}
+
+HierarchyParser::HierarchyParser(HPNode *_rootnode, const wchar_t *_sibling, const wchar_t *_escape, const wchar_t *_parent_open, const wchar_t *_parent_close) {
+ // We did not alloc, we should not delete.
+ rootnode = _rootnode;
+ sibling = _sibling;
+ escape = _escape;
+ parent_open = _parent_open;
+ parent_close = _parent_close;
+
+ myalloc = 0;
+
+ const wchar_t *parsestr = (*rootnode)();
+
+ size_t i, length = wcslen(parsestr), depth = 0;
+
+ StringW curr_sibling;
+
+ for (i = 0; i < length; i++ ) {
+ wchar_t c = parsestr[i];
+
+ if (isEscape(c)) {
+ // always add the next character
+ curr_sibling += parsestr[++i];
+ } else if (isSibling(c)) {
+ // if we're not inside someone else,
+ if (!depth) {
+ // okay, we're done with the current sibling. ship him off.
+ processSibling(curr_sibling);
+ // on to the next sibling!
+ curr_sibling = L"";
+ } else {
+ curr_sibling += c;
+ }
+ } else if (isParentOpen(c)) {
+ // increment depth
+ curr_sibling += c;
+ depth++;
+ } else if (isParentClose(c)) {
+ // decrement depth
+ curr_sibling += c;
+ depth--;
+ } else {
+ curr_sibling += c;
+ }
+ }
+
+ // If there is anything left over, process it as a sibling.
+ if (curr_sibling.len()) {
+ processSibling(curr_sibling);
+ }
+}
+
+void HierarchyParser::processSibling(const wchar_t *sibstr) {
+ StringW curr_sibling = sibstr;
+ // slice the name out of the front of the string.
+ StringW sibling_name = curr_sibling.lSpliceChar(parent_open);
+ // curr_sibling will contain the children of this sibling (or nothing).
+ curr_sibling.rSpliceChar(parent_close);
+ // create a new child for our root node to contain the sibling's child info
+ HPNode *child = new HPNode(curr_sibling, rootnode);
+ // parse the child hierarchically for its children
+ HierarchyParser childparser(child, sibling, escape, parent_open, parent_close);
+ // once parsed. set its name to be this sibling
+ (*child)() = sibling_name;
+ // and lastly add him as a child to the root node.
+ rootnode->addChild(child);
+}
+
diff --git a/Src/Wasabi/bfc/parse/hierarchyparser.h b/Src/Wasabi/bfc/parse/hierarchyparser.h
new file mode 100644
index 00000000..286b3706
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/hierarchyparser.h
@@ -0,0 +1,55 @@
+#ifndef __PARAMPARSE_H
+#define __PARAMPARSE_H
+
+#include <bfc/parse/pathparse.h>
+#include <bfc/node.h>
+#include <bfc/string/StringW.h>
+
+
+// typedef NodeC<String> HPNode // OH YAH, YOU CAN'T FWD REF TYPEDEFS. STOOOOOOPID.
+class HPNode : public NodeC<StringW> {
+public:
+ HPNode( const StringW & myPayload, NodeC<StringW> * myParent = NULL ) : NodeC<StringW>(myPayload, myParent) {}
+};
+
+class HierarchyParser {
+public:
+ HierarchyParser(const wchar_t *str = NULL, const wchar_t *_sibling=L";", const wchar_t *_escape=L"\\", const wchar_t *_parent_open=L"(", const wchar_t *_parent_close=L")") ;
+ ~HierarchyParser();
+
+ HPNode *findGuid(GUID g);
+ HPNode *findString(const wchar_t *str);
+
+ int hasGuid(GUID g) { return findGuid(g) != NULL; }
+ int hasString(const wchar_t *str) { return findString(str) != NULL; }
+
+ HPNode *rootNode() { return rootnode; }
+
+private:
+ HPNode *rootnode;
+ int myalloc;
+
+ StringW sibling;
+ StringW escape;
+ StringW parent_open;
+ StringW parent_close;
+
+ HierarchyParser(HPNode *_rootnode, const wchar_t *_sibling=L";", const wchar_t *_escape=L"\\", const wchar_t *_parent_open=L"(", const wchar_t *_parent_close=L")");
+ void processSibling(const wchar_t *sibling);
+
+
+ inline int isSibling(wchar_t c) {
+ return sibling.lFindChar(c) != -1;
+ }
+ inline int isEscape(wchar_t c) {
+ return escape.lFindChar(c) != -1;
+ }
+ inline int isParentOpen(wchar_t c) {
+ return parent_open.lFindChar(c) != -1;
+ }
+ inline int isParentClose(wchar_t c) {
+ return parent_close.lFindChar(c) != -1;
+ }
+};
+
+#endif
diff --git a/Src/Wasabi/bfc/parse/paramparser.cpp b/Src/Wasabi/bfc/parse/paramparser.cpp
new file mode 100644
index 00000000..c68bbbe2
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/paramparser.cpp
@@ -0,0 +1,20 @@
+#include "precomp_wasabi_bfc.h"
+#include "paramparser.h"
+#include <bfc/nsguid.h>
+#include <bfc/wasabi_std.h>
+
+int ParamParser::findGuid(GUID g) {
+ for (int i=0;i<getNumItems();i++) {
+ const wchar_t *e = enumItem(i);
+ GUID eguid = nsGUID::fromCharW(e);
+ if (g == eguid) return i;
+ }
+ return -1;
+}
+
+int ParamParser::findString(const wchar_t *str) {
+ for (int i=0;i<getNumItems();i++) {
+ if (!WCSICMP(str, enumItem(i))) return i;
+ }
+ return -1;
+} \ No newline at end of file
diff --git a/Src/Wasabi/bfc/parse/paramparser.h b/Src/Wasabi/bfc/parse/paramparser.h
new file mode 100644
index 00000000..69573bdc
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/paramparser.h
@@ -0,0 +1,23 @@
+#ifndef __PARAMPARSE_H
+#define __PARAMPARSE_H
+
+#include <bfc/parse/pathparse.h>
+
+class ParamParser : private PathParserW
+{
+ public:
+
+ ParamParser(const wchar_t *str, const wchar_t *sep=L";", int unique=0) : PathParserW(str, sep, unique) {}
+
+ int findGuid(GUID g);
+ int findString(const wchar_t *str);
+
+ int hasGuid(GUID g) { return findGuid(g) >= 0; }
+ int hasString(const wchar_t *str) { return findString(str) >= 0; }
+
+ const wchar_t *enumItem(int element) { return enumString(element); }
+ int getNumItems() { return getNumStrings(); }
+ const wchar_t *getLastItem() { return getLastString(); }
+};
+
+#endif
diff --git a/Src/Wasabi/bfc/parse/pathparse.cpp b/Src/Wasabi/bfc/parse/pathparse.cpp
new file mode 100644
index 00000000..a6653d5d
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/pathparse.cpp
@@ -0,0 +1,54 @@
+#include "precomp_wasabi_bfc.h"
+#include <bfc/wasabi_std.h>
+#include "pathparse.h"
+
+PathParser::PathParser(const char *_str, const char *sep, int uniquestrs) :
+ processed(FALSE), str(_str ? _str : ""), separators(sep), uniques(uniquestrs)
+{
+ ASSERT(sep != NULL);
+}
+
+int PathParser::getNumStrings() {
+ process();
+ return strings.getNumItems();
+}
+
+char *PathParser::enumString(int i) {
+ process();
+ return strings[i];
+}
+
+char *PathParser::enumStringSafe(int i, char *def_val) {
+ char *ret = enumString(i);
+ if (ret == NULL) ret = def_val;
+ return ret;
+}
+
+void PathParser::process() {
+ if (processed) return;
+ processed = 1;
+ preProcess(str);
+ char *nonconst = str.getNonConstVal();
+
+ char *pt = strtok(nonconst, separators);
+ if (pt == NULL) return;
+ postProcess(pt);
+ strings.addItem(pt);
+ for (;;) {
+ char *pt = strtok(NULL, separators);
+ if (pt == NULL) break;
+ postProcess(pt);
+ if (uniques) {
+ int exists = 0;
+ foreach(strings)
+ if (STRCASEEQL(strings.getfor(), pt)) {
+ exists=1;
+ break;
+ }
+ endfor;
+ if (exists) continue;
+ }
+ strings.addItem(pt);
+ }
+}
+
diff --git a/Src/Wasabi/bfc/parse/pathparse.h b/Src/Wasabi/bfc/parse/pathparse.h
new file mode 100644
index 00000000..67a22ffe
--- /dev/null
+++ b/Src/Wasabi/bfc/parse/pathparse.h
@@ -0,0 +1,152 @@
+#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