dictionary::inputSyntaxEntry: Completed support for specifying the default syntax in etc/controlDict

This commit is contained in:
Henry Weller
2019-07-11 00:16:30 +01:00
parent cba96822f4
commit cd910ed6b8
2 changed files with 24 additions and 10 deletions

View File

@ -37,8 +37,9 @@ const Foam::word Foam::functionEntries::inputSyntaxEntry::typeName
// might include inputSyntax entries // might include inputSyntax entries
int Foam::functionEntries::inputSyntaxEntry::debug(0); int Foam::functionEntries::inputSyntaxEntry::debug(0);
// Read the default dictionary syntax from etc/controlDict if specified
Foam::functionEntries::inputSyntaxEntry::inputSyntax Foam::functionEntries::inputSyntaxEntry::inputSyntax
Foam::functionEntries::inputSyntaxEntry::syntax_ Foam::functionEntries::inputSyntaxEntry::defaultSyntax_
( (
Foam::debug::optimisationSwitches().found("inputSyntax") Foam::debug::optimisationSwitches().found("inputSyntax")
? Foam::functionEntries::inputSyntaxEntry::syntax ? Foam::functionEntries::inputSyntaxEntry::syntax
@ -51,6 +52,13 @@ Foam::functionEntries::inputSyntaxEntry::inputSyntax
: DOT : DOT
); );
// Initialise the current dictionary syntax to the default
Foam::functionEntries::inputSyntaxEntry::inputSyntax
Foam::functionEntries::inputSyntaxEntry::syntax_
(
Foam::functionEntries::inputSyntaxEntry::defaultSyntax_
);
namespace Foam namespace Foam
{ {
@ -76,7 +84,7 @@ Foam::functionEntries::inputSyntaxEntry::syntax
) )
{ {
word syntax(is); word syntax(is);
if (syntax == "slash" || syntax == "default") if (syntax == "slash")
{ {
return SLASH; return SLASH;
} }
@ -88,9 +96,10 @@ Foam::functionEntries::inputSyntaxEntry::syntax
{ {
WarningInFunction WarningInFunction
<< "unsupported input syntax'" << syntax << "unsupported input syntax'" << syntax
<< "' ... defaulting to 'dot'" << ", setting to default"
<< endl; << endl;
return DOT;
return defaultSyntax_;
} }
} }
@ -110,7 +119,7 @@ bool Foam::functionEntries::inputSyntaxEntry::execute
void Foam::functionEntries::inputSyntaxEntry::clear() void Foam::functionEntries::inputSyntaxEntry::clear()
{ {
syntax_ = DOT; syntax_ = defaultSyntax_;
} }

View File

@ -34,12 +34,13 @@ Description
The possible input syntax: The possible input syntax:
- \par slash use '/' as the scope operator - \par slash use '/' as the scope operator
and '../' to go to the parent dictionary '../' to go to the parent dictionary
and '!' to go to the top-level dictionary
- \par dot use '.' as the scope operator - \par dot use '.' as the scope operator
and '..' to go to the parent dictionary '..' to go to the parent dictionary
- \par default currently identical to dot and ':' to go to the top-level dictionary
The default dictionary syntax is \c dot but changed to \c slash in The default dictionary syntax is \c dot but can be changed to \c slash in
etc/controlDict etc/controlDict
\verbatim \verbatim
OptimisationSwitches OptimisationSwitches
@ -83,6 +84,9 @@ class inputSyntaxEntry
DOT DOT
}; };
//- The default input syntax
static inputSyntax defaultSyntax_;
//- The current input syntax //- The current input syntax
static inputSyntax syntax_; static inputSyntax syntax_;
@ -110,7 +114,8 @@ public:
//- Execute the functionEntry in a sub-dict context //- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&); static bool execute(dictionary& parentDict, Istream&);
//- Reset the inputSyntax to %default (ie, %merge) //- Reset the inputSyntax to the default specified in etc/controlDict
// if not specified to %dot
static void clear(); static void clear();
//- Return true if the inputSyntax is %slash //- Return true if the inputSyntax is %slash