TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Entree Class Reference

Class defining operators and methods for all reading operation in an input flow (file, keyboard communication buffer, etc.). More...

#include <Entree.h>

Inheritance diagram for Entree:
[legend]
Collaboration diagram for Entree:
[legend]

Public Types

enum  Error_Action { ERROR_EXIT , ERROR_CONTINUE , ERROR_EXCEPTION }

Public Member Functions

 Entree ()
 Entree (istream &is)
 Entree (const Entree &is)
virtual ~Entree ()
void set_bin (bool bin) override
 Changes the file write mode.
Entreeoperator= (istream &is)
Entreeoperator= (Entree &is)
virtual istream & get_istream ()
virtual const istream & get_istream () const
void set_istream (istream *is)
Entreeoperator>> (Entree &(*f)(Entree &))
Entreeoperator>> (istream &(*f)(istream &))
Entreeoperator>> (ios &(*f)(ios &))
template<typename T>
Entreeoperator>> (const TRUST_Ref< T > &)
Entreeoperator>> (const TRUST_Ref_Objet_U &)
virtual Entreeoperator>> (int &ob)
virtual Entreeoperator>> (long &ob)
virtual Entreeoperator>> (long long &ob)
virtual Entreeoperator>> (float &ob)
virtual Entreeoperator>> (double &ob)
virtual Entreeoperator>> (std::string &ob)
virtual Entreeoperator>> (Objet_U &ob) final
virtual int get (int *ob, std::streamsize n)
virtual int get (long *ob, std::streamsize n)
virtual int get (long long *ob, std::streamsize n)
virtual int get (float *ob, std::streamsize n)
virtual int get (double *ob, std::streamsize n)
virtual int get (char *buf, std::streamsize bufsize)
 Reads a string from ostream_. bufsize is the size of the buffer allocated for ob (including.
virtual int eof ()
virtual int jumpOfLines ()
virtual int fail ()
virtual int good ()
virtual void set_check_types (bool flag)
 Indicates whether the stream should verify the types of read objects (ints and floating-point numbers).
bool check_types () const
virtual void set_error_action (Error_Action)
 Changes the error behaviour of the input; see error_handle_() and get_error_action().
Error_Action get_error_action ()
 Returns error_action_ for this input (allows modifying it and restoring the previous value afterwards).
 operator istream & ()
istream & putback (char ch)
bool get_diffuse ()
virtual void set_diffuse (bool diffuse)
 Sets the diffuse flag for this input stream.
Public Member Functions inherited from AbstractIO
bool is_64b () const
virtual void set_64b (bool is_64b)
bool is_bin ()
void set_avoid_conversion (bool avoid)
bool avoid_conversion ()

Protected Member Functions

int error_handle (int fail_flag)
virtual int error_handle_ (int fail_flag)
 This function is called by operator>>, get, get_nom, ouvrir, fermer, lire, etc.
Protected Member Functions inherited from AbstractIO
 AbstractIO ()
virtual ~AbstractIO ()
template<typename _TYPE_>
bool must_convert () const
 Whether to convert an int into a long when reading/writing out data.

Protected Attributes

bool check_types_ = false
Error_Action error_action_
bool diffuse_
Protected Attributes inherited from AbstractIO
bool bin_ = false
 Is this a binary flux?
bool is_64b_
 Will we be reading/writing in 64b? (Init in ctor to avoid including arch.h probably).
bool avoid_conversion_ = false

Detailed Description

Class defining operators and methods for all reading operation in an input flow (file, keyboard communication buffer, etc.).

See also
Sortie

Definition at line 41 of file Entree.h.

Member Enumeration Documentation

◆ Error_Action

Enumerator
ERROR_EXIT 
ERROR_CONTINUE 
ERROR_EXCEPTION 

Definition at line 93 of file Entree.h.

Constructor & Destructor Documentation

◆ Entree() [1/3]

Entree::Entree ( )

Definition at line 24 of file Entree.cpp.

◆ Entree() [2/3]

Entree::Entree ( istream & is)

Definition at line 31 of file Entree.cpp.

◆ Entree() [3/3]

Entree::Entree ( const Entree & is)

Definition at line 36 of file Entree.cpp.

◆ ~Entree()

Entree::~Entree ( )
virtual

Definition at line 277 of file Entree.cpp.

Member Function Documentation

◆ check_types()

bool Entree::check_types ( ) const
inline

Definition at line 92 of file Entree.h.

◆ eof()

int Entree::eof ( )
virtual

Reimplemented in Entree_complete, Entree_Fichier_base, and Lec_Diffuse_base.

Definition at line 256 of file Entree.cpp.

◆ error_handle()

int Entree::error_handle ( int fail_flag)
inlineprotected

Definition at line 105 of file Entree.h.

◆ error_handle_()

int Entree::error_handle_ ( int fail_flag)
protectedvirtual

This function is called by operator>>, get, get_nom, ouvrir, fermer, lire, etc.

.. on failure (when fail() is set). It returns 0 if an error occurred (go through error_handle() which handles inline the case where there is no error), and 1 if there is no error. (for coding convenience, one writes "return error_handle(fail());" It can be configured to:

  • return "0" on error and continue code execution (case of legacy code that does not handle exceptions but periodically tests the fail() flag) In this case, operator>> methods continue execution even on failure, and the content of the read variables is undefined!
  • call Process::exit() (case of a code section where no error handling is desired and everything is assumed to succeed)
  • throw an exception (allows rigorous error handling and optimal user feedback depending on context)
See also
set_error_action()

Definition at line 339 of file Entree.cpp.

◆ fail()

int Entree::fail ( )
virtual

Reimplemented in Entree_complete, Entree_Fichier_base, and Lec_Diffuse_base.

Definition at line 263 of file Entree.cpp.

◆ get() [1/6]

int Entree::get ( char * ob,
std::streamsize bufsize )
virtual

Reads a string from ostream_. bufsize is the size of the buffer allocated for ob (including.

the final null character). The string always contains a null character even on failure. The method returns 1 if reading is successful, 0 otherwise. If the buffer is too small, we currently call exit(), but in the future we could test: if strlen(ob)==bufsize-1, then call lire() again until the end is reached. If the next lire() returns a string of length zero, it means the string length was exactly bufsize-1. Warning: the behaviour differs between binary and ASCII mode. In binary mode, the string is read until the next '\0'. In ASCII mode, the string is read until the next separator (space, tab, newline).

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 103 of file Entree.cpp.

◆ get() [2/6]

int Entree::get ( double * ob,
std::streamsize n )
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 219 of file Entree.cpp.

◆ get() [3/6]

int Entree::get ( float * ob,
std::streamsize n )
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 225 of file Entree.cpp.

◆ get() [4/6]

int Entree::get ( int * ob,
std::streamsize n )
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 222 of file Entree.cpp.

◆ get() [5/6]

int Entree::get ( long * ob,
std::streamsize n )
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 228 of file Entree.cpp.

◆ get() [6/6]

int Entree::get ( long long * ob,
std::streamsize n )
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 231 of file Entree.cpp.

◆ get_diffuse()

bool Entree::get_diffuse ( )
inline

Definition at line 99 of file Entree.h.

◆ get_error_action()

Entree::Error_Action Entree::get_error_action ( )

Returns error_action_ for this input (allows modifying it and restoring the previous value afterwards).

Definition at line 371 of file Entree.cpp.

◆ get_istream() [1/2]

istream & Entree::get_istream ( )
virtual

Reimplemented in LecFicDiffuse.

Definition at line 41 of file Entree.cpp.

◆ get_istream() [2/2]

const istream & Entree::get_istream ( ) const
virtual

Reimplemented in LecFicDiffuse.

Definition at line 46 of file Entree.cpp.

◆ good()

int Entree::good ( )
virtual

Reimplemented in Entree_complete, Entree_Fichier_base, and Lec_Diffuse_base.

Definition at line 270 of file Entree.cpp.

◆ jumpOfLines()

int Entree::jumpOfLines ( )
virtual

Definition at line 238 of file Entree.cpp.

◆ operator istream &()

Entree::operator istream & ( )
inline

Definition at line 97 of file Entree.h.

◆ operator=() [1/2]

Entree & Entree::operator= ( Entree & is)

Definition at line 80 of file Entree.cpp.

◆ operator=() [2/2]

Entree & Entree::operator= ( istream & is)

Definition at line 72 of file Entree.cpp.

◆ operator>>() [1/12]

template<typename T>
Entree & Entree::operator>> ( const TRUST_Ref< T > & )
inline

Definition at line 65 of file Entree.h.

◆ operator>>() [2/12]

Entree & Entree::operator>> ( const TRUST_Ref_Objet_U & )
inline

Definition at line 67 of file Entree.h.

◆ operator>>() [3/12]

Entree & Entree::operator>> ( double & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 216 of file Entree.cpp.

◆ operator>>() [4/12]

Entree & Entree::operator>> ( Entree &(* )(Entree &))

Definition at line 55 of file Entree.cpp.

◆ operator>>() [5/12]

Entree & Entree::operator>> ( float & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 224 of file Entree.cpp.

◆ operator>>() [6/12]

Entree & Entree::operator>> ( int & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 221 of file Entree.cpp.

◆ operator>>() [7/12]

Entree & Entree::operator>> ( ios &(* )(ios &))

Definition at line 65 of file Entree.cpp.

◆ operator>>() [8/12]

Entree & Entree::operator>> ( istream &(* )(istream &))

Definition at line 60 of file Entree.cpp.

◆ operator>>() [9/12]

Entree & Entree::operator>> ( long & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 227 of file Entree.cpp.

◆ operator>>() [10/12]

Entree & Entree::operator>> ( long long & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 230 of file Entree.cpp.

◆ operator>>() [11/12]

Entree & Entree::operator>> ( Objet_U & ob)
finalvirtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 236 of file Entree.cpp.

◆ operator>>() [12/12]

Entree & Entree::operator>> ( std::string & ob)
virtual

Reimplemented in EChaineJDD, Entree_complete, and Lec_Diffuse_base.

Definition at line 234 of file Entree.cpp.

◆ putback()

istream & Entree::putback ( char ch)
inline

Definition at line 98 of file Entree.h.

◆ set_bin()

void Entree::set_bin ( bool bin)
overridevirtual

Changes the file write mode.

This method can be called at any time.

Reimplemented from AbstractIO.

Reimplemented in Entree_Brute, Entree_complete, and Lec_Diffuse_base.

Definition at line 291 of file Entree.cpp.

◆ set_check_types()

void Entree::set_check_types ( bool flag)
virtual

Indicates whether the stream should verify the types of read objects (ints and floating-point numbers).

Example: the input contains 123.456 123.456 int i; check_types(0); is >> i; // i contains 123 check_types(1); is >> i; // Error: reads the string 123.456 and tries to convert it to int See operator>>(int &)

Reimplemented in Entree_complete, and Lec_Diffuse_base.

Definition at line 313 of file Entree.cpp.

◆ set_diffuse()

void Entree::set_diffuse ( bool diffuse)
virtual

Sets the diffuse flag for this input stream.

This virtual method does nothing in the base class; see override in Lec_Diffuse_base.

Parameters
diffuseWhether to diffuse data to other processes.

Reimplemented in Lec_Diffuse_base.

Definition at line 409 of file Entree.cpp.

◆ set_error_action()

void Entree::set_error_action ( Entree::Error_Action action)
virtual

Changes the error behaviour of the input; see error_handle_() and get_error_action().

Reimplemented in Entree_complete.

Definition at line 379 of file Entree.cpp.

◆ set_istream()

void Entree::set_istream ( istream * is)

Definition at line 50 of file Entree.cpp.

Member Data Documentation

◆ check_types_

bool Entree::check_types_ = false
protected

Definition at line 112 of file Entree.h.

◆ diffuse_

bool Entree::diffuse_
protected

Definition at line 114 of file Entree.h.

◆ error_action_

Error_Action Entree::error_action_
protected

Definition at line 113 of file Entree.h.


The documentation for this class was generated from the following files:
  • /home/docs/trust-code/src/Kernel/Utilitaires/Entree.h
  • /home/docs/trust-code/src/Kernel/Utilitaires/Entree.cpp