TrioCFD 1.9.9_beta
TrioCFD documentation
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 This class behaves like EChaine until the end of the string is reached.
22 *
23 * The remainder is read from entree2 passed as parameter.
24 * check_types() and error_action() are identical to those of 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 // If num_entree_ == 0, we are reading from chaine_str, otherwise from entree2_
63 // Reference to the second input (we do not own the pointed object)
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 // Loop to allow the value array to span across both inputs:
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 */
An input stream whose source is a character string.
Definition EChaine.h:31
int fail() override
void set_bin(bool bin) override
Changing the type of input is forbidden.
int eof() override
Entree & operator>>(int &ob) override
int good() override
void set_error_action(Error_Action) override
Sets the value on both source inputs. Warning, the value of entree2 is modified!
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
Sets the flag on both source inputs. Warning, the flag of entree2 is modified!
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