Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::SimpleCsvReaderWriter Class Reference
Inheritance diagram for Arcane::SimpleCsvReaderWriter:
Collaboration diagram for Arcane::SimpleCsvReaderWriter:

Public Member Functions

 SimpleCsvReaderWriter (const Ref< SimpleTableInternal > &simple_table_internal)
bool writeTable (const Directory &dst, const String &file_name) override
 Method allowing writing a simple table to a file.
bool readTable (const Directory &src, const String &file_name) override
 Method allowing reading a file containing a simple table.
void clearInternal () override
 Method allowing clearing the content of the SimpleTableInternal object.
void print () override
 Method allowing writing the table to the standard output.
Integer precision () override
 Method allowing retrieval of the precision currently used for writing values.
void setPrecision (Integer precision) override
 Method allowing modification of the print precision.
bool isFixed () override
 Method allowing checking if the 'std::fixed' flag is active or not for writing values.
void setFixed (bool fixed) override
 Method allowing setting or unsetting the 'std::fixed' flag.
bool isForcedToUseScientificNotation () override
 Method allowing checking if the 'std::scientific' flag is active or not for writing values.
void setForcedToUseScientificNotation (bool use_scientific) override
 Method allowing setting or unsetting the 'std::scientific' flag.
String fileType () override
 Method allowing retrieval of the file type that will be written by the implementation. ("csv" will be returned for the csv implementation).
Ref< SimpleTableInternalinternal () override
 Method allowing retrieval of a reference to the SimpleTableInternal object used.
void setInternal (const Ref< SimpleTableInternal > &simple_table_internal) override
 Method allowing setting a reference to a SimpleTableInternal.

Protected Member Functions

bool _openFile (std::ifstream &stream, Directory directory, const String &file)
void _closeFile (std::ifstream &stream)
void _print (std::ostream &stream)

Protected Attributes

Ref< SimpleTableInternalm_simple_table_internal
char m_separator
Integer m_precision_print
bool m_is_fixed_print
bool m_scientific_notation
const String m_output_file_type = "csv"

Detailed Description

Definition at line 32 of file SimpleCsvReaderWriter.h.

Constructor & Destructor Documentation

◆ SimpleCsvReaderWriter() [1/2]

Arcane::SimpleCsvReaderWriter::SimpleCsvReaderWriter ( const Ref< SimpleTableInternal > & simple_table_internal)
inline

Definition at line 37 of file SimpleCsvReaderWriter.h.

◆ SimpleCsvReaderWriter() [2/2]

Arcane::SimpleCsvReaderWriter::SimpleCsvReaderWriter ( )
inline

Definition at line 48 of file SimpleCsvReaderWriter.h.

Member Function Documentation

◆ _closeFile()

void Arcane::SimpleCsvReaderWriter::_closeFile ( std::ifstream & stream)
protected

Definition at line 229 of file SimpleCsvReaderWriter.cc.

◆ _openFile()

bool Arcane::SimpleCsvReaderWriter::_openFile ( std::ifstream & stream,
Directory directory,
const String & file )
protected

Definition at line 222 of file SimpleCsvReaderWriter.cc.

◆ _print()

void Arcane::SimpleCsvReaderWriter::_print ( std::ostream & stream)
protected

Definition at line 235 of file SimpleCsvReaderWriter.cc.

◆ clearInternal()

void Arcane::SimpleCsvReaderWriter::clearInternal ( )
overridevirtual

Method allowing clearing the content of the SimpleTableInternal object.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 146 of file SimpleCsvReaderWriter.cc.

Referenced by readTable().

Here is the caller graph for this function:

◆ fileType()

String Arcane::SimpleCsvReaderWriter::fileType ( )
inlineoverridevirtual

Method allowing retrieval of the file type that will be written by the implementation. ("csv" will be returned for the csv implementation).

Returns
String The file type/extension used.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 75 of file SimpleCsvReaderWriter.h.

Referenced by readTable(), and writeTable().

Here is the caller graph for this function:

◆ internal()

Ref< SimpleTableInternal > Arcane::SimpleCsvReaderWriter::internal ( )
overridevirtual

Method allowing retrieval of a reference to the SimpleTableInternal object used.

Returns
Ref<SimpleTableInternal> A copy of the reference.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 205 of file SimpleCsvReaderWriter.cc.

◆ isFixed()

bool Arcane::SimpleCsvReaderWriter::isFixed ( )
overridevirtual

Method allowing checking if the 'std::fixed' flag is active or not for writing values.

Returns
true If yes.
false If no.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 178 of file SimpleCsvReaderWriter.cc.

◆ isForcedToUseScientificNotation()

bool Arcane::SimpleCsvReaderWriter::isForcedToUseScientificNotation ( )
overridevirtual

Method allowing checking if the 'std::scientific' flag is active or not for writing values.

Returns
true If yes.
false If no.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 190 of file SimpleCsvReaderWriter.cc.

◆ precision()

Integer Arcane::SimpleCsvReaderWriter::precision ( )
overridevirtual

Method allowing retrieval of the precision currently used for writing values.

Returns
Integer The precision.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 161 of file SimpleCsvReaderWriter.cc.

Referenced by setPrecision().

Here is the caller graph for this function:

◆ print()

void Arcane::SimpleCsvReaderWriter::print ( )
overridevirtual

Method allowing writing the table to the standard output.

The writing format is free (for the csv implementation, the writing is done the same way as in a csv file).

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 152 of file SimpleCsvReaderWriter.cc.

◆ readTable()

bool Arcane::SimpleCsvReaderWriter::readTable ( const Directory & src,
const String & file_name )
overridevirtual

Method allowing reading a file containing a simple table.

The extension will be added by the implementation.

A call to SimpleTableInternal::clear() must be performed before reading.

