TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Typer_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 <Typer_Lire.h>
17#include <Synonyme_info.h>
18#include <Interprete_bloc.h>
19
20Implemente_instanciable(Typer_Lire,"Typer_Lire|Type_Read",Lire);
21
22/*! @brief Calls the printOn method of the Interprete class.
23 *
24 */
26{
27 return Lire::printOn(os);
28}
29
30/*! @brief Calls the readOn method of the Interprete class.
31 *
32 */
34{
35 return Lire::readOn(is);
36}
37
38/*! @brief Read an object.
39 *
40 */
42{
43 // Example in a data file:
44 // Typer_Lire name type { ... }
45 Nom name;
46 is >> name; // The object name is read from the input stream is
47
48 if (objet_existant(name)) //name of an existing object -> read it
49 {
50 Objet_U& object=objet(name);
51 return is >> object; // Then "{ ... }" is read by the object readOn
52 }
53 else //not the name of an existing object -> read the type, create the object, then read it
54 {
55 // Lire name type { ... }
56 DerObjU ref;
57 Nom type;
58 is >> type;
59 if (type=="{")
60 {
61 Objet_U& object=objet(name); // To crash with the usual error message
62 return is >> object;
63 }
64 ref.typer(type);
65 //add the object to the current interpreter...
67 return is >> obj; //and read it
68 }
69}
70
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.
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
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
Keyword to read an object, typically from a data file.
Definition Typer_Lire.h:25
Entree & interpreter(Entree &) override
Read an object.