From a653f2d02765726896591cd55a71dfc490fa9dff Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 13 Apr 2011 17:11:36 +0100 Subject: [PATCH] BUG: wordRe: assignment from keyType not handled --- .../primitives/strings/wordRe/wordRe.H | 11 ++++++-- .../primitives/strings/wordRe/wordReI.H | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index 566f42af6ca..bcb7dad5b1c 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,6 +52,7 @@ SourceFiles #include "word.H" #include "regExp.H" +#include "keyType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +61,6 @@ namespace Foam // Forward declaration of friend functions and operators class wordRe; - class Istream; class Ostream; @@ -118,6 +118,9 @@ public: //- Construct as copy inline wordRe(const wordRe&); + //- Construct from keyType + inline wordRe(const keyType&, const compOption=LITERAL); + //- Construct as copy of word inline wordRe(const word&); @@ -196,6 +199,10 @@ public: //- Copy word, never a regular expression inline const wordRe& operator=(const word&); + //- Copy keyType, auto-test for regular expression + // Always case sensitive + inline const wordRe& operator=(const keyType&); + //- Copy string, auto-test for regular expression // Always case sensitive inline const wordRe& operator=(const string&); diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H index 713c0030641..fcbd1c38456 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,6 +65,18 @@ inline Foam::wordRe::wordRe(const word& str) {} +inline Foam::wordRe::wordRe(const keyType& str, const compOption opt) +: + word(str, false), + re_() +{ + if (str.isPattern()) + { + compile(opt); + } +} + + inline Foam::wordRe::wordRe(const char* str, const compOption opt) : word(str, false), @@ -236,6 +248,17 @@ inline const Foam::wordRe& Foam::wordRe::operator=(const word& str) } +inline const Foam::wordRe& Foam::wordRe::operator=(const keyType& str) +{ + string::operator=(str); + if (str.isPattern()) + { + compile(); + } + return *this; +} + + inline const Foam::wordRe& Foam::wordRe::operator=(const string& str) { string::operator=(str); -- GitLab