Public Member Functions | Private Member Functions | Private Attributes | Friends
CSV Class Reference

Templated CSV container data entry. Reference column is always a scalar, e.g. time. More...

Collaboration diagram for CSV:
Collaboration graph
[legend]

Public Member Functions

 TypeName ("csvFile")
 Runtime type information. More...
 
 CSV (const word &entryName, const dictionary &dict, const word &ext="Coeffs")
 Construct from entry name and dictionary. More...
 
 CSV (const CSV< Type > &tbl)
 Copy constructor. More...
 
virtual tmp< DataEntry< Type > > clone () const
 Construct and return a clone. More...
 
virtual ~CSV ()
 Destructor. More...
 
virtual const fileNamefName () const
 Return const access to the file name. More...
 
virtual void writeData (Ostream &os) const
 Write in dictionary format. More...
 

Private Member Functions

void read ()
 Read csv data table. More...
 
Type readValue (const List< string > &)
 Read the next value from the splitted string. More...
 
void operator= (const CSV< Type > &)
 Disallow default bitwise assignment. More...
 
label readValue (const List< string > &splitted)
 
scalar readValue (const List< string > &splitted)
 

Private Attributes

dictionary coeffs_
 Coefficients dictionary (for convenience on reading) More...
 
label nHeaderLine_
 Number header lines. More...
 
label refColumn_
 Column of the time. More...
 
labelList componentColumns_
 Labels of the components. More...
 
char separator_
 Separator character. More...
 
bool mergeSeparators_
 Merge separators flag, e.g. ',,,' becomes ','. More...
 
fileName fName_
 File name for csv table. More...
 

Friends

Ostreamoperator (Ostream &os, const CSV< Type > &cnst)
 Ostream Operator. More...
 

Detailed Description

Templated CSV container data entry. Reference column is always a scalar, e.g. time.

    <entryName> csvFile;
    <entryName>Coeffs
    {
        nHeaderLine         4;          // number of header lines
        refColumn           0;          // reference column index
        componentColumns    (1 2 3);    // component column indices
        separator           ",";        // optional (defaults to ",")
        mergeSeparators     no;         // merge multiple separators
        fileName            "fileXYZ";  // name of csv data file
        outOfBounds         clamp;      // optional out-of-bounds handling
        interpolationScheme linear;     // optional interpolation scheme
    }
Source files

Definition at line 65 of file CSV.H.

Constructor & Destructor Documentation

◆ CSV() [1/2]

CSV ( const word entryName,
const dictionary dict,
const word ext = "Coeffs" 
)

Construct from entry name and dictionary.

◆ CSV() [2/2]

CSV ( const CSV< Type > &  tbl)

Copy constructor.

Definition at line 230 of file CSV.C.

◆ ~CSV()

~CSV ( )
virtual

Destructor.

Definition at line 245 of file CSV.C.

Member Function Documentation

◆ read()

void read ( )
private

Read csv data table.

Definition at line 88 of file CSV.C.

References DynamicList::append(), Foam::exit(), string::expand(), Foam::FatalIOError, FatalIOErrorInFunction, found, ISstream::getLine(), IOstream::good(), Foam::max(), n, Foam::pos(), readScalar, and x.

Here is the call graph for this function:

◆ readValue() [1/3]

Type readValue ( const List< string > &  )
private

Read the next value from the splitted string.

◆ operator=()

void operator= ( const CSV< Type > &  )
private

Disallow default bitwise assignment.

◆ TypeName()

TypeName ( "csvFile"  )

Runtime type information.

◆ clone()

virtual tmp<DataEntry<Type> > clone ( ) const
inlinevirtual

Construct and return a clone.

Definition at line 139 of file CSV.H.

◆ fName()

const Foam::fileName & fName ( ) const
virtual

Return const access to the file name.

Definition at line 252 of file CSV.C.

◆ writeData()

void writeData ( Ostream os) const
virtual

Write in dictionary format.

Definition at line 60 of file CSVIO.C.

References Foam::decrIndent(), Foam::endl(), IOstream::format(), Foam::incrIndent(), Foam::indent(), Foam::name(), Foam::nl, writeData(), and Ostream::writeKeyword().

Here is the call graph for this function:

◆ readValue() [2/3]

label readValue ( const List< string > &  splitted)
private

Definition at line 35 of file CSV.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::readLabel(), and List::size().

Here is the call graph for this function:

◆ readValue() [3/3]

Type readValue ( const List< string > &  splitted)
private

Definition at line 49 of file CSV.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::readScalar(), and List::size().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator

Ostream& operator ( Ostream os,
const CSV< Type > &  cnst 
)
friend

Ostream Operator.

Field Documentation

◆ coeffs_

dictionary coeffs_
private

Coefficients dictionary (for convenience on reading)

Definition at line 86 of file CSV.H.

◆ nHeaderLine_

label nHeaderLine_
private

Number header lines.

Definition at line 89 of file CSV.H.

◆ refColumn_

label refColumn_
private

Column of the time.

Definition at line 92 of file CSV.H.

◆ componentColumns_

labelList componentColumns_
private

Labels of the components.

Definition at line 95 of file CSV.H.

◆ separator_

char separator_
private

Separator character.

Definition at line 98 of file CSV.H.

◆ mergeSeparators_

bool mergeSeparators_
private

Merge separators flag, e.g. ',,,' becomes ','.

Definition at line 101 of file CSV.H.

◆ fName_

fileName fName_
private

File name for csv table.

Definition at line 104 of file CSV.H.


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