Go to the documentation of this file.
139 using namespace Foam;
145 bool upgradeScope(
word& entryName)
149 entryName.find(
'/') == string::npos
150 && entryName.find(
':') != string::npos
159 if (entryName.size()) entryName.append(
".");
161 entryName.append(
name);
180 dictAndKeyword(
const word& scopedName)
182 auto i = scopedName.rfind(
'/');
183 if (i == string::npos)
185 i = scopedName.rfind(
'.');
188 if (i != string::npos)
190 dict_ = scopedName.substr(0, i);
191 key_ = scopedName.substr(i+1);
214 const word& subDictName
217 if (subDictName.empty())
224 if (!eptr || !eptr->
isDict())
227 <<
"'" << subDictName <<
"' not found in dictionary "
228 <<
dict.
name() <<
" or is not a dictionary" <<
nl
229 <<
"Known entries are " <<
dict.
keys()
239 for (
const entry& refEntry : dictToRemove)
247 if (refEntry.isDict())
249 removeDict(finder.dict(), refEntry.dict());
252 purge = finder.dict().empty();
255 else if (finder.found() && !refEntry.isDict())
258 purge = (finder.ref() == refEntry);
269 int main(
int argc,
char *argv[])
273 "Interrogate and manipulate dictionaries"
290 "Set entry value or add new entry"
307 "Write differences with respect to the specified dictionary"
313 "As per -diff, but locate the file as per foamEtcFile"
320 "Set default write precision for IOstreams"
326 "List the #include/#sinclude files to standard output"
331 "Read the specified dictionary file, expand the macros etc. and write "
332 "the resulting dictionary to standard output"
336 "disableFunctionEntries",
337 "Disable expansion of dictionary directives - #include, #codeStream etc"
343 const bool listIncludes =
args.
found(
"includes");
350 const bool disableEntries =
args.
found(
"disableFunctionEntries");
356 Serr<<
"Not expanding variables or dictionary directives" <<
endl;
379 if (!dictFile().good())
382 <<
"Cannot open file " << dictFileName
387 bool changed =
false;
399 <<
"//\n// " << dictFileName <<
"\n//\n";
408 bool optDiff =
false;
417 if (!diffFile.good())
420 <<
"Cannot open file " << diffFileName
425 diffDict.
read(diffFile,
true);
431 if (foundName.empty())
434 <<
"Cannot find etcFile " << diffFileName
439 if (!diffFile.good())
442 <<
"Cannot open file " << foundName
447 diffDict.
read(diffFile,
true);
455 upgradeScope(scopedName);
464 const bool overwrite =
args.
found(
"set");
467 const dictAndKeyword dAk(scopedName);
497 const dictAndKeyword dAk(scopedName);
511 const dictAndKeyword dAk(scopedName);
514 const dictionary& d2(lookupScopedDict(diffDict, dAk.dict()));
521 if (*e1Ptr == *e2Ptr)
523 const_cast<dictionary&
>(d1).remove(dAk.key());
541 <<
"Cannot find entry " << scopedName
546 for (
const entry&
e : finder.dict())
555 Info<< finder.dict();
557 else if (finder.ref().isStream())
559 const tokenList& tokens = finder.ref().stream();
563 if (i < tokens.size() - 1)
586 removeDict(
dict, diffDict);
A keyword and a list of tokens is an 'entry'.
static bool New(dictionary &parentDict, Istream &is, const inputMode inpMode=inputMode::GLOBAL, const int endChar=0)
void set(List< bool > &bools, const labelRange &range)
const fileName & name() const noexcept
A class for handling words, derived from Foam::string.
A class for handling file names.
T getOrDefault(const word &optName, const T &deflt) const
Input from file stream, using an ISstream.
static Ostream & writeEndDivider(Ostream &os)
virtual bool isDict() const noexcept
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
static void addNote(const string ¬e)
static bool master(const label communicator=worldComm)
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
T get(const label index) const
static Ostream & writeBanner(Ostream &os, const bool noSyntaxHint=false)
bool readIfPresent(const word &optName, T &val) const
static void addArgument(const string &argName, const string &usage="")
List< keyType > keys(bool patterns=false) const
fileName findEtcFile(const fileName &name, const bool mandatory=false, unsigned short location=0777)
const_searcher csearchScoped(const word &keyword, enum keyType::option) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
OBJstream os(runTime.globalPath()/outputName)
static int disableFunctionEntries
virtual const dictionary & dict() const =0
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
virtual int precision() const
Functions to search 'etc' directories for configuration files etc.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
static unsigned int defaultPrecision() noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
static Ostream & writeDivider(Ostream &os)
bool remove(const word &keyword)
void write(Ostream &os, const bool subDict=true) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const dimensionedScalar e
@ REGEX
Regular expression.
const_searcher search(const word &keyword, enum keyType::option=keyType::REGEX) const
word name(const expressions::valueTypeCode typeCode)
#define FatalIOErrorInFunction(ios)
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Foam::argList args(argc, argv)
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
bool found(const word &optName) const