https://gitlab.opengeosys.org/ogs/ogs.git
Revision 41e525ab36d0e8ae3bc55071706f1a6f32017b7b authored by Tom Fischer on 11 May 2021, 09:10:04 UTC, committed by Tom Fischer on 11 May 2021, 09:10:04 UTC
Add doxygen documentition for line source terms.

See merge request ogs/ogs!3618
2 parent s e4b016b + a8315a5
Raw File
Tip revision: 41e525ab36d0e8ae3bc55071706f1a6f32017b7b authored by Tom Fischer on 11 May 2021, 09:10:04 UTC
Merge branch 'FixDocu' into 'master'
Tip revision: 41e525a
Writer.cpp
/**
 * \file
 * \author Lars Bilke
 * \date   2012-02-13
 * \brief  Implementation of the Writer class.
 *
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "Writer.h"

#include <fstream>
#include <limits>

#include "BaseLib/Logging.h"

namespace BaseLib
{
namespace IO
{
Writer::Writer()
{
    out.precision(std::numeric_limits<double>::digits10);
}

std::string Writer::writeToString()
{
    // Empty stream and clear error states.
    out.str("");
    out.clear();

    if (this->write())
    {
        return out.str();
    }

    return std::string("");
}

int writeStringToFile(std::string content,
                      std::filesystem::path const& file_path)
{
    if (content.empty())
    {
        return 0;
    }
    std::ofstream fileStream;
    fileStream.open(file_path.c_str());

    // check file stream
    if (!fileStream)
    {
        ERR("Could not open file '{:s}'!", file_path.string());
        return 0;
    }

    fileStream << content;

    fileStream.close();
    return 1;
}

}  // namespace IO
}  // namespace BaseLib
back to top