Files
NazaraEngine/src/Nazara/Core/ByteArray.cpp
Gawaboumga bbac0838dd Include-What-You-Use (#137)
* IWYU Core

* IWYU Noise

* IWYU Utility

* IWYU Audio

* IWYU Platform

* IWYU Lua

* IWYU Network

* IWYU Physics2D

* IWYU Physics3D

* IWYU Renderer

* IWYU Graphics

* IWYU NDKServer

* IWYU Fix

* Try to fix compilation

* Other fixes
2017-10-01 11:17:09 +02:00

46 lines
962 B
C++

// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/ByteArray.hpp>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
/*!
* \ingroup core
* \class Nz::ByteArray
* \brief Core class that represents an array of bytes
*/
/*!
* \brief Gives a string representation in base 16
* \return String in base 16
*/
String ByteArray::ToHex() const
{
std::size_t length = m_array.size() * 2;
String hexOutput(length, '\0');
for (std::size_t i = 0; i < m_array.size(); ++i)
std::sprintf(&hexOutput[i * 2], "%02x", m_array[i]);
return hexOutput;
}
/*!
* \brief Output operator
* \return The stream
*
* \param out The stream
* \param byteArray The ByteArray to output
*/
std::ostream& operator<<(std::ostream& out, const Nz::ByteArray& byteArray)
{
out << byteArray.ToHex();
return out;
}
}