dynamicCodeContext Class Reference

Encapsulation of dynamic code dictionaries. More...

Public Member Functions

 dynamicCodeContext ()
 Default construct. More...
 
 dynamicCodeContext (const dictionary &dict)
 Construct from a dictionary. More...
 
bool valid () const noexcept
 Considered valid if not using dictionary::null as the context. More...
 
void setCodeContext (const dictionary &dict)
 Set code context from a dictionary. More...
 
const dictionarydict () const noexcept
 Return the parent dictionary context. More...
 
const stringoptions () const noexcept
 The code options (Make/options) More...
 
const stringlibs () const noexcept
 The code libs (LIB_LIBS) More...
 
const stringinclude () const noexcept
 The code includes. More...
 
const stringlocalCode () const noexcept
 The local (file-scope) code. More...
 
const stringcode () const noexcept
 The code. More...
 
const SHA1sha1 () const noexcept
 The SHA1 calculated from options, libs, include, code, etc. More...
 
void append (const std::string &str)
 Add content to SHA1 hashing. More...
 
const entryfindEntry (const word &key) const
 Locate literal dictionary entry, nullptr if not found. More...
 
bool readEntry (const word &key, string &str, bool mandatory=true, bool withLineNum=true)
 
bool readIfPresent (const word &key, string &str, bool withLineNum=true)
 
 operator const dictionary & () const noexcept
 Cast to dictionary. More...
 

Static Public Member Functions

static void inplaceExpand (string &str, const dictionary &dict)
 Cleanup string and expand with dictionary parameters. More...
 
static unsigned addLineDirective (string &code, label lineNum, const string &file)
 Prefix a #line directive to code. More...
 
static unsigned addLineDirective (string &code, label lineNum, const dictionary &dict)
 Prefix a #line directive to code. More...
 

Detailed Description

Encapsulation of dynamic code dictionaries.

Source files

Definition at line 53 of file dynamicCodeContext.H.

Constructor & Destructor Documentation

◆ dynamicCodeContext() [1/2]

Default construct.

Definition at line 81 of file dynamicCodeContext.C.

◆ dynamicCodeContext() [2/2]

dynamicCodeContext ( const dictionary dict)
explicit

Construct from a dictionary.

Definition at line 87 of file dynamicCodeContext.C.

References dynamicCodeContext::dict(), and dynamicCodeContext::setCodeContext().

Here is the call graph for this function:

Member Function Documentation

◆ inplaceExpand()

void inplaceExpand ( string str,
const dictionary dict 
)
static

Cleanup string and expand with dictionary parameters.

Definition at line 35 of file dynamicCodeContext.C.

References dynamicCodeContext::dict(), Foam::stringOps::inplaceExpand(), and Foam::stringOps::inplaceTrim().

Referenced by dynamicCodeContext::readEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addLineDirective() [1/2]

unsigned addLineDirective ( string code,
label  lineNum,
const string file 
)
static

Prefix a #line directive to code.

The input lineNum is 0-based. Is a no-op if any of the arguments are invalid (lineNum is negative, code or file are empty)

Returns
The change in string length caused by the directive. This can potentially be used to recover the substring portions.

Definition at line 46 of file dynamicCodeContext.C.

References Foam::name().

Here is the call graph for this function:

◆ addLineDirective() [2/2]

unsigned addLineDirective ( string code,
label  lineNum,
const dictionary dict 
)
static

Prefix a #line directive to code.

The name of the dictionary is used for the 'file' name.

Definition at line 68 of file dynamicCodeContext.C.

References dict, and dictionary::name().

Here is the call graph for this function:

◆ valid()

bool valid ( ) const
noexcept

Considered valid if not using dictionary::null as the context.

Definition at line 97 of file dynamicCodeContext.C.

◆ setCodeContext()

void setCodeContext ( const dictionary dict)

Set code context from a dictionary.

Definition at line 164 of file dynamicCodeContext.C.

References dict, and readIfPresent().

Referenced by dynamicCodeContext::dynamicCodeContext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dict()

const dictionary & dict ( ) const
inlinenoexcept

Return the parent dictionary context.

Definition at line 128 of file dynamicCodeContext.H.