The elements that must be retrieved are:

  • row names (m_row_names),
  • column names (m_column_names),
  • table name (m_table_name),
  • table values (m_values).

The elements that must be deduced if not retrieved are:

  • row sizes (m_row_sizes),
  • column sizes (m_column_sizes).

Default deduction for m_row_sizes:

  • len(m_row_sizes) = len(m_row_names)
  • m_row_sizes[*] = m_values.dim2Size()

Default deduction for m_column_sizes:

  • len(m_column_sizes) = len(m_column_names)
  • m_column_sizes[*] = m_values.dim1Size()
Parameters
srcThe source directory.
file_nameThe file name (without extension).
Returns
true If the file was successfully read.
false If the file could not be read.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 42 of file SimpleCsvReaderWriter.cc.

References clearInternal(), fileType(), Arcane::AbstractArray< T >::size(), Arcane::String::split(), and Arcane::Array< T >::subConstView().

Here is the call graph for this function:

◆ setFixed()

void Arcane::SimpleCsvReaderWriter::setFixed ( bool fixed)
overridevirtual

Method allowing setting or unsetting the 'std::fixed' flag.

For both the 'print()' method and the 'writetable()' method.

This flag allows 'forcing' the number of digits after the comma to the desired precision. For example, if 'setPrecision(4)' was called, and 'setFixed(true)' is called, the print of '6.1' will yield '6.1000'.

Warning
The "std::fixed" flag modifies the behavior of "setPrecision()"; if the "std::fixed" flag is disabled, the precision defines the total number of digits (before and after the comma); if the "std::fixed" flag is enabled, the precision defines the number of digits after the comma. Therefore, attention must be paid when using "std::numeric_limits<Real>::max_digits10" (for writing) or "std::numeric_limits<Real>::digits10" (for reading), which should be used without the "std::fixed" flag.
Parameters
fixedWhether the 'std::fixed' flag should be set or not.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 184 of file SimpleCsvReaderWriter.cc.

◆ setForcedToUseScientificNotation()

void Arcane::SimpleCsvReaderWriter::setForcedToUseScientificNotation ( bool use_scientific)
overridevirtual

Method allowing setting or unsetting the 'std::scientific' flag.

For both the 'print()' method and the 'writetable()' method.

This flag allows 'forcing' the display of values in scientific notation during writing.

Parameters
use_scientificWhether the 'std::scientific' flag should be set or not.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 196 of file SimpleCsvReaderWriter.cc.

◆ setInternal()

void Arcane::SimpleCsvReaderWriter::setInternal ( const Ref< SimpleTableInternal > & simple_table_internal)
overridevirtual

Method allowing setting a reference to a SimpleTableInternal.

Parameters
simple_table_internalThe reference to a SimpleTableInternal.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 211 of file SimpleCsvReaderWriter.cc.

References ARCANE_FATAL, and Arcane::RefImpl< InstanceType, RefClassType, ImplTagId >::isNull().

Here is the call graph for this function:

◆ setPrecision()

void Arcane::SimpleCsvReaderWriter::setPrecision ( Integer precision)
overridevirtual

Method allowing modification of the print precision.

For both the 'print()' method and the 'writetable()' method.

Warning
The "std::fixed" flag modifies the behavior of "setPrecision()"; if the "std::fixed" flag is disabled, the precision defines the total number of digits (before and after the comma); if the "std::fixed" flag is enabled, the precision defines the number of digits after the comma. Therefore, attention must be paid when using "std::numeric_limits<Real>::max_digits10" (for writing) or "std::numeric_limits<Real>::digits10" (for reading), which should be used without the "std::fixed" flag.
Parameters
precisionThe new precision.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 167 of file SimpleCsvReaderWriter.cc.

References precision().

Here is the call graph for this function:

◆ writeTable()

bool Arcane::SimpleCsvReaderWriter::writeTable ( const Directory & dst,
const String & file_name )
overridevirtual

Method allowing writing a simple table to a file.

The extension will be added by the implementation.

The destination directory will be created by the implementation if it does not exist.

The SimpleTableInternal elements that must be written are:

  • row names (m_row_names),
  • column names (m_column_names),
  • table name (m_table_name),
  • table values (m_values).

Other SimpleTableInternal elements are not mandatory.

Parameters
dstThe destination directory.
file_nameThe file name (without extension).
Returns
true If the file was successfully written.
false If the file could not be written.

Implements Arcane::ISimpleTableReaderWriter.

Definition at line 29 of file SimpleCsvReaderWriter.cc.

References Arcane::Directory::file(), and fileType().

Here is the call graph for this function:

Member Data Documentation

◆ m_is_fixed_print

bool Arcane::SimpleCsvReaderWriter::m_is_fixed_print
protected

Definition at line 93 of file SimpleCsvReaderWriter.h.

◆ m_output_file_type

const String Arcane::SimpleCsvReaderWriter::m_output_file_type = "csv"
protected

Definition at line 96 of file SimpleCsvReaderWriter.h.

◆ m_precision_print

Integer Arcane::SimpleCsvReaderWriter::m_precision_print
protected

Definition at line 92 of file SimpleCsvReaderWriter.h.

◆ m_scientific_notation

bool Arcane::SimpleCsvReaderWriter::m_scientific_notation
protected

Definition at line 94 of file SimpleCsvReaderWriter.h.

◆ m_separator

char Arcane::SimpleCsvReaderWriter::m_separator
protected

Definition at line 90 of file SimpleCsvReaderWriter.h.

◆ m_simple_table_internal

Ref<SimpleTableInternal> Arcane::SimpleCsvReaderWriter::m_simple_table_internal
protected

Definition at line 88 of file SimpleCsvReaderWriter.h.


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