commit belr for openSUSE:Factory
Hello community, here is the log from the commit of package belr for openSUSE:Factory checked in at 2017-08-30 16:21:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/belr (Old) and /work/SRC/openSUSE:Factory/.belr.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "belr" Wed Aug 30 16:21:30 2017 rev:3 rq:511975 version:0.1.3 Changes: -------- --- /work/SRC/openSUSE:Factory/belr/belr.changes 2017-07-03 09:36:51.515631975 +0200 +++ /work/SRC/openSUSE:Factory/.belr.new/belr.changes 2017-08-30 16:21:31.467658078 +0200 @@ -1,0 +2,7 @@ +Fri Jul 21 12:20:04 UTC 2017 - sor.alexei@meowr.ru + +- Update to version 0.1.3: + * Bug fixes. +- Remove belr-0.1.2-fix-includedir.patch: fixed upstream. + +------------------------------------------------------------------- Old: ---- belr-0.1.2-fix-includedir.patch belr-0.1.2.tar.gz New: ---- belr-0.1.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ belr.spec ++++++ --- /var/tmp/diff_new_pack.XUJuVq/_old 2017-08-30 16:21:32.419524186 +0200 +++ /var/tmp/diff_new_pack.XUJuVq/_new 2017-08-30 16:21:32.423523623 +0200 @@ -19,7 +19,7 @@ %define soname libbelr %define sover 1 Name: belr -Version: 0.1.2 +Version: 0.1.3 Release: 0 Summary: Language recognition library License: GPL-3.0+ @@ -29,12 +29,10 @@ Source1: baselibs.conf # PATCH-FIX-OPENSUSE belr-fix-pkgconfig.patch sor.alexei@meowr.ru -- Install belr.pc. Patch0: belr-fix-pkgconfig.patch -# PATCH-FIX-UPSTREAM belr-0.1.2-fix-includedir.patch -- Fix includedir (from commit a515fda). -Patch1: belr-0.1.2-fix-includedir.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: pkgconfig -BuildRequires: pkgconfig(bctoolbox) +BuildRequires: pkgconfig(bctoolbox) >= 0.6.0 %description Belr parses input formatted according to a language defined by an @@ -61,9 +59,8 @@ to develop applications using the belr library. %prep -%setup -q +%setup -q -n %{name}-%{version}-0 %patch0 -p1 -%patch1 -p1 %build %cmake \ @@ -79,12 +76,10 @@ %postun -n %{soname}%{sover} -p /sbin/ldconfig %files -n %{soname}%{sover} -%defattr(-,root,root) %doc COPYING %{_libdir}/%{soname}.so.%{sover}* %files devel -%defattr(-,root,root) %doc COPYING NEWS README.md %{_bindir}/belr-parse %{_includedir}/%{name}/ ++++++ belr-0.1.2.tar.gz -> belr-0.1.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/CMakeLists.txt new/belr-0.1.3-0/CMakeLists.txt --- old/belr-0.1.2/CMakeLists.txt 2017-03-02 14:41:18.000000000 +0100 +++ new/belr-0.1.3-0/CMakeLists.txt 2017-07-20 15:55:35.000000000 +0200 @@ -21,7 +21,7 @@ ############################################################################ cmake_minimum_required(VERSION 3.0) -project(BELR VERSION 0.1.2 LANGUAGES C CXX) +project(BELR VERSION 0.1.3 LANGUAGES C CXX) set(BELR_SO_VERSION "1") @@ -31,22 +31,6 @@ option(ENABLE_TOOLS "Turn on or off compilation of tools." YES) -macro(apply_compile_flags SOURCE_FILES) - if(${SOURCE_FILES}) - set(options "") - foreach(a ${ARGV}) - if(STRICT_OPTIONS_${a}) - string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}") - set(options "${options} ${options_${a}}") - endif() - endforeach() - if(options) - set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}") - endif() - endif() -endmacro() - - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX) @@ -76,7 +60,6 @@ include_directories( include/ src/ - ${BCTOOLBOX_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ) if(MSVC) @@ -113,6 +96,16 @@ list(REMOVE_DUPLICATES STRICT_OPTIONS_C) endif() +set(BELR_CPPFLAGS ${BCTOOLBOX_CPPFLAGS}) +if(ENABLE_STATIC) + list(APPEND BELR_CPPFLAGS "-DBELR_STATIC") +endif() +if(BELR_CPPFLAGS) + list(REMOVE_DUPLICATES BELR_CPPFLAGS) + add_definitions(${BELR_CPPFLAGS}) +endif() +add_definitions("-DBELR_EXPORTS") + if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) set(EXPORT_TARGETS_NAME "LinphoneBuilder") else() @@ -143,15 +136,4 @@ DESTINATION ${ConfigPackageLocation} ) - -# CPack settings -set(CPACK_PACKAGE_NAME "belr") -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) -set(CPACK_SOURCE_GENERATOR "TGZ") -set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") -set(CPACK_SOURCE_IGNORE_FILES - "^${CMAKE_BINARY_DIR}" - "/\\\\..+" -) - -include(CPack) +add_subdirectory(build) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/NEWS new/belr-0.1.3-0/NEWS --- old/belr-0.1.2/NEWS 2017-02-23 17:36:20.000000000 +0100 +++ new/belr-0.1.3-0/NEWS 2017-07-20 15:55:35.000000000 +0200 @@ -1,3 +1,6 @@ +belr-0.1.3 -- July 19th, 2017 + * Bug fixes + belr-0.1.2 -- February 23th, 2017 * Bug fixes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/README.md new/belr-0.1.3-0/README.md --- old/belr-0.1.2/README.md 2017-02-23 17:36:20.000000000 +0100 +++ new/belr-0.1.3-0/README.md 2017-07-20 15:55:35.000000000 +0200 @@ -41,6 +41,15 @@ To ensure that the installed binaries are striped of any rpath, use `-DCMAKE_SKIP_INSTALL_RPATH=ON` while you invoke cmake. +Rpm packaging +belr can be generated with cmake3 using the following command: +mkdir WORK +cd WORK +cmake3 ../ +make package_source +rpmbuild -ta --clean --rmsource --rmspec belr-<version>-<release>.tar.gz + + ----------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/belr.spec new/belr-0.1.3-0/belr.spec --- old/belr-0.1.2/belr.spec 1970-01-01 01:00:00.000000000 +0100 +++ new/belr-0.1.3-0/belr.spec 2017-07-21 10:26:44.000000000 +0200 @@ -0,0 +1,94 @@ +# -*- rpm-spec -*- + +## rpmbuild options +# These 2 lines are here because we can build the RPM for flexisip, in which +# case we prefix the entire installation so that we don't break compatibility +# with the user's libs. +# To compile with bc prefix, use rpmbuild -ba --with bc [SPEC] +%define pkg_name belr + +# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir +# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros +%define _datarootdir %{_prefix}/share +%define _datadir %{_datarootdir} +%define _docdir %{_datadir}/doc + +%define build_number 0 + + + +Name: %{pkg_name} +Version: 0.1.3 +Release: %{build_number}%{?dist} +Summary: Belr is language recognition library for ABNF based protocols. + +Group: Applications/Communications +License: GPL +URL: http://www.linphone.org +Source0: %{name}-%{version}-%{build_number}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +%description + +Belr is Belledonne Communications' language recognition library. +It aims at parsing any input formatted according to a language defined by an ABNF grammar, +such as the protocols standardized at IETF. + +It is based on finite state machine theory and heavily relies on recursivity from an implementation standpoint. + + +%package devel +Summary: Development libraries for belr +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Libraries and headers required to develop software with belr + +%if 0%{?rhel} && 0%{?rhel} <= 7 +%global cmake_name cmake3 +%define ctest_name ctest3 +%else +%global cmake_name cmake +%define ctest_name ctest +%endif + +%prep +%setup -n %{name}-%{version}-%build_number + +%build +%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix} +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} + +%check +%{ctest_name} -V %{?_smp_mflags} + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%defattr(-,root,root) +%doc AUTHORS ChangeLog COPYING NEWS README.md +%{_libdir}/*.so.* + +%files devel +%defattr(-,root,root) +%{_includedir}/belr +%{_libdir}/libbelr.a +%{_libdir}/libbelr.so +%{_datadir}/Belr/cmake/BelrConfig.cmake +%{_datadir}/Belr/cmake/BelrTargets-noconfig.cmake +%{_datadir}/Belr/cmake/BelrTargets.cmake +%{_bindir}/* + +%changelog +* Wed Jul 19 2017 jehan.monnier <jehan.monnier@linphone.org> +- Initial RPM release. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/build/CMakeLists.txt new/belr-0.1.3-0/build/CMakeLists.txt --- old/belr-0.1.2/build/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/belr-0.1.3-0/build/CMakeLists.txt 2017-07-20 15:55:35.000000000 +0200 @@ -0,0 +1,50 @@ +############################################################################ +# CMakeLists.txt +# Copyright (C) 2017 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ + +if (NOT CPACK_PACKAGE_NAME) + set(CPACK_PACKAGE_NAME "belr") +ENDIF() + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../COPYING") + +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) + +set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}) + +set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_SOURCE_IGNORE_FILES +"${CMAKE_BINARY_DIR}" +"^${PROJECT_SOURCE_DIR}/.git*" +) +bc_project_build_version(${PROJECT_VERSION} PROJECT_VERSION_BUILD) + +set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_BUILD}") + +message("-- Package file name is ${CPACK_PACKAGE_FILE_NAME}" ) + +set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rpm/belr.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/../belr.spec) + +include(CPack) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/build/rpm/belr.spec.in new/belr-0.1.3-0/build/rpm/belr.spec.in --- old/belr-0.1.2/build/rpm/belr.spec.in 1970-01-01 01:00:00.000000000 +0100 +++ new/belr-0.1.3-0/build/rpm/belr.spec.in 2017-07-20 15:55:35.000000000 +0200 @@ -0,0 +1,94 @@ +# -*- rpm-spec -*- + +## rpmbuild options +# These 2 lines are here because we can build the RPM for flexisip, in which +# case we prefix the entire installation so that we don't break compatibility +# with the user's libs. +# To compile with bc prefix, use rpmbuild -ba --with bc [SPEC] +%define pkg_name belr + +# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir +# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros +%define _datarootdir %{_prefix}/share +%define _datadir %{_datarootdir} +%define _docdir %{_datadir}/doc + +%define build_number @PROJECT_VERSION_BUILD@ + + + +Name: %{pkg_name} +Version: @PROJECT_VERSION@ +Release: %{build_number}%{?dist} +Summary: Belr is language recognition library for ABNF based protocols. + +Group: Applications/Communications +License: GPL +URL: http://www.linphone.org +Source0: %{name}-%{version}-%{build_number}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +%description + +Belr is Belledonne Communications' language recognition library. +It aims at parsing any input formatted according to a language defined by an ABNF grammar, +such as the protocols standardized at IETF. + +It is based on finite state machine theory and heavily relies on recursivity from an implementation standpoint. + + +%package devel +Summary: Development libraries for belr +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Libraries and headers required to develop software with belr + +%if 0%{?rhel} && 0%{?rhel} <= 7 +%global cmake_name cmake3 +%define ctest_name ctest3 +%else +%global cmake_name cmake +%define ctest_name ctest +%endif + +%prep +%setup -n %{name}-%{version}-%build_number + +%build +%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix} +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} + +%check +%{ctest_name} -V %{?_smp_mflags} + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%defattr(-,root,root) +%doc AUTHORS ChangeLog COPYING NEWS README.md +%{_libdir}/*.so.* + +%files devel +%defattr(-,root,root) +%{_includedir}/belr +%{_libdir}/libbelr.a +%{_libdir}/libbelr.so +%{_datadir}/Belr/cmake/BelrConfig.cmake +%{_datadir}/Belr/cmake/BelrTargets-noconfig.cmake +%{_datadir}/Belr/cmake/BelrTargets.cmake +%{_bindir}/* + +%changelog +* Wed Jul 19 2017 jehan.monnier <jehan.monnier@linphone.org> +- Initial RPM release. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/cmake/BelrConfig.cmake.in new/belr-0.1.3-0/cmake/BelrConfig.cmake.in --- old/belr-0.1.2/cmake/BelrConfig.cmake.in 2017-03-02 14:41:18.000000000 +0100 +++ new/belr-0.1.3-0/cmake/BelrConfig.cmake.in 2017-07-13 10:25:50.000000000 +0200 @@ -26,22 +26,36 @@ # BELR_FOUND - system has belr # BELR_INCLUDE_DIRS - the belr include directory # BELR_LIBRARIES - The libraries needed to use belr +# BELR_CPPFLAGS - The compilation flags needed to use belr if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) include("${CMAKE_CURRENT_LIST_DIR}/BelrTargets.cmake") endif() -get_filename_component(BELR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) - set(BELR_INCLUDE_DIRS "${EP_belr_INCLUDE_DIR}") +if(@ENABLE_SHARED@) + set(BELR_TARGETNAME belr) + set(BELR_LIBRARIES ${BELR_TARGETNAME}) else() - set(BELR_INCLUDE_DIRS "${BELR_CMAKE_DIR}/../../../include") + set(BELR_TARGETNAME belr-static) + if(TARGET ${BELR_TARGETNAME}) + if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) + set(BELR_LIBRARIES ${BELR_TARGETNAME}) + else() + get_target_property(BELR_LIBRARIES ${BELR_TARGETNAME} LOCATION) + endif() + get_target_property(BELR_LINK_LIBRARIES ${BELR_TARGETNAME} INTERFACE_LINK_LIBRARIES) + if(BELR_LINK_LIBRARIES) + list(APPEND BELR_LIBRARIES ${BELR_LINK_LIBRARIES}) + endif() + endif() endif() - -if(@ENABLE_SHARED@) - set(BELR_LIBRARIES belr) +get_target_property(BELR_INCLUDE_DIRS ${BELR_TARGETNAME} INTERFACE_INCLUDE_DIRECTORIES) +if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) + list(INSERT BELR_INCLUDE_DIRS 0 "${EP_belr_INCLUDE_DIR}") else() - set(BELR_LIBRARIES belr-static) + list(INSERT BELR_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@") endif() +list(REMOVE_DUPLICATES BELR_INCLUDE_DIRS) +set(BELR_CPPFLAGS @BELR_CPPFLAGS@) set(BELR_FOUND 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/include/belr/belr.hh new/belr-0.1.3-0/include/belr/belr.hh --- old/belr-0.1.2/include/belr/belr.hh 2017-03-02 14:41:18.000000000 +0100 +++ new/belr-0.1.3-0/include/belr/belr.hh 2017-07-13 15:18:22.000000000 +0200 @@ -6,17 +6,24 @@ #include <map> #include <memory> -using namespace ::std; -#if defined(_MSC_VER) -#define BELR_PUBLIC __declspec(dllexport) +#ifdef _MSC_VER + #ifdef BELR_STATIC + #define BELR_PUBLIC + #else + #ifdef BELR_EXPORTS + #define BELR_PUBLIC __declspec(dllexport) + #else + #define BELR_PUBLIC __declspec(dllimport) + #endif + #endif #else -#define BELR_PUBLIC + #define BELR_PUBLIC #endif namespace belr{ -BELR_PUBLIC string tolower(const string &str); +BELR_PUBLIC std::string tolower(const std::string &str); class ParserContextBase; @@ -28,11 +35,11 @@ bool mPossibleChars[256]; }; -class Recognizer : public enable_shared_from_this<Recognizer>{ +class Recognizer : public std::enable_shared_from_this<Recognizer>{ public: - void setName(const string &name); - const string &getName()const; - BELR_PUBLIC size_t feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); + void setName(const std::string &name); + const std::string &getName()const; + BELR_PUBLIC size_t feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); unsigned int getId()const{ return mId; } @@ -45,8 +52,8 @@ virtual bool _getTransitionMap(TransitionMap *mask); virtual void _optimize(int recursionLevel)=0; Recognizer(); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos)=0; - string mName; + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos)=0; + std::string mName; unsigned int mId; }; @@ -55,7 +62,7 @@ CharRecognizer(int to_recognize, bool caseSensitive=false); private: virtual void _optimize(int recursionLevel); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); int mToRecognize; bool mCaseSensitive; }; @@ -63,13 +70,13 @@ class Selector : public Recognizer{ public: Selector(); - shared_ptr<Selector> addRecognizer(const shared_ptr<Recognizer> &element); + std::shared_ptr<Selector> addRecognizer(const std::shared_ptr<Recognizer> &element); protected: virtual void _optimize(int recursionLevel); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); - size_t _feedExclusive(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); + size_t _feedExclusive(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); virtual bool _getTransitionMap(TransitionMap *mask); - list<shared_ptr<Recognizer>> mElements; + std::list<std::shared_ptr<Recognizer>> mElements; bool mIsExclusive; }; @@ -78,41 +85,41 @@ public: ExclusiveSelector(); private: - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); }; class Sequence : public Recognizer{ public: Sequence(); - shared_ptr<Sequence> addRecognizer(const shared_ptr<Recognizer> &element); + std::shared_ptr<Sequence> addRecognizer(const std::shared_ptr<Recognizer> &element); virtual bool _getTransitionMap(TransitionMap *mask); protected: virtual void _optimize(int recursionLevel); private: - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); - list<shared_ptr<Recognizer>> mElements; + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); + std::list<std::shared_ptr<Recognizer>> mElements; }; class Loop : public Recognizer{ public: Loop(); - shared_ptr<Loop> setRecognizer(const shared_ptr<Recognizer> &element, int min=0, int max=-1); + std::shared_ptr<Loop> setRecognizer(const std::shared_ptr<Recognizer> &element, int min=0, int max=-1); virtual bool _getTransitionMap(TransitionMap *mask); protected: virtual void _optimize(int recursionLevel); private: - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); - shared_ptr<Recognizer> mRecognizer; + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); + std::shared_ptr<Recognizer> mRecognizer; int mMin, mMax; }; class Foundation{ public: - static shared_ptr<CharRecognizer> charRecognizer(int character, bool caseSensitive=false); - static shared_ptr<Selector> selector(bool isExclusive=false); - static shared_ptr<Sequence> sequence(); - static shared_ptr<Loop> loop(); + static std::shared_ptr<CharRecognizer> charRecognizer(int character, bool caseSensitive=false); + static std::shared_ptr<Selector> selector(bool isExclusive=false); + static std::shared_ptr<Sequence> sequence(); + static std::shared_ptr<Loop> loop(); }; /*this is an optimization of a selector with multiple individual char recognizer*/ @@ -121,36 +128,36 @@ CharRange(int begin, int end); private: virtual void _optimize(int recursionLevel); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); int mBegin,mEnd; }; class Literal : public Recognizer{ public: - Literal(const string &lit); + Literal(const std::string &lit); virtual bool _getTransitionMap(TransitionMap *mask); private: virtual void _optimize(int recursionLevel); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); - string mLiteral; + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); + std::string mLiteral; size_t mLiteralSize; }; class Utils{ public: - static shared_ptr<Recognizer> literal(const string & lt); - static shared_ptr<Recognizer> char_range(int begin, int end); + static std::shared_ptr<Recognizer> literal(const std::string & lt); + static std::shared_ptr<Recognizer> char_range(int begin, int end); }; class RecognizerPointer : public Recognizer{ public: RecognizerPointer(); - shared_ptr<Recognizer> getPointed(); - void setPointed(const shared_ptr<Recognizer> &r); + std::shared_ptr<Recognizer> getPointed(); + void setPointed(const std::shared_ptr<Recognizer> &r); private: virtual void _optimize(int recursionLevel); - virtual size_t _feed(const shared_ptr<ParserContextBase> &ctx, const string &input, size_t pos); - shared_ptr<Recognizer> mRecognizer; + virtual size_t _feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos); + std::shared_ptr<Recognizer> mRecognizer; }; /** @@ -161,14 +168,14 @@ /** * Initialize an empty grammar, giving a name for debugging. **/ - BELR_PUBLIC Grammar(const string &name); + BELR_PUBLIC Grammar(const std::string &name); BELR_PUBLIC ~Grammar(); /** * Include another grammar into this grammar. **/ - BELR_PUBLIC void include(const shared_ptr<Grammar>& grammar); + BELR_PUBLIC void include(const std::shared_ptr<Grammar>& grammar); /** * Add arule to the grammar. * @param name the name of the rule @@ -178,7 +185,7 @@ * TODO: use unique_ptr to enforce this, or make a copy ? **/ template <typename _recognizerT> - shared_ptr<_recognizerT> addRule(const string & name, const shared_ptr<_recognizerT> &rule){ + std::shared_ptr<_recognizerT> addRule(const std::string & name, const std::shared_ptr<_recognizerT> &rule){ assignRule(name, rule); return rule; } @@ -190,7 +197,7 @@ * @return the rule. **/ template <typename _recognizerT> - shared_ptr<_recognizerT> extendRule(const string & name, const shared_ptr<_recognizerT> &rule){ + std::shared_ptr<_recognizerT> extendRule(const std::string & name, const std::shared_ptr<_recognizerT> &rule){ _extendRule(name, rule); return rule; } @@ -199,7 +206,7 @@ * @param name the name of the rule * @return the recognizer implementing this rule. Is NULL if the rule doesn't exist in the grammar. **/ - BELR_PUBLIC shared_ptr<Recognizer> findRule(const string &name); + BELR_PUBLIC std::shared_ptr<Recognizer> findRule(const std::string &name); /** * Find a rule from the grammar, given its name. * Unlike findRule(), getRule() never returns NULL. @@ -208,7 +215,7 @@ * @param name the name of the rule to get * @return the recognizer implementing the rule, or a RecognizerPointer if the rule isn't yet defined. **/ - BELR_PUBLIC shared_ptr<Recognizer> getRule(const string &name); + BELR_PUBLIC std::shared_ptr<Recognizer> getRule(const std::string &name); /** * Returns true if the grammar is complete, that is all rules are defined. * In other words, a grammar is complete if no rule depends on another rule which is not defined. @@ -226,11 +233,11 @@ **/ int getNumRules()const; private: - void assignRule(const string &name, const shared_ptr<Recognizer> &rule); - void _extendRule(const string &name, const shared_ptr<Recognizer> &rule); - map<string,shared_ptr<Recognizer>> mRules; - list<shared_ptr<RecognizerPointer>> mRecognizerPointers; - string mName; + void assignRule(const std::string &name, const std::shared_ptr<Recognizer> &rule); + void _extendRule(const std::string &name, const std::shared_ptr<Recognizer> &rule); + std::map<std::string,std::shared_ptr<Recognizer>> mRules; + std::list<std::shared_ptr<RecognizerPointer>> mRecognizerPointers; + std::string mName; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/include/belr/grammarbuilder.hh new/belr-0.1.3-0/include/belr/grammarbuilder.hh --- old/belr-0.1.2/include/belr/grammarbuilder.hh 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/include/belr/grammarbuilder.hh 2017-07-13 10:25:50.000000000 +0200 @@ -12,118 +12,118 @@ class ABNFBuilder{ public: virtual ~ABNFBuilder(); - virtual shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar)=0; + virtual std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar)=0; }; class ABNFRule : public ABNFBuilder{ public: ABNFRule(); - static shared_ptr<ABNFRule> create(); - void setName(const string &name); - void setDefinedAs(const string &defined_as); - void setAlternation(const shared_ptr<ABNFAlternation> &a); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); + static std::shared_ptr<ABNFRule> create(); + void setName(const std::string &name); + void setDefinedAs(const std::string &defined_as); + void setAlternation(const std::shared_ptr<ABNFAlternation> &a); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); bool isExtension()const; - const string &getName()const{ + const std::string &getName()const{ return mName; } private: - shared_ptr<ABNFAlternation> mAlternation; - string mName; - string mDefinedAs; + std::shared_ptr<ABNFAlternation> mAlternation; + std::string mName; + std::string mDefinedAs; }; class ABNFRuleList : public ABNFBuilder{ public: - static shared_ptr<ABNFRuleList> create(); - void addRule(const shared_ptr<ABNFRule> & rule); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); + static std::shared_ptr<ABNFRuleList> create(); + void addRule(const std::shared_ptr<ABNFRule> & rule); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); private: - list<shared_ptr<ABNFRule>> mRules; + std::list<std::shared_ptr<ABNFRule>> mRules; }; class ABNFNumval : public ABNFBuilder{ public: ABNFNumval(); - static shared_ptr<ABNFNumval> create(); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); - void setDecVal(const string &decval); - void setHexVal(const string &hexval); - void setBinVal(const string &binval); + static std::shared_ptr<ABNFNumval> create(); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); + void setDecVal(const std::string &decval); + void setHexVal(const std::string &hexval); + void setBinVal(const std::string &binval); private: - void parseValues(const string &val, int base); - vector<int> mValues; + void parseValues(const std::string &val, int base); + std::vector<int> mValues; bool mIsRange; }; class ABNFElement : public ABNFBuilder{ public: ABNFElement(); - static shared_ptr<ABNFElement> create(); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); - void setElement(const shared_ptr<ABNFBuilder> &e); - void setRulename(const string &rulename); - void setCharVal(const string &charval); - void setProseVal(const string &prose); -private: - shared_ptr<ABNFBuilder> mElement; - string mRulename; - string mCharVal; + static std::shared_ptr<ABNFElement> create(); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); + void setElement(const std::shared_ptr<ABNFBuilder> &e); + void setRulename(const std::string &rulename); + void setCharVal(const std::string &charval); + void setProseVal(const std::string &prose); +private: + std::shared_ptr<ABNFBuilder> mElement; + std::string mRulename; + std::string mCharVal; }; class ABNFGroup : public ABNFBuilder{ public: ABNFGroup(); - static shared_ptr<ABNFGroup> create(); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); - void setAlternation(const shared_ptr<ABNFAlternation> &a); + static std::shared_ptr<ABNFGroup> create(); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); + void setAlternation(const std::shared_ptr<ABNFAlternation> &a); private: - shared_ptr<ABNFAlternation> mAlternation; + std::shared_ptr<ABNFAlternation> mAlternation; }; class ABNFRepetition : public ABNFBuilder{ public: ABNFRepetition(); - static shared_ptr<ABNFRepetition> create(); - void setRepeat(const string &r); + static std::shared_ptr<ABNFRepetition> create(); + void setRepeat(const std::string &r); void setMin(int min); void setMax(int max); void setCount(int count); - void setElement(const shared_ptr<ABNFElement> &e); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); + void setElement(const std::shared_ptr<ABNFElement> &e); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); private: int mMin, mMax, mCount; - string mRepeat; - shared_ptr<ABNFElement> mElement; + std::string mRepeat; + std::shared_ptr<ABNFElement> mElement; }; class ABNFOption : public ABNFBuilder{ public: ABNFOption(); - static shared_ptr<ABNFOption> create(); - void setAlternation(const shared_ptr<ABNFAlternation> &a); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); + static std::shared_ptr<ABNFOption> create(); + void setAlternation(const std::shared_ptr<ABNFAlternation> &a); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); private: - shared_ptr<ABNFAlternation> mAlternation; + std::shared_ptr<ABNFAlternation> mAlternation; }; class ABNFConcatenation : public ABNFBuilder{ public: - static shared_ptr<ABNFConcatenation> create(); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); - void addRepetition(const shared_ptr<ABNFRepetition> &r); + static std::shared_ptr<ABNFConcatenation> create(); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); + void addRepetition(const std::shared_ptr<ABNFRepetition> &r); private: - list<shared_ptr<ABNFRepetition>> mRepetitions; + std::list<std::shared_ptr<ABNFRepetition>> mRepetitions; }; class ABNFAlternation : public ABNFBuilder{ public: - static shared_ptr<ABNFAlternation> create(); - void addConcatenation(const shared_ptr<ABNFConcatenation> &c); - shared_ptr<Recognizer> buildRecognizer(const shared_ptr<Grammar> &grammar); - shared_ptr<Recognizer> buildRecognizerNoOptim(const shared_ptr<Grammar> &grammar); + static std::shared_ptr<ABNFAlternation> create(); + void addConcatenation(const std::shared_ptr<ABNFConcatenation> &c); + std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar); + std::shared_ptr<Recognizer> buildRecognizerNoOptim(const std::shared_ptr<Grammar> &grammar); private: - list<shared_ptr<ABNFConcatenation>> mConcatenations; + std::list<std::shared_ptr<ABNFConcatenation>> mConcatenations; }; /** @@ -145,7 +145,7 @@ * @param grammar an optional grammar to include. * @return the Grammar object corresponding to the text definition loaded, NULL if an error occured. **/ - BELR_PUBLIC shared_ptr<Grammar> createFromAbnf(const string &abnf, const shared_ptr<Grammar> &grammar=NULL); + BELR_PUBLIC std::shared_ptr<Grammar> createFromAbnf(const std::string &abnf, const std::shared_ptr<Grammar> &grammar=NULL); /** * Create a grammar from an ABNF grammar defined in the text file pointed by path. * An optional Grammar argument corresponding to a grammar to include can be passed. @@ -156,9 +156,9 @@ * @param grammar an optional grammar to include. * @return the Grammar object corresponding to the text definition loaded, NULL if an error occured. **/ - BELR_PUBLIC shared_ptr<Grammar> createFromAbnfFile(const string &path, const shared_ptr<Grammar> &grammar=NULL); + BELR_PUBLIC std::shared_ptr<Grammar> createFromAbnfFile(const std::string &path, const std::shared_ptr<Grammar> &grammar=NULL); private: - Parser<shared_ptr<ABNFBuilder>> mParser; + Parser<std::shared_ptr<ABNFBuilder>> mParser; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/include/belr/parser-impl.cc new/belr-0.1.3-0/include/belr/parser-impl.cc --- old/belr-0.1.2/include/belr/parser-impl.cc 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/include/belr/parser-impl.cc 2017-07-13 10:25:50.000000000 +0200 @@ -5,7 +5,9 @@ //#include <chrono> #include <ctime> -namespace belr{ + +using namespace std; +using namespace belr; template <class T, class U> T universal_pointer_cast(const shared_ptr<U>& sp){ @@ -332,5 +334,3 @@ auto ret= pctx->createRootObject(input); return ret; } - -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/include/belr/parser.hh new/belr-0.1.3-0/include/belr/parser.hh --- old/belr-0.1.2/include/belr/parser.hh 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/include/belr/parser.hh 2017-07-13 10:25:50.000000000 +0200 @@ -7,7 +7,7 @@ #include "belr.hh" -namespace belr{ +namespace belr { template<typename _parserElementT> class AbstractCollector{ @@ -25,23 +25,23 @@ template <typename _derivedParserElementT, typename _parserElementT, typename _valueT> class ParserCollector : public CollectorBase<_parserElementT,_valueT>{ public: - ParserCollector(const function<void (_derivedParserElementT , _valueT)> &fn) : mFunc(fn){ + ParserCollector(const std::function<void (_derivedParserElementT , _valueT)> &fn) : mFunc(fn){ } virtual void invoke(_parserElementT obj, _valueT value); void invokeWithChild(_parserElementT obj, _parserElementT child); private: - function<void (_derivedParserElementT, _valueT)> mFunc; + std::function<void (_derivedParserElementT, _valueT)> mFunc; }; template <typename _derivedParserElementT, typename _parserElementT, typename _valueT> class ParserChildCollector : public CollectorBase<_parserElementT,_valueT>{ public: - ParserChildCollector(const function<void (_derivedParserElementT , _valueT)> &fn) : mFunc(fn){ + ParserChildCollector(const std::function<void (_derivedParserElementT , _valueT)> &fn) : mFunc(fn){ } virtual void invoke(_parserElementT obj, _valueT value); virtual void invokeWithChild(_parserElementT obj, _parserElementT child); private: - function<void (_derivedParserElementT, _valueT)> mFunc; + std::function<void (_derivedParserElementT, _valueT)> mFunc; }; template <typename _parserElementT> @@ -53,54 +53,54 @@ class HandlerContextBase; template <typename _parserElementT> -class ParserHandlerBase : public enable_shared_from_this<ParserHandlerBase<_parserElementT>>{ +class ParserHandlerBase : public std::enable_shared_from_this<ParserHandlerBase<_parserElementT>>{ friend class HandlerContext<_parserElementT>; public: - virtual _parserElementT invoke(const string &input, size_t begin, size_t count)=0; - shared_ptr<HandlerContext<_parserElementT>> createContext(); - const string &getRulename()const{ + virtual _parserElementT invoke(const std::string &input, size_t begin, size_t count)=0; + std::shared_ptr<HandlerContext<_parserElementT>> createContext(); + const std::string &getRulename()const{ return mRulename; } protected: - void releaseContext(const shared_ptr<HandlerContext<_parserElementT>> &ctx); - ParserHandlerBase(const Parser<_parserElementT> &parser, const string &name); - void installCollector(const string &rulename, const shared_ptr<AbstractCollector<_parserElementT>> &collector); - const shared_ptr<AbstractCollector<_parserElementT>> &getCollector(unsigned int rule_id)const; + void releaseContext(const std::shared_ptr<HandlerContext<_parserElementT>> &ctx); + ParserHandlerBase(const Parser<_parserElementT> &parser, const std::string &name); + void installCollector(const std::string &rulename, const std::shared_ptr<AbstractCollector<_parserElementT>> &collector); + const std::shared_ptr<AbstractCollector<_parserElementT>> &getCollector(unsigned int rule_id)const; private: - map<unsigned int, shared_ptr<AbstractCollector<_parserElementT>> > mCollectors; + std::map<unsigned int, std::shared_ptr<AbstractCollector<_parserElementT>> > mCollectors; const Parser<_parserElementT> &mParser; - string mRulename; - shared_ptr<HandlerContext<_parserElementT>> mCachedContext; + std::string mRulename; + std::shared_ptr<HandlerContext<_parserElementT>> mCachedContext; }; template <typename _derivedParserElementT, typename _parserElementT> class ParserHandler : public ParserHandlerBase<_parserElementT>{ public: - ParserHandler(const Parser<_parserElementT> &parser, const string &rulename, const function<_derivedParserElementT ()> &create) + ParserHandler(const Parser<_parserElementT> &parser, const std::string &rulename, const std::function<_derivedParserElementT ()> &create) : ParserHandlerBase<_parserElementT>(parser, rulename), mHandlerCreateFunc(create){ } - ParserHandler(const Parser<_parserElementT> &parser, const string &rulename, const function<_derivedParserElementT (const string &, const string &)> &create) + ParserHandler(const Parser<_parserElementT> &parser, const std::string &rulename, const std::function<_derivedParserElementT (const std::string &, const std::string &)> &create) : ParserHandlerBase<_parserElementT>(parser, rulename), mHandlerCreateDebugFunc(create){ } template <typename _derivedParserElementTChild> - shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const string &child_rule_name, function<void (_derivedParserElementTChild , const string & )> fn){ - this->installCollector(child_rule_name, make_shared<ParserCollector<_derivedParserElementT,_parserElementT,const string&>>(fn)); - return static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); + std::shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const std::string &child_rule_name, std::function<void (_derivedParserElementTChild , const std::string & )> fn){ + this->installCollector(child_rule_name, std::make_shared<ParserCollector<_derivedParserElementT,_parserElementT,const std::string&>>(fn)); + return std::static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); } template <typename _derivedParserElementTChild> - shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const string &child_rule_name, function<void (_derivedParserElementTChild , int )> fn){ - this->installCollector(child_rule_name, make_shared<ParserCollector<_derivedParserElementT,_parserElementT,int>>(fn)); - return static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); + std::shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const std::string &child_rule_name, std::function<void (_derivedParserElementTChild , int )> fn){ + this->installCollector(child_rule_name, std::make_shared<ParserCollector<_derivedParserElementT,_parserElementT,int>>(fn)); + return std::static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); } template <typename _derivedParserElementTChild, typename _valueT> - shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const string &child_rule_name, function<void (_derivedParserElementTChild , _valueT)> fn){ - this->installCollector(child_rule_name, make_shared<ParserChildCollector<_derivedParserElementT,_parserElementT,_valueT>>(fn)); - return static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); + std::shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setCollector(const std::string &child_rule_name, std::function<void (_derivedParserElementTChild , _valueT)> fn){ + this->installCollector(child_rule_name, std::make_shared<ParserChildCollector<_derivedParserElementT,_parserElementT,_valueT>>(fn)); + return std::static_pointer_cast<ParserHandler<_derivedParserElementT,_parserElementT>>(this->shared_from_this()); } - _parserElementT invoke(const string &input, size_t begin, size_t count); + _parserElementT invoke(const std::string &input, size_t begin, size_t count); private: - function<_derivedParserElementT ()> mHandlerCreateFunc; - function<_derivedParserElementT (const string &, const string &)> mHandlerCreateDebugFunc; + std::function<_derivedParserElementT ()> mHandlerCreateFunc; + std::function<_derivedParserElementT (const std::string &, const std::string &)> mHandlerCreateDebugFunc; }; template <typename _parserElementT> @@ -109,16 +109,16 @@ AbstractCollector<_parserElementT> * mCollector;//not a shared_ptr for optimization, the collector cannot disapear size_t mBegin; size_t mCount; - shared_ptr<HandlerContext<_parserElementT>> mChild; + std::shared_ptr<HandlerContext<_parserElementT>> mChild; public: - Assignment(const shared_ptr<AbstractCollector<_parserElementT>> &c, size_t begin, size_t count, const shared_ptr<HandlerContext<_parserElementT>> &child) + Assignment(const std::shared_ptr<AbstractCollector<_parserElementT>> &c, size_t begin, size_t count, const std::shared_ptr<HandlerContext<_parserElementT>> &child) : mCollector(c.get()), mBegin(begin), mCount(count), mChild(child) { } - void invoke(_parserElementT parent, const string &input); + void invoke(_parserElementT parent, const std::string &input); }; -class HandlerContextBase : public enable_shared_from_this<HandlerContextBase>{ +class HandlerContextBase : public std::enable_shared_from_this<HandlerContextBase>{ public: BELR_PUBLIC virtual ~HandlerContextBase(); }; @@ -126,61 +126,61 @@ template <typename _parserElementT> class HandlerContext : public HandlerContextBase{ public: - HandlerContext(const shared_ptr<ParserHandlerBase<_parserElementT>> &handler); - void setChild(unsigned int subrule_id, size_t begin, size_t count, const shared_ptr<HandlerContext> &child); - _parserElementT realize(const string &input, size_t begin, size_t count); - shared_ptr<HandlerContext<_parserElementT>> branch(); - void merge(const shared_ptr<HandlerContext<_parserElementT>> &other); + HandlerContext(const std::shared_ptr<ParserHandlerBase<_parserElementT>> &handler); + void setChild(unsigned int subrule_id, size_t begin, size_t count, const std::shared_ptr<HandlerContext> &child); + _parserElementT realize(const std::string &input, size_t begin, size_t count); + std::shared_ptr<HandlerContext<_parserElementT>> branch(); + void merge(const std::shared_ptr<HandlerContext<_parserElementT>> &other); size_t getLastIterator()const; void undoAssignments(size_t pos); void recycle(); private: ParserHandlerBase<_parserElementT> & mHandler; - vector<Assignment<_parserElementT>> mAssignments; + std::vector<Assignment<_parserElementT>> mAssignments; }; struct ParserLocalContext{ ParserLocalContext() : mHandlerContext(NULL), mRecognizer(NULL), mAssignmentPos(0) { } - void set(const shared_ptr<HandlerContextBase>& hc, const shared_ptr<Recognizer>& rec, size_t pos){ + void set(const std::shared_ptr<HandlerContextBase>& hc, const std::shared_ptr<Recognizer>& rec, size_t pos){ mHandlerContext=hc; mRecognizer=rec.get(); mAssignmentPos=pos; } - shared_ptr<HandlerContextBase> mHandlerContext; + std::shared_ptr<HandlerContextBase> mHandlerContext; Recognizer * mRecognizer; //not a shared ptr to optimize, the object can't disapear in the context of use of ParserLocalContext. size_t mAssignmentPos; }; class ParserContextBase{ public: - virtual void beginParse(ParserLocalContext &ctx, const shared_ptr<Recognizer> &rec)=0; - virtual void endParse(const ParserLocalContext &ctx, const string &input, size_t begin, size_t count)=0; - virtual shared_ptr<HandlerContextBase> branch()=0; - virtual void merge(const shared_ptr<HandlerContextBase> &other)=0; - virtual void removeBranch(const shared_ptr<HandlerContextBase> &other)=0; + virtual void beginParse(ParserLocalContext &ctx, const std::shared_ptr<Recognizer> &rec)=0; + virtual void endParse(const ParserLocalContext &ctx, const std::string &input, size_t begin, size_t count)=0; + virtual std::shared_ptr<HandlerContextBase> branch()=0; + virtual void merge(const std::shared_ptr<HandlerContextBase> &other)=0; + virtual void removeBranch(const std::shared_ptr<HandlerContextBase> &other)=0; }; template <typename _parserElementT> class ParserContext : public ParserContextBase{ public: ParserContext(Parser<_parserElementT> &parser); - _parserElementT createRootObject(const string &input); + _parserElementT createRootObject(const std::string &input); protected: - virtual void beginParse(ParserLocalContext &ctx, const shared_ptr<Recognizer> &rec); - virtual void endParse(const ParserLocalContext &ctx, const string &input, size_t begin, size_t count); - virtual shared_ptr<HandlerContextBase> branch(); - virtual void merge(const shared_ptr<HandlerContextBase> &other); - virtual void removeBranch(const shared_ptr<HandlerContextBase> &other); - void _beginParse(ParserLocalContext &ctx, const shared_ptr<Recognizer> &rec); - void _endParse(const ParserLocalContext &ctx, const string &input, size_t begin, size_t count); - shared_ptr<HandlerContext<_parserElementT>> _branch(); - void _merge(const shared_ptr<HandlerContext<_parserElementT>> &other); - void _removeBranch(const shared_ptr<HandlerContext<_parserElementT>> &other); + virtual void beginParse(ParserLocalContext &ctx, const std::shared_ptr<Recognizer> &rec); + virtual void endParse(const ParserLocalContext &ctx, const std::string &input, size_t begin, size_t count); + virtual std::shared_ptr<HandlerContextBase> branch(); + virtual void merge(const std::shared_ptr<HandlerContextBase> &other); + virtual void removeBranch(const std::shared_ptr<HandlerContextBase> &other); + void _beginParse(ParserLocalContext &ctx, const std::shared_ptr<Recognizer> &rec); + void _endParse(const ParserLocalContext &ctx, const std::string &input, size_t begin, size_t count); + std::shared_ptr<HandlerContext<_parserElementT>> _branch(); + void _merge(const std::shared_ptr<HandlerContext<_parserElementT>> &other); + void _removeBranch(const std::shared_ptr<HandlerContext<_parserElementT>> &other); private: Parser<_parserElementT> & mParser; - list<shared_ptr<HandlerContext<_parserElementT>>> mHandlerStack; - shared_ptr<HandlerContext<_parserElementT>> mRoot; + std::list<std::shared_ptr<HandlerContext<_parserElementT>>> mHandlerStack; + std::shared_ptr<HandlerContext<_parserElementT>> mRoot; }; /** @@ -195,71 +195,71 @@ friend class ParserContext<_parserElementT>; friend class ParserHandlerBase<_parserElementT>; public: - Parser(const shared_ptr<Grammar> &grammar); + Parser(const std::shared_ptr<Grammar> &grammar); template <typename _derivedParserElementT> - shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setHandler(const string &rulename,const function<_derivedParserElementT ()> & handler){ - auto ret=make_shared<ParserHandler<_derivedParserElementT,_parserElementT>>(*this, rulename,handler); + std::shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setHandler(const std::string &rulename,const std::function<_derivedParserElementT ()> & handler){ + auto ret=std::make_shared<ParserHandler<_derivedParserElementT,_parserElementT>>(*this, rulename,handler); installHandler(ret); return ret; } template <typename _derivedParserElementT> - shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setHandler(const string &rulename, - const function<_derivedParserElementT (const string &, const string &)> & handler){ - auto ret=make_shared<ParserHandler<_derivedParserElementT,_parserElementT>>(*this, rulename,handler); + std::shared_ptr<ParserHandler<_derivedParserElementT,_parserElementT>> setHandler(const std::string &rulename, + const std::function<_derivedParserElementT (const std::string &, const std::string &)> & handler){ + auto ret=std::make_shared<ParserHandler<_derivedParserElementT,_parserElementT>>(*this, rulename,handler); installHandler(ret); return ret; } - _parserElementT parseInput(const string &rulename, const string &input, size_t *parsed_size); + _parserElementT parseInput(const std::string &rulename, const std::string &input, size_t *parsed_size); private: - shared_ptr<ParserHandlerBase<_parserElementT>> &getHandler(unsigned int); - void installHandler(const shared_ptr<ParserHandlerBase<_parserElementT>> &handler); - shared_ptr<Grammar> mGrammar; - map<unsigned int, shared_ptr<ParserHandlerBase<_parserElementT>>> mHandlers; - shared_ptr<ParserHandlerBase<_parserElementT>> mNullHandler; - shared_ptr<AbstractCollector<_parserElementT>> mNullCollector; + std::shared_ptr<ParserHandlerBase<_parserElementT>> &getHandler(unsigned int); + void installHandler(const std::shared_ptr<ParserHandlerBase<_parserElementT>> &handler); + std::shared_ptr<Grammar> mGrammar; + std::map<unsigned int, std::shared_ptr<ParserHandlerBase<_parserElementT>>> mHandlers; + std::shared_ptr<ParserHandlerBase<_parserElementT>> mNullHandler; + std::shared_ptr<AbstractCollector<_parserElementT>> mNullCollector; }; class DebugElement{ public: - DebugElement(const string &rulename, const string &value); - static shared_ptr<DebugElement> create(const string &rulename, const string &value); - void addChild(const shared_ptr<DebugElement> &e); - BELR_PUBLIC ostream &tostream(int level, ostream &str)const; + DebugElement(const std::string &rulename, const std::string &value); + static std::shared_ptr<DebugElement> create(const std::string &rulename, const std::string &value); + void addChild(const std::shared_ptr<DebugElement> &e); + BELR_PUBLIC std::ostream &tostream(int level, std::ostream &str)const; private: - string mRulename; - string mValue; - list<shared_ptr<DebugElement>> mChildren; + std::string mRulename; + std::string mValue; + std::list<std::shared_ptr<DebugElement>> mChildren; }; -class DebugParser : protected Parser<shared_ptr<DebugElement>>{ +class DebugParser : protected Parser<std::shared_ptr<DebugElement>>{ public: - BELR_PUBLIC DebugParser(const shared_ptr<Grammar> &grammar); - BELR_PUBLIC void setObservedRules(const list<string> &rules); - BELR_PUBLIC shared_ptr<DebugElement> parseInput(const string &rulename, const string &input, size_t *parsed_size); + BELR_PUBLIC DebugParser(const std::shared_ptr<Grammar> &grammar); + BELR_PUBLIC void setObservedRules(const std::list<std::string> &rules); + BELR_PUBLIC std::shared_ptr<DebugElement> parseInput(const std::string &rulename, const std::string &input, size_t *parsed_size); }; template <typename _retT> -function< _retT ()> make_fn(_retT (*arg)()){ - return function<_retT ()>(arg); +std::function< _retT ()> make_fn(_retT (*arg)()){ + return std::function<_retT ()>(arg); } template <typename _retT, typename _arg1T, typename _arg2T> -function< _retT (_arg1T,_arg2T)> make_fn(_retT (*arg)(_arg1T,_arg2T)){ - return function< _retT (_arg1T,_arg2T)>(arg); +std::function< _retT (_arg1T,_arg2T)> make_fn(_retT (*arg)(_arg1T,_arg2T)){ + return std::function< _retT (_arg1T,_arg2T)>(arg); } template <typename _klassT, typename _argT> -function< void (_klassT*,_argT)> make_fn(void (_klassT::*arg)(_argT)){ - return function< void (_klassT*,_argT)>(mem_fn(arg)); +std::function< void (_klassT*,_argT)> make_fn(void (_klassT::*arg)(_argT)){ + return std::function< void (_klassT*,_argT)>(std::mem_fn(arg)); } template <typename _klassT, typename _argT> -function< void (shared_ptr<_klassT>,_argT)> make_sfn(void (_klassT::*arg)(_argT)){ - return function< void (shared_ptr<_klassT>,_argT)>(mem_fn(arg)); +std::function< void (std::shared_ptr<_klassT>,_argT)> make_sfn(void (_klassT::*arg)(_argT)){ + return std::function< void (std::shared_ptr<_klassT>,_argT)>(std::mem_fn(arg)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/src/CMakeLists.txt new/belr-0.1.3-0/src/CMakeLists.txt --- old/belr-0.1.2/src/CMakeLists.txt 2017-03-02 14:41:18.000000000 +0100 +++ new/belr-0.1.3-0/src/CMakeLists.txt 2017-07-13 10:25:50.000000000 +0200 @@ -29,13 +29,14 @@ parser.cc ) -apply_compile_flags(BELR_SOURCE_FILES_C "CPP" "C") -apply_compile_flags(BELR_SOURCE_FILES_CXX "CPP" "CXX") +bc_apply_compile_flags(BELR_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C) +bc_apply_compile_flags(BELR_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) if(ENABLE_STATIC) add_library(belr-static STATIC ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX}) set_target_properties(belr-static PROPERTIES OUTPUT_NAME belr) - target_link_libraries(belr-static ${BCTOOLBOX_CORE_LIBRARIES}) + target_include_directories(belr-static PUBLIC ${BCTOOLBOX_CORE_INCLUDE_DIRS}) + target_link_libraries(belr-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES}) endif() if(ENABLE_SHARED) add_library(belr SHARED ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX}) @@ -43,6 +44,7 @@ set_target_properties(belr PROPERTIES LINK_FLAGS "-stdlib=libc++") endif() set_target_properties(belr PROPERTIES VERSION ${BELR_SO_VERSION}) + target_include_directories(belr PUBLIC ${BCTOOLBOX_CORE_INCLUDE_DIRS}) target_link_libraries(belr PRIVATE ${BCTOOLBOX_CORE_LIBRARIES}) if(MSVC) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/src/abnf.cc new/belr-0.1.3-0/src/abnf.cc --- old/belr-0.1.2/src/abnf.cc 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/src/abnf.cc 2017-07-13 10:25:50.000000000 +0200 @@ -1,6 +1,7 @@ #include "belr/abnf.hh" -namespace belr{ +using namespace std; +using namespace belr; /* * CoreRules grammar @@ -556,6 +557,3 @@ ) ); } - -}//end of namespace - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/src/belr.cc new/belr-0.1.3-0/src/belr.cc --- old/belr-0.1.2/src/belr.cc 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/src/belr.cc 2017-07-13 15:18:22.000000000 +0200 @@ -5,7 +5,10 @@ #include <algorithm> #include <iostream> -namespace belr{ + +using namespace std; +using namespace belr; + TransitionMap::TransitionMap(){ for(size_t i=0;i<sizeof(mPossibleChars)/sizeof(bool);++i) @@ -40,7 +43,7 @@ Recognizer::Recognizer() : mId(0) { } -void Recognizer::setName(const string& name){ +void Recognizer::setName(const std::string& name){ static unsigned int id_base=0; mName=name; /* every recognizer that is given a name is given also a unique id*/ @@ -489,10 +492,9 @@ } -string tolower(const string &str){ +string belr::tolower(const string &str){ string ret(str); transform(ret.begin(),ret.end(), ret.begin(), ::tolower); return ret; } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/tools/CMakeLists.txt new/belr-0.1.3-0/tools/CMakeLists.txt --- old/belr-0.1.2/tools/CMakeLists.txt 2017-03-02 14:41:18.000000000 +0100 +++ new/belr-0.1.3-0/tools/CMakeLists.txt 2017-07-13 15:18:22.000000000 +0200 @@ -28,7 +28,7 @@ foreach(EXECTUABLE belr-parse belr-demo) set(SOURCE_FILES_CXX ${EXECTUABLE}.cc) - apply_compile_flags(SOURCE_FILES_CXX "CPP" "CXX") + bc_apply_compile_flags(SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) add_executable(${EXECTUABLE} ${SOURCE_FILES_CXX}) set_target_properties(${EXECTUABLE} PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(${EXECTUABLE} ${BELR_LIBRARIES_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/belr-0.1.2/tools/belr-parse.cc new/belr-0.1.3-0/tools/belr-parse.cc --- old/belr-0.1.2/tools/belr-parse.cc 2017-02-09 13:29:54.000000000 +0100 +++ new/belr-0.1.3-0/tools/belr-parse.cc 2017-07-13 10:25:50.000000000 +0200 @@ -11,7 +11,8 @@ #include <cstring> #include <cstdlib> -using namespace::belr; +using namespace belr; +using namespace std; int main(int argc, char *argv[]){ const char *file=NULL,*message_file=NULL;
participants (1)
-
root@hilbert.suse.de