Core/ByteArray: Move ToHex implementation to .cpp
This commit is contained in:
parent
a8d4e44669
commit
8ed34d22fb
|
|
@ -88,7 +88,7 @@ namespace Nz
|
||||||
inline void ShrinkToFit();
|
inline void ShrinkToFit();
|
||||||
inline void Swap(ByteArray& other);
|
inline void Swap(ByteArray& other);
|
||||||
|
|
||||||
inline String ToHex() const;
|
String ToHex() const;
|
||||||
inline String ToString() const;
|
inline String ToString() const;
|
||||||
|
|
||||||
// STL interface
|
// STL interface
|
||||||
|
|
|
||||||
|
|
@ -465,22 +465,6 @@ namespace Nz
|
||||||
m_array.swap(other.m_array);
|
m_array.swap(other.m_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Gives a string representation in base 16
|
|
||||||
* \return String in base 16
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline 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 Gives a string representation
|
* \brief Gives a string representation
|
||||||
* \return String where each byte is converted to char
|
* \return String where each byte is converted to char
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,22 @@ namespace Nz
|
||||||
* \brief Core class that represents an array of bytes
|
* \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
|
* \brief Output operator
|
||||||
* \return The stream
|
* \return The stream
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue