220 const
word& compoundType,
222 const
bool readContent = true
227 const Type*
isA()
const 229 return dynamic_cast<const Type*
>(
this);
257 virtual label
size()
const = 0;
260 virtual void resize(
const label
n) = 0;
289 virtual std::streamsize
size_bytes()
const = 0;
312 template<
class ValT =
typename T::value_type>
313 typename std::enable_if<pTraits_has_zero<ValT>::value,
void>
::type 320 template<
class ValT =
typename T::value_type>
321 typename std::enable_if<!pTraits_has_zero<ValT>::value,
void>
::type 324 T::operator=(ValT());
336 Compound<T>(
const Compound<T>&) =
delete;
339 Compound<T>&
operator=(
const Compound<T>&) =
delete;
355 T(
std::move(content))
368 template<
class... Args>
381 virtual label
size()
const 387 virtual void resize(
const label
n)
393 virtual void fill_zero() { _m_fill_zero(); }
405 operator<<(os, static_cast<const T&>(*this));
425 return T::cdata_bytes();
431 return T::data_bytes();
437 return T::size_bytes();
484 inline void setUndefined()
noexcept;
493 void parseError(const
char* expected) const;
519 inline explicit
token(const label val, label lineNum=0)
noexcept;
522 inline explicit
token(const
float val, label lineNum=0)
noexcept;
525 inline explicit
token(const
double val, label lineNum=0)
noexcept;
528 inline explicit
token(const
word& w, label lineNum=0);
531 inline explicit
token(const
string& str, label lineNum=0);
534 inline explicit
token(
word&& w, label lineNum=0);
537 inline explicit
token(
string&& str, label lineNum=0);
656 inline
bool isWord(const
std::
string&
s) const;
697 explicit operator
bool() const
noexcept {
return good(); }
734 inline scalar
number()
const;
758 const word& compoundType,
760 const bool readContent =
true 823 inline void operator=(
const string& str);
832 inline void operator=(token::compound* ptr);
835 inline void operator=(autoPtr<token::compound>&& ptr);
845 inline bool operator==(
const std::string&
s)
const;
855 inline bool operator!=(
const std::string&
s)
const;
865 friend ostream& operator<<(ostream& os, const InfoProxy<token>& ip);
907 Ostream&
operator<<(Ostream&
os,
const token::compound& ct);
909 ostream& operator<<(ostream& os, const InfoProxy<token>& ip);
912 Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip);
918 #define defineCompoundTypeName(Type, UnusedTag) \ 919 defineTemplateTypeNameWithName(token::Compound<Type>, #Type); 922 #define defineNamedCompoundTypeName(Type, Name) \ 923 defineTemplateTypeNameWithName(token::Compound<Type>, #Name); 926 #define addCompoundToRunTimeSelectionTable(Type, Tag) \ 927 token::compound::addemptyConstructorToTable<token::Compound<Type>> \ 928 add##Tag##emptyConstructorToTable_; 931 #define addNamedCompoundToRunTimeSelectionTable(Type, Tag, Name) \ 932 token::compound::addemptyConstructorToTable<token::Compound<Type>> \ 933 add##Tag##emptyConstructorToTable_(#Name); Subtract or start of negative number.
static bool isCompound(const word &compoundType)
True if a known (registered) compound type.
virtual void read(Istream &is)=0
Read from stream into the underlying content.
Begin block [isseparator].
static const token undefinedToken
An undefined token.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
double doubleScalarToken() const
Return double value.
static autoPtr< compound > New(const word &compoundType)
Default construct specified compound type.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
bool operator!=(const token &tok) const
bool isDouble() const noexcept
Token is DOUBLE.
Left parenthesis [isseparator].
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
punctuationToken pToken() const
Return punctuation character.
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
virtual tokenType typeCode() const
The token type (if any) corresponding to the contained component type (LABEL, FLOAT, DOUBLE, etc).
single character punctuation
patchWriters resize(patchIds.size())
Reference counter for various OpenFOAM components.
stream flag (1-byte bitmask)
bool isCompound() const noexcept
Token is COMPOUND.
scalar number() const
Return label, float or double value.
Begin dimensions [isseparator].
const word & wordToken() const
Return const reference to the word contents.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds an item read from Istream.
TypeNameNoDebug("Compound<T>")
Declare type-name, virtual type (without debug switch)
tokenType
Enumeration defining the types of token.
bool moved() const noexcept
Get compound transferred status.
The vector-space number of components: default is 1.
A traits class, which is primarily used for primitives and vector-space.
tokenType type() const noexcept
Return the token type.
bool isFlag() const noexcept
Token is FLAG.
Begin string with double quote.
friend Ostream & operator<<(Ostream &os, const token &tok)
Begin list [isseparator].
Subtract or start of negative number.
Assignment/equals [isseparator].
float floatToken() const
Return float value.
bool isExpression() const noexcept
Token is EXPRESSION (string variant)
bool isSeparator() const noexcept
Token is PUNCTUATION and isseparator.
virtual ~compound() noexcept=default
Destructor.
bool undefined() const noexcept
Token is UNDEFINED.
virtual void resize(const label n)
Change the size of the underlying container content.
scalar scalarToken() const
Return float or double value.
bool boolToken() const
Return boolean token value.
Dollar - start variable or expression.
bool readCompoundToken(const word &compoundType, Istream &is, const bool readContent=true)
Default construct the specified compound type and read from stream.
word name() const
Return the name of the current token type.
declareRunTimeSelectionTable(autoPtr, compound, empty,(),())
Declare run-time constructor selection table.
static constexpr const char *const typeName
The type name is "token".
virtual void fill_zero()=0
Fill with zero values, or with default constructed.
virtual direction nComponents() const
The number of vector-space or other components of the underlying data content.
virtual std::streamsize size_bytes() const
Size of the (contiguous) byte data.
End dimensions [isseparator].
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA)
virtual void fill_zero()
Fill with zero value or with default value initialized.
int flagToken() const
Return flag bitmask value.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Right square bracket [isseparator].
Abstract base class for complex tokens.
Compound()=default
Default construct.
A templated class for holding compound tokens. The underlying container is normally a List of values...
static autoPtr< Compound< T > > New(Args &&... args)
Construct autoPtr compound type with forwarding arguments.
Right parenthesis [isseparator].
Compound type such as List<label> etc.
label lineNumber() const noexcept
The line number for the token.
double doubleToken() const
Return double value.
compound & transferCompoundToken(const Istream *is=nullptr)
Return reference to compound and mark internally as released.
Left square bracket [isseparator].
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
bool isStringType() const noexcept
Token is word-variant or string-variant (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA)
virtual std::streamsize size_bytes() const =0
Size of the (contiguous) byte data.
virtual const char * cdata_bytes() const =0
Pointer to the underlying data as byte data.
A class for handling words, derived from Foam::string.
static bool isseparator(int c) noexcept
True if the character is a punctuation separator (eg, in ISstream).
virtual void resize(const label n)=0
Change the size of the underlying container content.
Istream & operator>>(Istream &, directionInfo &)
End string with double quote.
flagType
Stream or output control flags (1-byte width)
void swap(token &tok) noexcept
Swap token contents: type, data, line-number.
void setBad()
Clear token and set to be ERROR.
punctuationToken
Standard punctuation tokens (a character)
virtual void read(Istream &is)
Redirect read to underlying content.
const compound & compoundToken() const
Const reference to compound token. Fatal if the wrong type.
float (single-precision) type
virtual direction nComponents() const =0
The number of vector-space or other components of the underlying data content.
float floatScalarToken() const
Return float value.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool isBool() const noexcept
Token is BOOL.
constexpr compound() noexcept
Default construct.
bool setType(const tokenType tokType) noexcept
Change the token type, for similar types.
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
OBJstream os(runTime.globalPath()/outputName)
bool isFloatScalar() const
Token is FLOAT.
bool isDoubleScalar() const
Token is DOUBLE.
const string & stringToken() const
Return const reference to the string contents.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Left brace [isseparator].
unsigned char state_
The compound token state, internally used values only.
static token flag(int bitmask) noexcept
Create a token with stream flags, no sanity check.
bool operator==(const token &tok) const
Foam::string (usually double-quoted)
virtual tokenType typeCode() const =0
The token type (if any) corresponding to the contained component type (LABEL, FLOAT, DOUBLE, etc).
void operator=(const token &tok)
Copy assign.
TypeNameNoDebug("compound")
Declare type-name, virtual type (without debug switch)
virtual const char * cdata_bytes() const
Pointer to the underlying data as byte data.
bool isCharData() const noexcept
Token is CHAR_DATA (string variant)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
bool isFloat() const noexcept
Token is FLOAT.
void reset()
Reset token to UNDEFINED and clear any allocated storage.
virtual label size() const =0
The size of the underlying content.
A helper class for outputting values to Ostream.
const dimensionedScalar c
Speed of light in a vacuum.
virtual char * data_bytes()=0
Pointer to the underlying data as byte data.
label labelToken() const
Return label value.
double (double-precision) type
Right brace [isseparator].
T::value_type value_type
The type of values held by the compound.
bool isLabel() const noexcept
Token is LABEL.
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
compound & refCompoundToken()
Return reference to compound token. Fatal if the wrong type.
String-variant: plain character content.
virtual char * data_bytes()
Pointer to the underlying data as byte data.
virtual void write(Ostream &os) const
Redirect write to underlying content.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
const Type * isA() const
Check if dynamic_cast to Type is possible.
Macros to ease declaration of run-time selection tables.
Question mark (eg, ternary)
Compound< T > & operator=(const Compound< T > &)=delete
No copy assignment.
bool isVariable() const noexcept
Token is VARIABLE (string variant)
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::argList args(argc, argv)
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
virtual void write(Ostream &os) const =0
Write the underlying content.
friend Ostream & operator<<(Ostream &os, const compound &ct)
Output operator.
bool isVerbatim() const noexcept
Token is VERBATIM string (string variant)
bool pending() const noexcept
Get compound pending-read status.
Hash - directive or start verbatim string.
virtual label size() const
The size of the underlying content.
bool isQuotedString() const noexcept
Token is (quoted) STRING (string variant)