TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Sortie_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 <Sortie_Brute.h>
16#include <Process.h>
17#include <EntreeSortie.h>
18#include <sstream>
19
20using std::ostringstream;
21
22// In its implementation use an ostringstream. This is by far the simplest method.
24 Sortie()
25{
26 set_bin(true);
27
28 ostream_ = std::make_unique<std::ostringstream>();
29}
30
31
32/*! @brief returns a pointer to the internal data.
33 *
34 * The data is valid as long as no other write operation is done on the Sortie_Brute object.
35 *
36 */
37const char* Sortie_Brute::get_data() const
38{
39 const ostringstream& os = static_cast< const ostringstream& >(get_ostream());
40 string_ = std::string(os.str());
41 return string_.c_str();
42}
43
44unsigned Sortie_Brute::get_size() const
45{
46 const ostringstream& os = static_cast< const ostringstream& >(get_ostream());
47 return (unsigned)os.str().size();
48}
49
51{
52 if (!bin)
53 {
54 Cerr << "Error in Sortie_Brute::set_bin(bool bin) : only binary format supported. Use SChaine otherwise." << finl;
56 }
57 Sortie::set_bin(bin);
58}
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
unsigned get_size() const
const char * get_data() const
returns a pointer to the internal data.
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
std::string string_
ostream & get_ostream()
Definition Sortie.h:64
Sortie()
Definition Sortie.cpp:26
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
Definition Sortie.cpp:255
std::unique_ptr< ostream > ostream_
Definition Sortie.h:116