TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Entree_complete.h
1/****************************************************************************
2* Copyright (c) 2026, 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#ifndef Entree_complete_included
17#define Entree_complete_included
18
19#include <EChaine.h>
20
21/*! @brief Cette classe se comporte comme EChaine tant que l'on n'est pas a la fin de la chaine.
22 *
23 * La suite est lue dans entree2 passee en parametre.
24 * check_types() et error_action() sont identiques a ceux de entree2
25 *
26 */
27
29{
30public:
31 Entree_complete(const char *str, Entree& entree2);
32 ~Entree_complete() override;
33
34 using Entree::operator>>;
35
36 Entree& operator>>(int& ob) override;
37 Entree& operator>>(long& ob) override;
38 Entree& operator>>(long long& ob) override;
39 Entree& operator>>(float& ob) override;
40 Entree& operator>>(double& ob) override;
41
42 int get(int *ob, std::streamsize n) override;
43 int get(long *ob, std::streamsize n) override;
44 int get(long long*ob, std::streamsize n) override;
45 int get(float *ob, std::streamsize n) override;
46 int get(double *ob, std::streamsize n) override;
47 int get(char *buf, std::streamsize bufsize) override;
48
49 int eof() override;
50 int fail() override;
51 int good() override;
52
53 void set_bin(bool bin) override;
54 void set_error_action(Error_Action) override;
55 void set_check_types(bool flag) override;
56
57protected:
59 // Si num_entree_ == 0, on est en train de lire dans chaine_str, sinon dans entree2_
63 // Reference a la deuxieme entree (on n'est pas proprietaire de l'objet pointe)
65
66private:
67 template <typename _TYPE_>
68 int get_template(_TYPE_ *ob, std::streamsize n);
69
70 template <typename _TYPE_>
71 Entree& operator_template(_TYPE_&ob);
72};
73
74template<typename _TYPE_>
75int Entree_complete::get_template(_TYPE_ *ob, std::streamsize n)
76{
77 // Je fais une boucle pour permettre au tableau de valeurs d'etre a cheval sur les deux entrees:
78 for (std::streamsize i = 0; i < n; i++)
79 {
80 Entree& is = get_input();
81 if (! is.get(ob+i, 1))
82 return 0;
83 }
84 return 1;
85}
86
87template<typename _TYPE_>
88Entree& Entree_complete::operator_template(_TYPE_& ob)
89{
90 Entree& is = get_input();
91 is >> ob;
92 return *this;
93}
94
95#endif /* Entree_complete_included */
Une entree dont la source est une chaine de caracteres.
Definition EChaine.h:31
int fail() override
void set_bin(bool bin) override
Il est interdit de changer de type d'entree.
int eof() override
Entree & operator>>(int &ob) override
int good() override
void set_error_action(Error_Action) override
affecte la valeur aux deux entrees sources Attention, la valeur de entree2 est modifiee !
int get(int *ob, std::streamsize n) override
Entree_complete(const char *str, Entree &entree2)
~Entree_complete() override
void set_check_types(bool flag) override
affecte le drapeau aux deux entrees sources Attention, le drapeau de entree2 est modifie !
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Entree()
Definition Entree.cpp:24
virtual int get(int *ob, std::streamsize n)
Definition Entree.cpp:222
Error_Action
Definition Entree.h:93