TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Entree_Brute.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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#include <Entree_Brute.h>
16#include <Process.h>
17#include <EntreeSortie.h>
18#include <sstream>
19
20using std::istringstream;
21
23 Entree(), data_(0)
24{
25 set_bin(1);
26 istrstream_ = new istringstream();
28}
29
30
32{
33 delete[] data_;
34}
35
37{
38 if (!bin)
39 {
40 Cerr << "Error in Entree_Brute::set_bin(int bin) : only binary format supported. Use EChaine otherwise." << finl;
42 }
43 Entree::set_bin(bin);
44}
45
46void Entree_Brute::set_data(const char * data, unsigned sz)
47{
48 if(data_)
49 {
50 // For now forbid multiple calls ... could try deleting data_
51 //Cerr << "Entree_Brute::set_data(): Multiple calls forbidden! " << finl;
52 //Process::exit(-1);
53 delete[] data_;
54 if (istrstream_)
55 delete istrstream_;
56 istrstream_ = new istringstream();
58 }
59
60 const std::istream& iss = get_istream();
61 std::streambuf * sb = iss.rdbuf();
62
63 data_ = new char[sz];
64 std::copy(data, data+sz, data_);
65 sb->pubsetbuf(data_, sz);
66}
istringstream * istrstream_
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
void set_data(const char *data, unsigned sz)
~Entree_Brute() override
Entree()
Definition Entree.cpp:24
virtual istream & get_istream()
Definition Entree.cpp:41
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
Definition Entree.cpp:291
void set_istream(istream *is)
Definition Entree.cpp:50
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455