34 HashTable<Tuple2<const dictionary*, label>, fileName, Hash<fileName>>
35 printDictionary::dictNameToDictPtrAndCount_;
37 HashTable<tmpNrc<dictionary>,
const dictionary*, Hash<void*>>
38 printDictionary::dictPtrToDefaults_;
44 void Foam::printDictionary::removeDefaults
46 const dictionary* dictPtr,
47 HashSet<
const dictionary*, Hash<void*>>& removeDictPtrs
51 HashTable<tmpNrc<dictionary>,
const dictionary*, Hash<void*>>
52 dictPtrToDefaultsType;
54 if (!dictPtrToDefaults_.found(dictPtr))
return;
56 const dictionary&
defaults = dictPtrToDefaults_[dictPtr]();
60 if (!iter().isDict())
continue;
62 const dictionary& subDefaults = iter().dict();
66 if (&jter()() == &subDefaults)
68 removeDefaults(jter.key(), removeDictPtrs);
74 removeDictPtrs.insert(dictPtr);
78 void Foam::printDictionary::removeDefaults(
const dictionary* dictPtr)
81 HashSet<const dictionary*, Hash<void*>>
84 removeDictPtrsType removeDictPtrs;
86 removeDefaults(dictPtr, removeDictPtrs);
90 dictPtrToDefaults_.erase(iter.key());
95 void Foam::printDictionary::setDefaults(
const dictionary&
dict)
97 removeDefaults(&
dict);
99 dictPtrToDefaults_.set
102 tmpNrc<dictionary>(
new dictionary(
dict.
parent(), dictionary()))
109 void Foam::printDictionary::setSubDefaults
111 const dictionary&
dict,
117 if (!iter().isDict())
continue;
119 const dictionary& subDict = iter().dict();
121 defaults.set(iter().keyword(), dictionary());
123 dictionary& subDefaults = defaults.subDict(iter().keyword());
125 if (!dictPtrToDefaults_.found(&subDict))
127 dictPtrToDefaults_.set
130 tmpNrc<dictionary>(subDefaults)
134 setSubDefaults(subDict, subDefaults);
139 void Foam::printDictionary::print
141 const dictionary&
dict,
142 const dictionary& defaults
149 if (!iter().isDict())
153 else if (defaults.isDict(iter().keyword()))
156 print(iter().
dict(), defaults.
subDict(iter().keyword()));
166 oss <<
"/* #print must be specified after the " << iter().keyword()
167 <<
" sub-dictionary in order for its defaults to be printed */";
180 label nDefaultsEntries = 0;
183 nDefaultsEntries += !iter().isDict();
190 if (!iter().isDict())
202 void Foam::printDictionary::add(
const dictionary&
dict)
204 if (dictNameToDictPtrAndCount_.found(
dict.
name()))
206 dicts_.append(&
dict);
209 dictNameToDictPtrAndCount_[
dict.
name()].second() ++;
216 void Foam::printDictionary::add(
const fileName& dictName)
218 dicts_.append(
nullptr);
219 dictNames_.append(dictName);
221 dictNameToDictPtrAndCount_.set
224 Tuple2<const dictionary*, label>(
nullptr, 1)
231 Foam::printDictionary::printDictionary()
246 const word& dictName =
247 dicts_.set(i) ? dicts_[i].name() : dictNames_[i];
249 if (!dictNameToDictPtrAndCount_.found(dictName))
continue;
252 dictNameToDictPtrAndCount_[dictName];
258 if (!dictPtrToDefaults_.found(dictPtr))
continue;
260 if (dictPtr &&
count == 0 && dictPtrToDefaults_[dictPtr].isTmp())
264 print(*dictPtr, dictPtrToDefaults_[dictPtr]());
276 if (dictNameToDictPtrAndCount_.found(
dict.
name()))
282 dictNameToDictPtrAndCount_.found(
dict.
name())
283 ? dictNameToDictPtrAndCount_[
dict.
name()].second()
286 dictNameToDictPtrAndCount_.set
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
virtual Ostream & write(const token &)
Write token.
A 2-tuple for storing two objects of different types.
const Type2 & second() const
Return second.
const Type1 & first() const
Return first.
const fileName & name() const
Return the dictionary name.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const dictionary & parent() const
Return the parent dictionary.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
static const fileName null
An empty fileName.
string relativePath() const
Return file name part relative to FOAM_CASE.
static dictionary & defaults(const dictionary &dict)
Return the dictionary to add defaults to for a given dictionary.
~printDictionary()
Destructor.
static void set(const dictionary &dict)
Set the dictionary to be printed.
A class for handling words, derived from string.
string breakIntoIndentedLines(const string &str, const string::size_type nLength=80, const string::size_type nIndent=0)
Break a string up into indented lines.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
Ostream & indent(Ostream &os)
Indent stream.