From c1c6243c3e24c1ee017e6f04b72a0b476f27c3a4 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 16 May 2017 10:53:07 +0200 Subject: [PATCH 01/10] ENH: pass through doc/Allwmake arguments, add -config, -dir options - can run doxygen with an alternative Doxyfile, which is useful when verifying generated content for particular classes. Eg, PATH/doc/Allwmake -dir $PWD --- doc/Allwmake | 4 +-- doc/Doxygen/Allwmake | 58 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/doc/Allwmake b/doc/Allwmake index f6684e337c..57d993de84 100755 --- a/doc/Allwmake +++ b/doc/Allwmake @@ -1,9 +1,9 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -# fix permissions (NB: '+X' and not '+x'!) +# Fix permissions (NB: '+X' and not '+x'!) chmod a+rX $WM_PROJECT_DIR $WM_PROJECT_DIR/doc Doxygen -Doxygen/Allwmake +exec Doxygen/Allwmake "$@" #------------------------------------------------------------------------------ diff --git a/doc/Doxygen/Allwmake b/doc/Doxygen/Allwmake index 9947ab925d..726c5fbbe7 100755 --- a/doc/Doxygen/Allwmake +++ b/doc/Doxygen/Allwmake @@ -14,13 +14,17 @@ usage() { usage: ${0##*/} [OPTION] options: - -online use links to the Github repositories instead of the local source code + -config name use alternative doxygen config + -dir name process given directory name directly + -online use links to the Github repositories instead of the + local source code -help USAGE exit 1 } +# ----------------------------------------------------------------------------- defineURL() { WEB_PATH="https://develop.openfoam.com" @@ -39,13 +43,43 @@ defineURL() { export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}" } -# parse options + +unset configName dirName + +# Parse options while [ "$#" -gt 0 ] do case "$1" in -h | -help) usage ;; + -config) + configName="$2" + [ -f "$configName" ] || { + # No such file. Try some common alternatives + for ending in $configName ".$configName" "-$configName" + do + if [ -f "Doxyfile$ending" ] + then + configName="Doxyfile$ending" + break + fi + done + } + [ -f "$configName" ] || { + echo "Could not resolve Doxyfile config: $configName" 1>&2 + exit 1 + } + shift + ;; + -dir) + dirName="$2" + [ -d "$dirName" ] || { + echo "Could not resolve input directory: $dirName" 1>&2 + exit 1 + } + shift + ;; -online) defineURL ;; @@ -56,19 +90,31 @@ do shift done + #------------------------------------------------------------------------------ rm -rf latex man -# remove html directory in background +# Remove html directory in background mv html html-stagedRemove$$ 2> /dev/null rm -rf html-stagedRemove$$ >/dev/null 2>&1 & -# ensure that created files are readable by everyone +# Ensure that created files are readable by everyone umask 22 -doxygen -# fix permissions (NB: '+X' and not '+x'!) +if [ -n "$dirName" ] +then + # Create a temporary with only the specified directory + tmpConfig="${TMPDIR:-/tmp}/Doxyfile.$$" + trap 'rm -f $tmpConfig 2>/dev/null; exit 0' EXIT TERM INT + cat $PWD/Doxyfile > $tmpConfig + echo "INPUT = $dirName" >> $tmpConfig + doxygen $tmpConfig +else + doxygen $configName +fi + +# Fix permissions (NB: '+X' and not '+x'!) chmod -R a+rX html latex man 2>/dev/null echo From a8d2ebf2983fdd8abbf028acf8a884d957773f7e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 16 May 2017 23:54:43 +0200 Subject: [PATCH 02/10] ENH: cleanup wordRe interfaces etc. - ensure that the string-related classes have consistently similar matching methods. Use operator()(const std::string) as an entry point for the match() method, which makes it easier to use for filters and predicates. In some cases this will also permit using a HashSet as a match predicate. regExp ==== - the set method now returns a bool to signal that the requested pattern was compiled. wordRe ==== - have separate constructors with the compilation option (was previously a default parameter). This leaves the single parameter constructor explicit, but the two parameter version is now non-explicit, which makes it easier to use when building lists. - renamed compile-option from REGEX (to REGEXP) for consistency with with the , header names etc. wordRes ==== - renamed from wordReListMatcher -> wordRes. For reduced typing and since it behaves as an entity only slightly related to its underlying list nature. - Provide old name as typedef and include for code transition. - pass through some list methods into wordRes hashedWordList ==== - hashedWordList[const word& name] now returns a -1 if the name is is not found in the list of indices. That has been a pending change ever since hashedWordList was generalized out of speciesTable (Oct-2010). - add operator()(const word& name) for easy use as a predicate STYLE: adjust parameter names in stringListOps - reflect if the parameter is being used as a primary matcher, or the matcher will be derived from the parameter. For example, (const char* re), which first creates a regExp versus (const regExp& matcher) which is used directly. --- applications/test/fileName/Test-fileName.C | 6 +- applications/test/wordRe/Test-wordRe.C | 30 +++- .../doxygenXmlParser/doxygenXmlParser.C | 8 +- .../dataConversion/foamToVTK/foamToVTK.C | 6 +- .../createZeroDirectory/boundaryInfo.C | 2 +- src/OSspecific/POSIX/regExp.C | 12 +- src/OSspecific/POSIX/regExp.H | 16 +- src/OSspecific/POSIX/regExpI.H | 6 + src/OpenFOAM/Make/files | 2 +- src/OpenFOAM/db/IOobjectList/IOobjectList.C | 2 +- .../primitives/strings/keyType/keyType.C | 6 +- .../primitives/strings/keyType/keyType.H | 25 ++- .../primitives/strings/keyType/keyTypeI.H | 6 + .../primitives/strings/lists/hashedWordList.H | 41 +++-- .../strings/lists/hashedWordListI.H | 60 ++++--- .../primitives/strings/lists/stringListOps.H | 167 ++++++++++-------- .../strings/lists/stringListOpsTemplates.C | 52 +++--- .../primitives/strings/string/string.H | 14 +- .../primitives/strings/string/stringI.H | 14 +- src/OpenFOAM/primitives/strings/word/word.H | 14 +- src/OpenFOAM/primitives/strings/word/wordI.H | 4 +- .../primitives/strings/wordRe/wordRe.H | 52 +++--- .../primitives/strings/wordRe/wordReI.H | 138 +++++++++------ .../strings/wordRes/wordReListMatcher.H | 51 ++++++ .../wordReListMatcher.C => wordRes/wordRes.C} | 10 +- .../wordReListMatcher.H => wordRes/wordRes.H} | 78 +++++--- .../wordResI.H} | 52 ++++-- src/conversion/ensight/mesh/ensightMesh.C | 4 +- src/functionObjects/field/ddt2/ddt2.C | 4 +- .../field/zeroGradient/zeroGradient.C | 4 +- .../surfMeshSamplers/surfMeshSamplers.C | 6 +- 31 files changed, 556 insertions(+), 336 deletions(-) create mode 100644 src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H rename src/OpenFOAM/primitives/strings/{lists/wordReListMatcher.C => wordRes/wordRes.C} (89%) rename src/OpenFOAM/primitives/strings/{lists/wordReListMatcher.H => wordRes/wordRes.H} (57%) rename src/OpenFOAM/primitives/strings/{lists/wordReListMatcherI.H => wordRes/wordResI.H} (67%) diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C index 18f89b6db0..5de8912bd8 100644 --- a/applications/test/fileName/Test-fileName.C +++ b/applications/test/fileName/Test-fileName.C @@ -180,9 +180,9 @@ int main(int argc, char *argv[]) // A regex with a zero length matcher doesn't work at all: // eg "(png|jpg|txt|)" regex matcher itself - wordRe matcher0("()", wordRe::REGEXP); - wordRe matcher1("(png|jpg|txt)", wordRe::REGEXP); - wordRe matcher2("(png|txt)", wordRe::REGEXP); + wordRe matcher0("()", wordRe::REGEX); + wordRe matcher1("(png|jpg|txt)", wordRe::REGEX); + wordRe matcher2("(png|txt)", wordRe::REGEX); Info<<"Has extension(s):" << nl << "input: " << endWithDot << nl; diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C index f5dfcda831..f3ab4a3719 100644 --- a/applications/test/wordRe/Test-wordRe.C +++ b/applications/test/wordRe/Test-wordRe.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +30,9 @@ Description #include "IFstream.H" #include "List.H" #include "Tuple2.H" +#include "keyType.H" #include "wordRe.H" +#include "wordRes.H" using namespace Foam; @@ -44,12 +46,36 @@ int main(int argc, char *argv[]) Foam::string s2("this .* file"); const char * s3 = "this .* file"; + keyType keyre("x.*", true); + + wordReList wordrelist + { + {"this", wordRe::LITERAL}, + {"x.*", wordRe::REGEX}, + {"file[a-b]", wordRe::REGEX}, + }; + + wordRes wrelist(wordrelist); + + Info<< "re-list:" << wrelist() << endl; + Info<< "match this: " << wrelist("this") << endl; + Info<< "match xyz: " << wrelist("xyz") << endl; + Info<< "match zyx: " << wrelist("zyx") << endl; + Info<< "match xyz: " << wrelist.match("xyz") << endl; + Info<< "keyre match: " << keyre("xyz") << endl; + Info<< "string match: " << string("this").match("xyz") << endl; + Info<< "string match: " << string("x.*")("xyz") << endl; + Info<< "string match: " << string("x.*")(keyre) << endl; + wordRe(s1, wordRe::DETECT).info(Info) << endl; wordRe(s2).info(Info) << endl; wordRe(s2, wordRe::DETECT).info(Info) << endl; - wordRe(s3, wordRe::REGEXP).info(Info) << endl; + wordRe(s3, wordRe::REGEX).info(Info) << endl; wre = "this .* file"; + + Info<<"substring: " << wre(4) << endl; + wre.info(Info) << endl; wre = s1; wre.info(Info) << endl; diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C index 0de175b4b7..bc67aabd7f 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/doxygenXmlParser/doxygenXmlParser.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "doxygenXmlParser.H" -#include "wordRe.H" +#include "regExp.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -40,8 +40,8 @@ Foam::doxygenXmlParser::doxygenXmlParser dictionary(dictionary::null) { // Pre-construct and compile regular expressions - const wordRe nameRe(".*.H", wordRe::DETECT); - const wordRe searchStrRe(searchStr, wordRe::DETECT); + const regExp nameRe(".*.H"); + const regExp searchStrRe(searchStr); // Pre-construct constant strings and names to speed-up comparisons const string slashStartTag('/' + startTag); @@ -163,7 +163,7 @@ Foam::doxygenXmlParser::doxygenXmlParser ( !exactMatch && !found(tName) // not already added - && wordRe(".*" + tName + ".*", wordRe::DETECT).match(name) + && regExp(".*" + tName + ".*").match(name) ) { dictionary dict(dictionary::null); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index c2a6f3b298..602f68b2d0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -199,7 +199,7 @@ void print(Ostream& os, const wordList& flds) labelList getSelectedPatches ( const polyBoundaryMesh& patches, - const List& excludePatches + const wordRes& excludePatches ) { DynamicList