TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
OBuffer.h
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
16#ifndef OBuffer_included
17#define OBuffer_included
18
19
20#include <Sortie.h>
21#include <sstream>
22//using namespace std;
23
24class OBuffer : public Sortie
25{
26
27public:
28 OBuffer();
29 void new_buffer();
30 void precision(int) override;
31 int get_precision();
32 const char* str();
33 int len();
34 void put_null_char();
35 Sortie& flush() override;
36 // Override to allow setting bin_, even if already open:
37 void set_bin(bool bin) override { bin_ = bin; }
38
39protected:
40
41private:
42 int precision_; ///< used to keep current precision when new_buffer() is called
43
44 /*! This pointer is just a (typed) view on the smart ptr hold by the base class (Sortie).
45 * The base class is managing the memory.
46 */
47 std::ostringstream* buf_ = nullptr;
48
49 std::string string_;
50};
51
52#endif
bool bin_
Is this a binary flux?
Definition AbstractIO.h:50
int len()
Definition OBuffer.cpp:76
int get_precision()
Definition OBuffer.cpp:40
void new_buffer()
Definition OBuffer.cpp:24
const char * str()
Renvoie un pointeur sur le debut du buffer.
Definition OBuffer.cpp:68
Sortie & flush() override
Force l'ecriture sur disque des donnees dans le tampon Utilise l'implementation de la classe ofstream...
Definition OBuffer.cpp:48
void put_null_char()
ajoute le caractere nul a la fin du buffer pour en faire une chaine de caracteres valide.
Definition OBuffer.cpp:59
OBuffer()
Definition OBuffer.cpp:18
void precision(int) override
Definition OBuffer.cpp:34
void set_bin(bool bin) override
Definition OBuffer.h:37
Sortie()
Definition Sortie.cpp:26