Loading...
Searching...
No Matches
IOstreamOption Class Reference

A simple container for options an IOstream can normally have. More...

#include <IOstreamOption.H>

Inheritance diagram for IOstreamOption:
Collaboration diagram for IOstreamOption:

Classes

class  versionNumber
 Representation of a major/minor version number. More...

Public Types

enum  streamFormat : char { ASCII = 0 , BINARY , COHERENT , UNKNOWN_FORMAT }
 Data format (ascii | binary | coherent). More...
enum  compressionType : char { UNCOMPRESSED = 0 , COMPRESSED }
 Compression treatment (UNCOMPRESSED | COMPRESSED). More...
enum  appendType : char {
  NO_APPEND = 0 , APPEND_APP , APPEND_ATE , NON_APPEND = NO_APPEND ,
  APPEND = APPEND_APP
}
 File appending (NO_APPEND | APPEND_APP | APPEND_ATE). More...
enum  atomicType : char { NON_ATOMIC = 0 , ATOMIC }
 Atomic operations (output). More...
enum class  floatFormat : unsigned { general = unsigned(0) , fixed = unsigned(std::ios_base::fixed) , scientific = unsigned(std::ios_base::scientific) }
 Float formats (eg, time directory name formats). More...

Public Member Functions

constexpr IOstreamOption (streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
 Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
constexpr IOstreamOption (streamFormat fmt, compressionType comp, versionNumber ver) noexcept
 Construct from components (format, compression, version).
constexpr IOstreamOption (streamFormat fmt, versionNumber ver, compressionType comp=compressionType::UNCOMPRESSED) noexcept
 Construct from components (format, version, compression).
 IOstreamOption (const IOstreamOption &opt, streamFormat fmt) noexcept
 Copy construct with change of format.
streamFormat format () const noexcept
 Get the current stream format.
streamFormat format (const streamFormat fmt) noexcept
 Set the stream format.
streamFormat format (const word &formatName)
 Set the stream format from string value.
compressionType compression () const noexcept
 Get the stream compression.
compressionType compression (const compressionType comp) noexcept
 Set the stream compression.
compressionType compression (const word &compName)
 Set the stream compression from string value.
versionNumber version () const noexcept
 Get the stream version.
versionNumber version (const versionNumber ver) noexcept
 Set the stream version.
versionNumber version (const token &tok)
 Set the stream version from token.

Static Public Member Functions

static floatFormat floatFormatEnum (const word &fmtName, const floatFormat deflt=floatFormat::general)
 Lookup floatFormat enum corresponding to the string (general | fixed | scientific).
static floatFormat floatFormatEnum (const word &key, const dictionary &dict, const floatFormat deflt=floatFormat::general)
 getOrDefault floatFormat from dictionary, warn only on bad enumeration.
static streamFormat formatEnum (const word &fmtName, const streamFormat deflt=streamFormat::ASCII)
 Lookup streamFormat enum corresponding to the string (ascii | binary).
static streamFormat formatEnum (const word &key, const dictionary &dict, const streamFormat deflt=streamFormat::ASCII)
 getOrDefault streamFormat from dictionary, warn only on bad enumeration.
static compressionType compressionEnum (const word &compName, const compressionType deflt=compressionType::UNCOMPRESSED)
 The compression enum corresponding to the string.
static compressionType compressionEnum (const word &key, const dictionary &dict, const compressionType deflt=compressionType::UNCOMPRESSED)
 getOrDefault compressionType from dictionary, warn only on bad enumeration.

Static Public Attributes

static const Enum< floatFormatfloatFormatNames
 Names for float formats (general, fixed, scientific).
static const Enum< streamFormatformatNames
 Stream format names (ascii, binary).
static const versionNumber currentVersion
 The current version number (2.0).

Detailed Description

A simple container for options an IOstream can normally have.

The format (ASCII | BINARY) is typically controlled by enumerated names (ascii, binary).

The compression (UNCOMPRESSED | COMPRESSED) is typically controlled by switch values (true/false, on/off, ...).

Source files

Definition at line 59 of file IOstreamOption.H.

Member Enumeration Documentation

◆ streamFormat

enum streamFormat : char

Data format (ascii | binary | coherent).

Enumerator
ASCII 

"ascii" (normal default)

BINARY 

"binary"

COHERENT 

"coherent"

UNKNOWN_FORMAT 

Definition at line 68 of file IOstreamOption.H.

◆ compressionType

enum compressionType : char

Compression treatment (UNCOMPRESSED | COMPRESSED).

Enumerator
UNCOMPRESSED 

compression = false

COMPRESSED 

compression = true

Definition at line 79 of file IOstreamOption.H.

◆ appendType

enum appendType : char

File appending (NO_APPEND | APPEND_APP | APPEND_ATE).

Enumerator
NO_APPEND 

no append (truncates existing)

APPEND_APP 

append (seek end each write)

APPEND_ATE 

append (seek end after open)

NON_APPEND 

old name for NO_APPEND

APPEND 

old name for APPEND_APP

Definition at line 88 of file IOstreamOption.H.

◆ atomicType

enum atomicType : char

Atomic operations (output).

Enumerator
NON_ATOMIC 

atomic = false

ATOMIC 

atomic = true

Definition at line 100 of file IOstreamOption.H.

◆ floatFormat

enum class floatFormat : unsigned
strong

Float formats (eg, time directory name formats).

Enumerator
general 

default float notation

fixed 

fixed-point notation

scientific 

scientific notation

Definition at line 109 of file IOstreamOption.H.

Constructor & Destructor Documentation

◆ IOstreamOption() [1/4]

IOstreamOption ( streamFormat fmt = streamFormat::ASCII,
compressionType comp = compressionType::UNCOMPRESSED )
inlineconstexprnoexcept

Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.

Note
non-explicit for convenient construction

Definition at line 355 of file IOstreamOption.H.

References ASCII, Foam::noexcept, and UNCOMPRESSED.

Referenced by IOstream::IOstream(), IOstream::IOstream(), and IOstreamOption().

Here is the caller graph for this function:

◆ IOstreamOption() [2/4]

IOstreamOption ( streamFormat fmt,
compressionType comp,
versionNumber ver )
inlineconstexprnoexcept

Construct from components (format, compression, version).

Definition at line 369 of file IOstreamOption.H.

References Foam::noexcept.

◆ IOstreamOption() [3/4]

IOstreamOption ( streamFormat fmt,
versionNumber ver,
compressionType comp = compressionType::UNCOMPRESSED )
inlineconstexprnoexcept

Construct from components (format, version, compression).

Definition at line 384 of file IOstreamOption.H.

References Foam::noexcept, and UNCOMPRESSED.

◆ IOstreamOption() [4/4]

IOstreamOption ( const IOstreamOption & opt,
streamFormat fmt )
inlinenoexcept

Copy construct with change of format.

Definition at line 399 of file IOstreamOption.H.

References IOstreamOption(), and Foam::noexcept.

Here is the call graph for this function:

Member Function Documentation

◆ floatFormatEnum() [1/2]

Foam::IOstreamOption::floatFormat floatFormatEnum ( const word & fmtName,
const floatFormat deflt = floatFormat::general )
static

Lookup floatFormat enum corresponding to the string (general | fixed | scientific).

If the string is not recognized, emit warning and return default. Silent if the string itself is empty.

Note
Can be used as constructor substitute for the enumeration

Definition at line 57 of file IOstreamOption.C.

References floatFormatNames, Foam::nl, and WarningInFunction.

Referenced by Time::readDict(), and ensightCase::options::timeFormat().

Here is the caller graph for this function:

◆ floatFormatEnum() [2/2]

Foam::IOstreamOption::floatFormat floatFormatEnum ( const word & key,
const dictionary & dict,
const floatFormat deflt = floatFormat::general )
static

getOrDefault floatFormat from dictionary, warn only on bad enumeration.

Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary

Definition at line 94 of file IOstreamOption.C.

References dict, and floatFormatNames.

◆ formatEnum() [1/2]

Foam::IOstreamOption::streamFormat formatEnum ( const word & fmtName,
const streamFormat deflt = streamFormat::ASCII )
static

Lookup streamFormat enum corresponding to the string (ascii | binary).

If the string is not recognized, emit warning and return default. Silent if the string itself is empty.

Note
Can be used as constructor substitute for the enumeration

Definition at line 106 of file IOstreamOption.C.

References formatNames, Foam::nl, and WarningInFunction.

Referenced by format(), VTKsurfaceFormatCore::formatOptions(), VTPsurfaceFormatCore::formatOptions(), and vtkWriter::vtkWriter().

Here is the caller graph for this function:

◆ formatEnum() [2/2]

Foam::IOstreamOption::streamFormat formatEnum ( const word & key,
const dictionary & dict,
const streamFormat deflt = streamFormat::ASCII )
static

getOrDefault streamFormat from dictionary, warn only on bad enumeration.

Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary

Definition at line 143 of file IOstreamOption.C.

References dict, and formatNames.

◆ compressionEnum() [1/2]

Foam::IOstreamOption::compressionType compressionEnum ( const word & compName,
const compressionType deflt = compressionType::UNCOMPRESSED )
static

The compression enum corresponding to the string.

Expects switch values (true/false, on/off, ...)

If the string is not recognized, emit warning and return default. Silent if the string itself is empty.

Note
Can be used as constructor substitute for the enumeration

Definition at line 155 of file IOstreamOption.C.

References COMPRESSED, Switch::find(), Foam::nl, UNCOMPRESSED, and WarningInFunction.

Referenced by compression().

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

◆ compressionEnum() [2/2]

Foam::IOstreamOption::compressionType compressionEnum ( const word & key,
const dictionary & dict,
const compressionType deflt = compressionType::UNCOMPRESSED )
static

getOrDefault compressionType from dictionary, warn only on bad enumeration.

Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary

Definition at line 188 of file IOstreamOption.C.

References COMPRESSED, dict, and UNCOMPRESSED.

◆ format() [1/3]

streamFormat format ( ) const
inlinenoexcept

Get the current stream format.

Definition at line 412 of file IOstreamOption.H.

References Foam::noexcept.

Referenced by CollidingParcel< ParcelType >::CollidingParcel(), ensightReadFile::detectBinaryHeader(), DSMCParcel< ParcelType >::DSMCParcel(), codeStream::evaluate(), findCellParticle::findCellParticle(), FIRECore::getFireLabel(), FIRECore::getFirePoint(), FIRECore::getFireString(), decomposedBlockData::getNumBlocks(), Foam::getPrimitive(), ensightReadFile::getTimeStepFooter(), ICharStream::ICharStream(), injectedParticle::injectedParticle(), ISpanStream::ISpanStream(), IStringStream::IStringStream(), IStringStream::IStringStream(), IStringStream::IStringStream(), ITstream::ITstream(), ITstream::ITstream(), ITstream::ITstream(), KinematicParcel< ParcelType >::KinematicParcel(), molecule::molecule(), MPPICParcel< ParcelType >::MPPICParcel(), OCharStream::OCharStream(), OCountStream::OCountStream(), Foam::operator>>(), PointIndexHit< point >::operator>>, OSHA1stream::OSHA1stream(), OSpanStream::OSpanStream(), OStringStream::OStringStream(), OTstream::OTstream(), IOobject::parseHeader(), Foam::processFlags(), ReactingParcel< ParcelType >::ReactingParcel(), decomposedBlockData::readBlock(), exprResultGlobals::readData(), particle< Type >::readData(), Foam::readEnsightString(), ensightSurfaceReader::readGeometry(), IOobject::readHeader(), DynamicList< T, SizeMin >::readList(), FixedList< T, N >::readList(), List< T >::readList(), PackedList< Width >::readList(), UList< T >::readList(), Matrix< Form, Type >::readMatrix(), Foam::setformat(), decomposedBlockData::skipBlockEntry(), solidParticle::solidParticle(), SprayParcel< ParcelType >::SprayParcel(), ThermoParcel< ParcelType >::ThermoParcel(), trackedParticle::trackedParticle(), UIPstreamBase::UIPstreamBase(), UOPstreamBase::UOPstreamBase(), wallBoundedParticle::wallBoundedParticle(), ABAQUSsurfaceFormat< Face >::write(), AC3DsurfaceFormat< Face >::write(), AC3DsurfaceFormat< Face >::write(), FIREMeshWriter::write(), GTSsurfaceFormat< Face >::write(), GTSsurfaceFormat< Face >::write(), NASsurfaceFormat< Face >::write(), OBJedgeFormat::write(), OBJsurfaceFormat< Face >::write(), OFFsurfaceFormat< Face >::write(), SMESHsurfaceFormat< Face >::write(), STARCDedgeFormat::write(), STARCDsurfaceFormat< Face >::write(), STLsurfaceFormat< Face >::write(), STLsurfaceFormat< Face >::write(), TRIsurfaceFormat< Face >::write(), TRIsurfaceFormat< Face >::write(), X3DsurfaceFormat< Face >::write(), decomposedBlockData::writeData(), decomposedBlockData::writeExtraHeaderContent(), decomposedBlockData::writeHeader(), IOobject::writeHeaderContent(), CompactIOField< T >::writeObject(), CompactIOList< T >::writeObject(), distributedTriSurfaceMesh::writeObject(), rigidBodyMeshMotion::writeObject(), and rigidBodyMeshMotionSolver::writeObject().

◆ format() [2/3]

streamFormat format ( const streamFormat fmt)
inlinenoexcept

Set the stream format.

Returns
the previous value

Definition at line 419 of file IOstreamOption.H.

◆ format() [3/3]

streamFormat format ( const word & formatName)
inline

Set the stream format from string value.

If the string is not recognized, emit warning and leave unchanged. Silent if the string itself is empty.

Returns
the previous value

Definition at line 433 of file IOstreamOption.H.

References formatEnum().

Here is the call graph for this function:

◆ compression() [1/3]

◆ compression() [2/3]

compressionType compression ( const compressionType comp)
inlinenoexcept

Set the stream compression.

Returns
the previous value

Definition at line 450 of file IOstreamOption.H.

◆ compression() [3/3]

compressionType compression ( const word & compName)
inline

Set the stream compression from string value.

If the string is not recognized, emit warning and leave unchanged. Silent if the string itself is empty.

Returns
the previous value

Definition at line 464 of file IOstreamOption.H.

References compressionEnum().

Here is the call graph for this function:

◆ version() [1/3]

◆ version() [2/3]

versionNumber version ( const versionNumber ver)
inlinenoexcept

Set the stream version.

Returns
the previous value

Definition at line 481 of file IOstreamOption.H.

◆ version() [3/3]

versionNumber version ( const token & tok)
inline

Set the stream version from token.

Returns
the previous value

Definition at line 493 of file IOstreamOption.H.

Member Data Documentation

◆ floatFormatNames

const Foam::Enum< Foam::IOstreamOption::floatFormat > floatFormatNames
static

Names for float formats (general, fixed, scientific).

Definition at line 225 of file IOstreamOption.H.

Referenced by floatFormatEnum(), and floatFormatEnum().

◆ formatNames

◆ currentVersion

const Foam::IOstreamOption::versionNumber currentVersion
static

The current version number (2.0).

Definition at line 235 of file IOstreamOption.H.


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