Eclipse SUMO - Simulation of Urban MObility
OutputDevice_String.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2009-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // An output device that encapsulates a stringstream
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <sstream>
24 #include <string>
25 #include "OutputDevice_String.h"
26 
27 
28 // ===========================================================================
29 // method definitions
30 // ===========================================================================
31 OutputDevice_String::OutputDevice_String(const bool binary, const int defaultIndentation)
32  : OutputDevice(binary, defaultIndentation) {
33  setPrecision();
34  myStream << std::setiosflags(std::ios::fixed);
35 }
36 
37 
39 }
40 
41 
42 std::string
44  return myStream.str();
45 }
46 
47 
48 std::ostream&
50  return myStream;
51 }
52 
53 
54 /****************************************************************************/
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
OutputDevice_String::getOStream
std::ostream & getOStream()
Returns the associated ostream.
Definition: OutputDevice_String.cpp:49
OutputDevice_String::myStream
std::ostringstream myStream
The wrapped ofstream.
Definition: OutputDevice_String.h:69
OutputDevice::setPrecision
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
Definition: OutputDevice.cpp:221
OutputDevice_String::~OutputDevice_String
~OutputDevice_String()
Destructor.
Definition: OutputDevice_String.cpp:38
OutputDevice_String::getString
std::string getString() const
Returns the current content as a string.
Definition: OutputDevice_String.cpp:43
OutputDevice_String::OutputDevice_String
OutputDevice_String(const bool binary=false, const int defaultIndentation=0)
Constructor.
Definition: OutputDevice_String.cpp:31
OutputDevice_String.h
config.h