Referenced by dynamicCodeContext::dynamicCodeContext(), codeStream::getFunction(), dynamicCodeContext::inplaceExpand(), and codedBase::updateLibrary().

Here is the caller graph for this function:

◆ options()

const string & options ( ) const
inlinenoexcept

The code options (Make/options)

Definition at line 134 of file dynamicCodeContext.H.

Referenced by codeStream::getFunction(), codedPoints0MotionSolver::prepare(), codedMixedFvPatchField< Type >::prepare(), codedFunctionObject::prepare(), CodedSource< Type >::prepare(), CodedField< Type >::prepare(), and CodedFunction1< Type >::prepare().

Here is the caller graph for this function:

◆ libs()

const string & libs ( ) const
inlinenoexcept

The code libs (LIB_LIBS)

Definition at line 140 of file dynamicCodeContext.H.

Referenced by codeStream::getFunction(), codedPoints0MotionSolver::prepare(), codedMixedFvPatchField< Type >::prepare(), codedFunctionObject::prepare(), CodedSource< Type >::prepare(), CodedField< Type >::prepare(), and CodedFunction1< Type >::prepare().

Here is the caller graph for this function:

◆ include()

const string & include ( ) const
inlinenoexcept

The code includes.

Definition at line 146 of file dynamicCodeContext.H.

Referenced by dynamicCode::setFilterContext().

Here is the caller graph for this function:

◆ localCode()

const string & localCode ( ) const
inlinenoexcept

The local (file-scope) code.

Definition at line 152 of file dynamicCodeContext.H.

Referenced by dynamicCode::setFilterContext().

Here is the caller graph for this function:

◆ code()

const string & code ( ) const
inlinenoexcept

The code.

Definition at line 158 of file dynamicCodeContext.H.

Referenced by CodedField< Type >::prepare(), CodedFunction1< Type >::prepare(), and dynamicCode::setFilterContext().

Here is the caller graph for this function:

◆ sha1()

const SHA1 & sha1 ( ) const
inlinenoexcept

The SHA1 calculated from options, libs, include, code, etc.

Definition at line 164 of file dynamicCodeContext.H.

Referenced by codeStream::getFunction(), codedPoints0MotionSolver::prepare(), codedMixedFvPatchField< Type >::prepare(), codedFunctionObject::prepare(), CodedSource< Type >::prepare(), CodedField< Type >::prepare(), CodedFunction1< Type >::prepare(), dynamicCode::setFilterContext(), codedBase::updateLibrary(), and dynamicCode::upToDate().

Here is the caller graph for this function:

◆ append()

void append ( const std::string &  str)
inline

Add content to SHA1 hashing.

Definition at line 170 of file dynamicCodeContext.H.

References SHA1::append().

Here is the call graph for this function:

◆ findEntry()

const Foam::entry * findEntry ( const word key) const

Locate literal dictionary entry, nullptr if not found.

Definition at line 103 of file dynamicCodeContext.C.

References dict, dictionary::findEntry(), and keyType::LITERAL.

Here is the call graph for this function:

◆ readEntry()

bool readEntry ( const word key,
string str,
bool  mandatory = true,
bool  withLineNum = true 
)

Read string entry from context dictionary append content to SHA1 hashing and add line number etc.

The string is cleared before reading.

Definition at line 109 of file dynamicCodeContext.C.

References dict, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, dictionary::findEntry(), dynamicCodeContext::inplaceExpand(), keyType::LITERAL, dictionary::name(), Foam::nl, entry::readEntry(), and entry::startLineNumber().

Here is the call graph for this function:

◆ readIfPresent()

bool readIfPresent ( const word key,
string str,
bool  withLineNum = true 
)

Read optional string entry from context dictionary, append content to SHA1 hashing and add line number etc.

The string is cleared before reading.

Definition at line 153 of file dynamicCodeContext.C.

References dynamicCodeContext::readIfPresent().

Referenced by dynamicCodeContext::readIfPresent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator const dictionary &()

operator const dictionary & ( ) const
inlinenoexcept

Cast to dictionary.

Definition at line 208 of file dynamicCodeContext.H.

References dictionary::get().

Here is the call graph for this function:

The documentation for this class was generated from the following files: