From 5b5a1dfbb65ef1072e20c138609231379979ed06 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 17 Mar 2021 13:16:01 +0100 Subject: [PATCH] changed the way how the library is built - now there is only one Makefile in the root directory and we have only one pikotools.a lib file - removed: mainparser --- Makefile | 74 ++++------ Makefile.dep | 48 +++++++ convert/Makefile | 27 ---- convert/Makefile.dep | 5 - convert/Makefile.o.dep | 1 - date/Makefile | 27 ---- date/Makefile.dep | 3 - date/Makefile.o.dep | 1 - log/Makefile | 27 ---- log/Makefile.dep | 10 -- log/Makefile.o.dep | 1 - mainparser/Makefile | 27 ---- mainparser/Makefile.dep | 3 - mainparser/Makefile.o.dep | 1 - mainparser/mainparser.cpp | 237 --------------------------------- mainparser/mainparser.h | 132 ------------------ mainparser/sample/Makefile | 10 -- mainparser/sample/sample.cpp | 117 ---------------- mainspaceparser/Makefile | 27 ---- mainspaceparser/Makefile.dep | 7 - mainspaceparser/Makefile.o.dep | 1 - space/Makefile | 27 ---- space/Makefile.dep | 27 ---- space/Makefile.o.dep | 1 - utf8/Makefile | 27 ---- utf8/Makefile.dep | 9 -- utf8/Makefile.o.dep | 1 - 27 files changed, 77 insertions(+), 801 deletions(-) create mode 100644 Makefile.dep delete mode 100644 convert/Makefile delete mode 100644 convert/Makefile.dep delete mode 100644 convert/Makefile.o.dep delete mode 100644 date/Makefile delete mode 100644 date/Makefile.dep delete mode 100644 date/Makefile.o.dep delete mode 100644 log/Makefile delete mode 100644 log/Makefile.dep delete mode 100644 log/Makefile.o.dep delete mode 100644 mainparser/Makefile delete mode 100644 mainparser/Makefile.dep delete mode 100644 mainparser/Makefile.o.dep delete mode 100644 mainparser/mainparser.cpp delete mode 100644 mainparser/mainparser.h delete mode 100644 mainparser/sample/Makefile delete mode 100644 mainparser/sample/sample.cpp delete mode 100644 mainspaceparser/Makefile delete mode 100644 mainspaceparser/Makefile.dep delete mode 100644 mainspaceparser/Makefile.o.dep delete mode 100644 space/Makefile delete mode 100644 space/Makefile.dep delete mode 100644 space/Makefile.o.dep delete mode 100644 utf8/Makefile delete mode 100644 utf8/Makefile.dep delete mode 100644 utf8/Makefile.o.dep diff --git a/Makefile b/Makefile index 5ea0e93..058a006 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,14 @@ -# Makefile for GNU make +sourcefiles:=$(shell find . -name "*.cpp") +objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles)) + + + +CXX = g++10 +#CXX = clang++ +#CXXFLAGS = -fsanitize=address -O0 -g3 -gdwarf-2 -O0 -std=c++14 -I../ttmath -I../pikotools -Wl,-rpath=/usr/local/lib/gcc5/ -Wall -pedantic -Wextra +#CXXFLAGS = -O0 -g3 -gdwarf-2 -O0 -std=c++17 -I../ttmath -I../pikotools -Wl,-rpath=/usr/local/lib/gcc7/ -Wall -pedantic -Wextra +CXXFLAGS = -Wl,-rpath=/usr/local/lib/gcc10/ -O0 -g3 -std=c++20 -I../pikotools -Wall -pedantic + ifndef CXX CXX = clang++ @@ -16,61 +26,35 @@ ifndef AR AR = ar endif -#CXX=g++5 -#CXXFLAGS=-Wall -O0 -g3 -gdwarf-2 -std=c++14 -export CXX -export CXXFLAGS -export LDFLAGS -export AR +#export CXX +#export CXXFLAGS +#export LDFLAGS +#export AR -all: space mainparser mainspaceparser utf8 date convert log +libname = pikotools.a +all: $(libname) -space: FORCE - @cd space ; $(MAKE) -e - -mainparser: FORCE - @cd mainparser ; $(MAKE) -e - -mainspaceparser: FORCE - @cd mainspaceparser ; $(MAKE) -e - -utf8: FORCE - @cd utf8 ; $(MAKE) -e - -date: FORCE - @cd date ; $(MAKE) -e - -convert: FORCE - @cd convert ; $(MAKE) -e - -log: FORCE - @cd log ; $(MAKE) -e +$(libname): $(objfiles) + $(AR) rcs $(libname) $(objfiles) - - -FORCE: +%.o: %.cpp + $(CXX) -c $(CXXFLAGS) -o $@ $< clean: - @cd space ; $(MAKE) -e clean - @cd mainparser ; $(MAKE) -e clean - @cd mainspaceparser ; $(MAKE) -e clean - @cd utf8 ; $(MAKE) -e clean - @cd date ; $(MAKE) -e clean - @cd convert ; $(MAKE) -e clean - @cd log ; $(MAKE) -e clean + rm -f $(objfiles) + rm -f $(libname) + depend: - @cd space ; $(MAKE) -e depend - @cd mainparser ; $(MAKE) -e depend - @cd mainspaceparser ; $(MAKE) -e depend - @cd utf8 ; $(MAKE) -e depend - @cd date ; $(MAKE) -e depend - @cd convert ; $(MAKE) -e depend - @cd log ; $(MAKE) -e depend + makedepend -Y. -f- $(sourcefiles) > Makefile.dep + + +-include Makefile.dep + diff --git a/Makefile.dep b/Makefile.dep new file mode 100644 index 0000000..891cd41 --- /dev/null +++ b/Makefile.dep @@ -0,0 +1,48 @@ +# DO NOT DELETE + +./convert/misc.o: ./convert/misc.h ./convert/text.h +./convert/text.o: ./convert/text.h +./convert/inttostr.o: ./convert/inttostr.h +./date/date.o: ./date/date.h convert/inttostr.h +./log/filelog.o: ./log/filelog.h textstream/textstream.h space/space.h +./log/filelog.o: textstream/types.h convert/inttostr.h date/date.h +./log/filelog.o: membuffer/membuffer.h textstream/types.h utf8/utf8.h +./log/filelog.o: utf8/utf8_templates.h utf8/utf8_private.h +./log/log.o: ./log/log.h textstream/textstream.h space/space.h +./log/log.o: textstream/types.h convert/inttostr.h date/date.h +./log/log.o: membuffer/membuffer.h textstream/types.h ./log/filelog.h +./log/log.o: utf8/utf8.h utf8/utf8_templates.h utf8/utf8_private.h +./mainspaceparser/mainspaceparser.o: ./mainspaceparser/mainspaceparser.h +./mainspaceparser/mainspaceparser.o: space/space.h textstream/types.h +./mainspaceparser/mainspaceparser.o: convert/inttostr.h utf8/utf8.h +./mainspaceparser/mainspaceparser.o: textstream/textstream.h date/date.h +./mainspaceparser/mainspaceparser.o: membuffer/membuffer.h textstream/types.h +./mainspaceparser/mainspaceparser.o: utf8/utf8_templates.h +./mainspaceparser/mainspaceparser.o: utf8/utf8_private.h +./space/jsontospaceparser.o: ./space/jsontospaceparser.h ./space/space.h +./space/jsontospaceparser.o: textstream/types.h convert/inttostr.h +./space/jsontospaceparser.o: utf8/utf8.h textstream/textstream.h +./space/jsontospaceparser.o: space/space.h date/date.h membuffer/membuffer.h +./space/jsontospaceparser.o: textstream/types.h utf8/utf8_templates.h +./space/jsontospaceparser.o: utf8/utf8_private.h convert/strtoint.h +./space/jsontospaceparser.o: ./convert/text.h ./convert/misc.h +./space/space.o: ./space/space.h textstream/types.h convert/inttostr.h +./space/space.o: utf8/utf8.h textstream/textstream.h space/space.h +./space/space.o: date/date.h membuffer/membuffer.h textstream/types.h +./space/space.o: utf8/utf8_templates.h utf8/utf8_private.h convert/convert.h +./space/space.o: ./convert/inttostr.h convert/patternreplacer.h +./space/space.o: convert/strtoint.h ./convert/text.h ./convert/misc.h +./space/spaceparser.o: ./space/spaceparser.h ./space/space.h +./space/spaceparser.o: textstream/types.h convert/inttostr.h utf8/utf8.h +./space/spaceparser.o: textstream/textstream.h space/space.h date/date.h +./space/spaceparser.o: membuffer/membuffer.h textstream/types.h +./space/spaceparser.o: utf8/utf8_templates.h utf8/utf8_private.h +./space/spacetojson.o: ./space/spacetojson.h ./space/space.h +./space/spacetojson.o: textstream/types.h convert/inttostr.h +./utf8/utf8.o: ./utf8/utf8.h textstream/textstream.h space/space.h +./utf8/utf8.o: textstream/types.h convert/inttostr.h date/date.h +./utf8/utf8.o: membuffer/membuffer.h textstream/types.h utf8/utf8_templates.h +./utf8/utf8.o: utf8/utf8_private.h +./utf8/utf8_private.o: utf8/utf8_private.h textstream/textstream.h +./utf8/utf8_private.o: space/space.h textstream/types.h convert/inttostr.h +./utf8/utf8_private.o: date/date.h membuffer/membuffer.h textstream/types.h diff --git a/convert/Makefile b/convert/Makefile deleted file mode 100644 index 3b74c9f..0000000 --- a/convert/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=convert.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/convert/Makefile.dep b/convert/Makefile.dep deleted file mode 100644 index 35b219c..0000000 --- a/convert/Makefile.dep +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT DELETE - -inttostr.o: inttostr.h -misc.o: misc.h text.h -text.o: text.h diff --git a/convert/Makefile.o.dep b/convert/Makefile.o.dep deleted file mode 100644 index 70b7e42..0000000 --- a/convert/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = inttostr.o misc.o text.o \ No newline at end of file diff --git a/date/Makefile b/date/Makefile deleted file mode 100644 index a17267b..0000000 --- a/date/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=date.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/date/Makefile.dep b/date/Makefile.dep deleted file mode 100644 index 4b933e3..0000000 --- a/date/Makefile.dep +++ /dev/null @@ -1,3 +0,0 @@ -# DO NOT DELETE - -date.o: date.h ../convert/inttostr.h diff --git a/date/Makefile.o.dep b/date/Makefile.o.dep deleted file mode 100644 index 1e1c891..0000000 --- a/date/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = date.o \ No newline at end of file diff --git a/log/Makefile b/log/Makefile deleted file mode 100644 index bed6eba..0000000 --- a/log/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=log.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/log/Makefile.dep b/log/Makefile.dep deleted file mode 100644 index a409558..0000000 --- a/log/Makefile.dep +++ /dev/null @@ -1,10 +0,0 @@ -# DO NOT DELETE - -filelog.o: filelog.h ../textstream/textstream.h ../space/space.h -filelog.o: ../textstream/types.h ../convert/inttostr.h ../date/date.h -filelog.o: ../membuffer/membuffer.h ../textstream/types.h ../utf8/utf8.h -filelog.o: ../utf8/utf8_templates.h ../utf8/utf8_private.h -log.o: log.h ../textstream/textstream.h ../space/space.h -log.o: ../textstream/types.h ../convert/inttostr.h ../date/date.h -log.o: ../membuffer/membuffer.h ../textstream/types.h filelog.h -log.o: ../utf8/utf8.h ../utf8/utf8_templates.h ../utf8/utf8_private.h diff --git a/log/Makefile.o.dep b/log/Makefile.o.dep deleted file mode 100644 index 3eff2ad..0000000 --- a/log/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = filelog.o log.o \ No newline at end of file diff --git a/mainparser/Makefile b/mainparser/Makefile deleted file mode 100644 index a451264..0000000 --- a/mainparser/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=mainparser.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/mainparser/Makefile.dep b/mainparser/Makefile.dep deleted file mode 100644 index ad09e57..0000000 --- a/mainparser/Makefile.dep +++ /dev/null @@ -1,3 +0,0 @@ -# DO NOT DELETE - -mainparser.o: mainparser.h diff --git a/mainparser/Makefile.o.dep b/mainparser/Makefile.o.dep deleted file mode 100644 index 0a6c3a7..0000000 --- a/mainparser/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = mainparser.o \ No newline at end of file diff --git a/mainparser/mainparser.cpp b/mainparser/mainparser.cpp deleted file mode 100644 index 6a67449..0000000 --- a/mainparser/mainparser.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * This file is a part of PikoTools - * and is distributed under the (new) BSD licence. - * Author: Tomasz Sowa - */ - -/* - * Copyright (c) 2011-2012, Tomasz Sowa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name Tomasz Sowa nor the names of contributors to this - * project may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 "mainparser.h" -#include - - -namespace PT -{ - - -MainParser::MainParser() -{ - argsize = 0; - arg = 0; - Reset(); -} - - - -MainParser::MainParser(int argc, const char ** argv) -{ - Set(argc, argv); - Reset(); -} - - - -void MainParser::Set(int argc, const char ** argv) -{ - argsize = argc; - arg = argv; - Reset(); -} - - - -void MainParser::Reset() -{ - argindex = 1; - offset = 0; - has_single_param = false; - has_double_param = false; -} - - - -char MainParser::GetSingleParam() -{ - if( !has_single_param ) - return 0; - - if( last_single_param != 0 ) - return last_single_param; - - Advance(); - - if( argindex >= argsize ) - return 0; - - last_single_param = arg[argindex][offset]; - offset += 1; - -return last_single_param; -} - - - -bool MainParser::IsSingleParam(char c) -{ - return GetSingleParam() == c; -} - - -const char * MainParser::GetDoubleParam() -{ - empty = 0; - - if( !has_double_param ) - return ∅ - - if( last_double_param != &empty ) - return last_double_param; - - Advance(); - - if( argindex >= argsize ) - return ∅ - - last_double_param = &arg[argindex][offset]; - offset = 0; - argindex += 1; - -return last_double_param; -} - - -bool MainParser::IsDoubleParam(const char * param) -{ - return strcmp(GetDoubleParam(), param) == 0; -} - - -const char * MainParser::GetValue() -{ - empty = 0; - Advance(); - - if( argindex >= argsize ) - return ∅ - - const char * value = &arg[argindex][offset]; - offset = 0; - argindex += 1; - has_single_param = false; - has_double_param = false; - -return value; -} - - - -bool MainParser::NextParam() -{ - bool was_single_param = has_single_param; - has_single_param = false; - has_double_param = false; - last_single_param = 0; - last_double_param = ∅ - empty = 0; - - if( Advance() ) - was_single_param = false; - - if( argindex >= argsize ) - return false; - - if( arg[argindex][offset]=='-' ) - { - if( arg[argindex][offset+1]=='-' ) - { - has_double_param = true; - offset += 2; - } - else - { - has_single_param = true; - offset += 1; - } - } - else - { - if( was_single_param ) - has_single_param = true; - } - -return has_single_param || has_double_param; -} - - - -bool MainParser::IsEnd() -{ - Advance(); - -return argindex >= argsize; -} - - - -bool MainParser::HasSingleParam() -{ - return has_single_param; -} - - - -bool MainParser::HasDoubleParam() -{ - return has_double_param; -} - - - -bool MainParser::Advance() -{ -bool was_incremented = false; - - while( argindex < argsize && arg[argindex][offset] == 0 ) - { - offset = 0; - argindex += 1; - was_incremented = true; - } - -return was_incremented; -} - - -} // namespace - - diff --git a/mainparser/mainparser.h b/mainparser/mainparser.h deleted file mode 100644 index 248f22a..0000000 --- a/mainparser/mainparser.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is a part of PikoTools - * and is distributed under the (new) BSD licence. - * Author: Tomasz Sowa - */ - -/* - * Copyright (c) 2011-2012, Tomasz Sowa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name Tomasz Sowa nor the names of contributors to this - * project may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - */ - -#ifndef headerfile_picotools_mainparser_mainparser -#define headerfile_picotools_mainparser_mainparser - - -namespace PT -{ - - -/* - a very little parser for main(int argc, char ** argv) parameters - look in sample/sample.cpp how to use the parser -*/ -class MainParser -{ -public: - - MainParser(); - MainParser(int argc, const char ** argv); - - // setting arguments passed to main(int argc, char ** argv) function - void Set(int argc, const char ** argv); - - // reseting the current state of parsing - // now you can start parsing from the beginning - // you don't have to call it for the first time - // (is automatically called by the Set method) - void Reset(); - - // checking if there is a next single or double parameter - // this method represents the main loop of checking parameters - bool NextParam(); - - // returning a single parameter (if exists) or '\0' otherwise - // single parameter means a parameter with '-' at the beginning e.g. "-a" - // next call to this method (without calling NextParam) returns the same value - // this method should be called after NextParam() - char GetSingleParam(); - - // calling GetSingleParam() and comparign with 'c' - bool IsSingleParam(char c); - - // returning a string for a double parameter or an empty string if there is no such a parameter - // double parameter means a parameter with '--' at the beginning e.g. "--output" - // next call to this method (without calling NextParam) returns the same value - // GetDoubleParam() should be called after NextParam() - // this method never returns a null pointer -- if there is no a param name (end of the string) - // a pointer to en empty string will be returned - const char * GetDoubleParam(); - - // calling GetDoubleParam() and comparing with 'param' - // so you don't have to call strcmp directly - bool IsDoubleParam(const char * param); - - // returning a string representing a value - // you have to know which parameter requires a value - // and if such a parameter is found then use this method to obtain the value - // the method advances the current pointer so next call to this method return a next value - // you can call GetValue() even when NextParam() has returned false - // in such a case this gets you the last values (those at the end of the parameter list) - // this method never returns a null pointer -- if there is no a value (end of the string) - // a pointer to en empty string will be returned - const char * GetValue(); - - // returning true if the input string is finished - // there are no more parameters or values - bool IsEnd(); - - // returning true if there is a single parameter - // should be called after NextParam() - bool HasSingleParam(); - - // returning true if there is a double parameter - // should be called after NextParam() - bool HasDoubleParam(); - -private: - - bool Advance(); - - int argindex; - int offset; - int argsize; - const char ** arg; - char empty; - bool has_single_param; - bool has_double_param; - char last_single_param; - const char * last_double_param; -}; - - -} // namespace - - -#endif diff --git a/mainparser/sample/Makefile b/mainparser/sample/Makefile deleted file mode 100644 index 81942f4..0000000 --- a/mainparser/sample/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -output=sample - -all: $(output) - -$(output): sample.cpp ../mainparser.h ../mainparser.cpp - g++ -o $(output) sample.cpp ../mainparser.cpp - -clean: - rm -f $(output) - rm -f $(output).exe diff --git a/mainparser/sample/sample.cpp b/mainparser/sample/sample.cpp deleted file mode 100644 index 17f38ce..0000000 --- a/mainparser/sample/sample.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is a part of MainParser -- simple parser for main() parameters - * and is distributed under the (new) BSD licence. - * Author: Tomasz Sowa - */ - -/* - * Copyright (c) 2011, Tomasz Sowa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name Tomasz Sowa nor the names of contributors to this - * project may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 -#include -#include "../mainparser.h" - - -int main() -{ -MainParser mp; - - // suppose you call a 'programname' in such a way: - // $ programname -a -b - c --longparam -- otherlongparam -xyz paramwithvalue -x --longparam2 longwithvalue lastvalue1 lastvalue2 lastvalue3 - // so the main() function get this table as input: - - const char * tab[] = { - "programname", - "-a", - "-b", - "-", - "c", - "--longparam", - "--", - "otherlongparam", - "-xyz", - "paramwithvalue", - "-x", - "--longparam2", - "longwithvalue", - "lastvalue1", // some values left at the end - "lastvalue2", // you can get them by using GetValue() method - "lastvalue3", - }; - - mp.Set(sizeof(tab)/sizeof(const char*), tab); - - while( mp.NextParam() ) - { - if( mp.GetSingleParam() != 0 ) - { - std::cout << "-" << mp.GetSingleParam() << std::endl; - - // we know that 'z' requires a value - if( mp.GetSingleParam() == 'z' ) - std::cout << "value for z: " << mp.GetValue() << std::endl; - } - - if( *mp.GetDoubleParam() ) - { - std::cout << "--" << mp.GetDoubleParam() << std::endl; - - // we know that "longparam2" requires a value - if( strcmp(mp.GetDoubleParam(), "longparam2") == 0 ) - std::cout << "value for longparam2: " << mp.GetValue() << std::endl; - } - } - - while( !mp.IsEnd() ) - std::cout << mp.GetValue() << std::endl; -} - -/* -program output: - --a --b --c ---longparam ---otherlongparam --x --y --z -value for z: paramwithvalue --x ---longparam2 -value for longparam2: longwithvalue -lastvalue1 -lastvalue2 -lastvalue3 -*/ diff --git a/mainspaceparser/Makefile b/mainspaceparser/Makefile deleted file mode 100644 index 5e52fc0..0000000 --- a/mainspaceparser/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=mainspaceparser.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/mainspaceparser/Makefile.dep b/mainspaceparser/Makefile.dep deleted file mode 100644 index 733d32a..0000000 --- a/mainspaceparser/Makefile.dep +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT DELETE - -mainspaceparser.o: mainspaceparser.h ../space/space.h ../textstream/types.h -mainspaceparser.o: ../convert/inttostr.h ../utf8/utf8.h -mainspaceparser.o: ../textstream/textstream.h ../date/date.h -mainspaceparser.o: ../membuffer/membuffer.h ../textstream/types.h -mainspaceparser.o: ../utf8/utf8_templates.h ../utf8/utf8_private.h diff --git a/mainspaceparser/Makefile.o.dep b/mainspaceparser/Makefile.o.dep deleted file mode 100644 index 029147f..0000000 --- a/mainspaceparser/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = mainspaceparser.o \ No newline at end of file diff --git a/space/Makefile b/space/Makefile deleted file mode 100644 index fc2ffe6..0000000 --- a/space/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=space.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/space/Makefile.dep b/space/Makefile.dep deleted file mode 100644 index 0c75896..0000000 --- a/space/Makefile.dep +++ /dev/null @@ -1,27 +0,0 @@ -# DO NOT DELETE - -jsontospaceparser.o: jsontospaceparser.h space.h ../textstream/types.h -jsontospaceparser.o: ../convert/inttostr.h ../utf8/utf8.h -jsontospaceparser.o: ../textstream/textstream.h ../space/space.h -jsontospaceparser.o: ../date/date.h ../membuffer/membuffer.h -jsontospaceparser.o: ../textstream/types.h ../utf8/utf8_templates.h -jsontospaceparser.o: ../utf8/utf8_private.h ../convert/strtoint.h -jsontospaceparser.o: ../convert/text.h ../convert/misc.h -main.o: space.h ../textstream/types.h ../convert/inttostr.h ../utf8/utf8.h -main.o: ../textstream/textstream.h ../space/space.h ../date/date.h -main.o: ../membuffer/membuffer.h ../textstream/types.h -main.o: ../utf8/utf8_templates.h ../utf8/utf8_private.h -main.o: ../space/jsontospaceparser.h -space.o: space.h ../textstream/types.h ../convert/inttostr.h ../utf8/utf8.h -space.o: ../textstream/textstream.h ../space/space.h ../date/date.h -space.o: ../membuffer/membuffer.h ../textstream/types.h -space.o: ../utf8/utf8_templates.h ../utf8/utf8_private.h ../convert/convert.h -space.o: ../convert/inttostr.h ../convert/patternreplacer.h -space.o: ../convert/strtoint.h ../convert/text.h ../convert/misc.h -spaceparser.o: spaceparser.h space.h ../textstream/types.h -spaceparser.o: ../convert/inttostr.h ../utf8/utf8.h -spaceparser.o: ../textstream/textstream.h ../space/space.h ../date/date.h -spaceparser.o: ../membuffer/membuffer.h ../textstream/types.h -spaceparser.o: ../utf8/utf8_templates.h ../utf8/utf8_private.h -spacetojson.o: spacetojson.h space.h ../textstream/types.h -spacetojson.o: ../convert/inttostr.h diff --git a/space/Makefile.o.dep b/space/Makefile.o.dep deleted file mode 100644 index 0b7ca32..0000000 --- a/space/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = jsontospaceparser.o main.o space.o spaceparser.o spacetojson.o \ No newline at end of file diff --git a/utf8/Makefile b/utf8/Makefile deleted file mode 100644 index 33c71a6..0000000 --- a/utf8/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include Makefile.o.dep - -libname=utf8.a - -all: $(libname) - -$(libname): $(o) - $(AR) rcs $(libname) $(o) - - -%.o: %.cpp - $(CXX) -c $(CXXFLAGS) -I.. $< - - - -depend: - makedepend -Y. -I.. -f- *.cpp > Makefile.dep - echo -n "o = " > Makefile.o.dep - ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep - - -clean: - rm -f *.o - rm -f $(libname) - - -include Makefile.dep diff --git a/utf8/Makefile.dep b/utf8/Makefile.dep deleted file mode 100644 index 3808a63..0000000 --- a/utf8/Makefile.dep +++ /dev/null @@ -1,9 +0,0 @@ -# DO NOT DELETE - -utf8_private.o: utf8_private.h ../textstream/textstream.h ../space/space.h -utf8_private.o: ../textstream/types.h ../convert/inttostr.h ../date/date.h -utf8_private.o: ../membuffer/membuffer.h ../textstream/types.h -utf8.o: utf8.h ../textstream/textstream.h ../space/space.h -utf8.o: ../textstream/types.h ../convert/inttostr.h ../date/date.h -utf8.o: ../membuffer/membuffer.h ../textstream/types.h -utf8.o: ../utf8/utf8_templates.h utf8_private.h diff --git a/utf8/Makefile.o.dep b/utf8/Makefile.o.dep deleted file mode 100644 index b58ce53..0000000 --- a/utf8/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = utf8_private.o utf8.o \ No newline at end of file