Path: blob/main/src/utils/iodevices/OutputDevice_String.h
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file OutputDevice_String.h14/// @author Michael Behrisch15/// @date 200916///17// An output device that encapsulates a stringstream18/****************************************************************************/19#pragma once20#include <config.h>2122#include <fstream>23#include "OutputDevice.h"242526// ===========================================================================27// class definitions28// ===========================================================================29/**30* @class OutputDevice_String31* @brief An output device that encapsulates an ofstream32*33* Please note that the device gots responsible for the stream and deletes34* it (it should not be deleted elsewhere).35*/36class OutputDevice_String : public OutputDevice {37public:38/** @brief Constructor39* @exception IOError Should not be thrown by this implementation40*/41OutputDevice_String(const int defaultIndentation = 0);424344/// @brief Destructor45~OutputDevice_String();464748/** @brief Returns the current content as a string49* @return The content as string50*/51std::string getString() const;5253protected:54/// @name Methods that override/implement OutputDevice-methods55/// @{5657/** @brief Returns the associated ostream58* @return The used stream59*/60std::ostream& getOStream();61/// @}626364private:65/// The wrapped ofstream66std::ostringstream myStream;6768};697071