TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Lire.cpp
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Lire.h>
17#include <Synonyme_info.h>
18#include <Interprete_bloc.h>
19
20Implemente_instanciable(Lire,"Lire|Read",Interprete);
21// XD read interprete lire NO_BRACE Interpretor to read the a_object objet defined between the braces.
22// XD attr a_object chaine a_object REQ Object to be read.
23// XD attr bloc chaine bloc REQ Definition of the object.
24
25
26/*! @brief Calls the printOn method of the Interprete class.
27 *
28 */
29Sortie& Lire::printOn(Sortie& os) const
30{
31 return Interprete::printOn(os);
32}
33
34/*! @brief Calls the readOn method of the Interprete class.
35 *
36 */
38{
39 return Interprete::readOn(is);
40}
41
42/*! @brief Read an object.
43 *
44 */
46{
47 // Example in a data file:
48 // Lire name { ... }
49 Nom name;
50 is >> name; // The object name is read from the input stream is
51
52 if (objet_existant(name)) //name of an existing object -> read it
53 {
54 Objet_U& object=objet(name);
55 return is >> object; // Then "{ ... }" is read by the object readOn
56 }
57 else //not the name of an existing object -> read the type, create the object, then read it
58 {
59 DerObjU ref;
60 Nom type;
61 is >> type;
62 ref.typer(type);
63 //add the object to the current interpreter...
65 return is >> obj; // then read it
66 }
67}
68
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Objet_U & ajouter(const Nom &nom, DerObjU &object_to_add)
Adds object ob to the interpreter's object list and names it with nom.
static Interprete_bloc & interprete_courant()
Returns the Interprete_bloc currently being read from the data set.
Base class for "interpreter" objects.
Definition Interprete.h:38
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
static int objet_existant(const Nom &)
Returns 1 if the object exists, 0 otherwise. See Interprete_bloc::objet_global_existant().
Keyword to read an object, typically from a data file.
Definition Lire.h:25
Entree & interpreter(Entree &) override
Read an object.
Definition Lire.cpp:45
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Objet_U * typer(const char *nom_type)
Tries to create an instance of type "type".
friend class Entree
Definition Objet_U.h:71
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
Definition Sortie.h:52