Skip to content
Snippets Groups Projects
STLVector.cpp 1.72 KiB
Newer Older
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * STLVector.cpp
 *
 *  Created on: Dec 22, 2016
 *      Author: wfg
 */

#include "STLVector.h"

/// \cond EXCLUDE_FROM_DOXYGEN
#include <new>       //std::bad_alloc
#include <stdexcept> //std::runtime_error
namespace adios2
{
namespace capsule
{

STLVector::STLVector(const bool debugMode)
: Capsule("heap/STLVector", debugMode)
{
}

char *STLVector::GetData() { return m_Data.data(); }

char *STLVector::GetMetadata() { return m_Metadata.data(); }

size_t STLVector::GetDataSize() const { return m_Data.size(); }
size_t STLVector::GetMetadataSize() const { return m_Metadata.size(); }
void STLVector::ResizeData(const size_t size)
William F Godoy's avatar
William F Godoy committed
    if (m_DebugMode)
        try
        {
            m_Data.resize(size);
        }
William F Godoy's avatar
William F Godoy committed
        catch (...)
            std::throw_with_nested(
William F Godoy's avatar
William F Godoy committed
                std::runtime_error("ERROR: possible overflow when resizing "
                                   "data buffer with size " +
                                   std::to_string(size) + "\n"));
        m_Data.resize(size);
void STLVector::ResizeMetadata(const size_t size)
William F Godoy's avatar
William F Godoy committed
    if (m_DebugMode)
        try
        {
            m_Metadata.resize(size);
        }
William F Godoy's avatar
William F Godoy committed
        catch (...)
            std::throw_with_nested(
William F Godoy's avatar
William F Godoy committed
                std::runtime_error("ERROR: possible overflow when resizing "
                                   "metadata buffer with size " +
                                   std::to_string(size) + "\n"));
        m_Metadata.resize(size);
} // end namespace capsule
} // end namespace adios