diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index ee0d751fae..288da061b8 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -110,13 +110,13 @@ public: inline fileName(const word&); //- Construct as copy of string - inline fileName(const string&); + inline fileName(const string&, const bool doStripInvalid=true); //- Construct as copy of std::string - inline fileName(const std::string&); + inline fileName(const std::string&, const bool doStripInvalid=true); //- Construct as copy of character array - inline fileName(const char*); + inline fileName(const char*, const bool doStripInvalid=true); //- Construct by concatenating elements of wordList separated by '/' explicit fileName(const wordList&); diff --git a/src/OpenFOAM/primitives/strings/fileName/fileNameI.H b/src/OpenFOAM/primitives/strings/fileName/fileNameI.H index a015e971bd..6c2bb37f9a 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileNameI.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileNameI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,8 @@ License inline void Foam::fileName::stripInvalid() { + // skip stripping unless debug is active to avoid + // costly operations if (debug && string::stripInvalid(*this)) { std::cerr @@ -54,38 +56,49 @@ inline Foam::fileName::fileName() string() {} + inline Foam::fileName::fileName(const fileName& fn) : string(fn) {} + inline Foam::fileName::fileName(const word& w) : string(w) {} -inline Foam::fileName::fileName(const string& str) +inline Foam::fileName::fileName(const string& s, const bool doStripInvalid) : - string(str) + string(s) { - stripInvalid(); + if (doStripInvalid) + { + stripInvalid(); + } } -inline Foam::fileName::fileName(const std::string& str) +inline Foam::fileName::fileName(const std::string& s, const bool doStripInvalid) : - string(str) + string(s) { - stripInvalid(); + if (doStripInvalid) + { + stripInvalid(); + } } -inline Foam::fileName::fileName(const char* str) +inline Foam::fileName::fileName(const char* s, const bool doStripInvalid) : - string(str) + string(s) { - stripInvalid(); + if (doStripInvalid) + { + stripInvalid(); + } } diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H index 587adfac99..a4d15df4e7 100644 --- a/src/OpenFOAM/primitives/strings/word/wordI.H +++ b/src/OpenFOAM/primitives/strings/word/wordI.H @@ -52,18 +52,18 @@ inline void Foam::word::stripInvalid() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::word::word(const word& w) -: - string(w) -{} - - inline Foam::word::word() : string() {} +inline Foam::word::word(const word& w) +: + string(w) +{} + + inline Foam::word::word(const string& s, const bool doStripInvalid) : string(s) @@ -96,6 +96,7 @@ inline Foam::word::word(const char* s, const bool doStripInvalid) } } + inline Foam::word::word ( const char* s,