# Hex.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/encoding/Hex.hpp"

# Hex

Utility class for hex string encoding/decoding .

namespace oatpp { namespace encoding { 
  class Hex {}
}}

# Fields

Type Name Summary
v_int32 ERROR_UNKNOWN_SYMBOL Unknown symbol error.

# Methods

Return Type Name Summary
void writeUInt16 Write value as hex string to buffer.
void writeUInt32 Write value as hex string to buffer.
v_int32 readUInt16 Parse 4-char hex string to int16.
v_int32 readUInt32 Parse 8-char hex string to int32.
void encode Write binary data as HEX string.
void decode Read binary data from hex string.

# Hex::ERROR_UNKNOWN_SYMBOL

Unknown symbol error.

static constexpr v_int32 ERROR_UNKNOWN_SYMBOL = 1

# Hex::writeUInt16

Write value as hex string to buffer.

  • @param value - value to write.
  • @param buffer - buffer for resultant string.

static void writeUInt16(v_uint16 value, p_char8 buffer)

# Hex::writeUInt32

Write value as hex string to buffer.

  • @param value - value to write.
  • @param buffer - buffer for resultant string.

static void writeUInt32(v_uint32 value, p_char8 buffer)

# Hex::readUInt16

Parse 4-char hex string to int16.

  • @param buffer - buffer containing string to parse.
  • @param value - out parameter. Resultant value.
  • @return - 0 on success. Negative value on failure.

static v_int32 readUInt16(p_char8 buffer, v_uint16& value)

# Hex::readUInt32

Parse 8-char hex string to int32.

  • @param buffer - buffer containing string to parse.
  • @param value - out parameter. Resultant value.
  • @return - 0 on success. Negative value on failure.

static v_int32 readUInt32(p_char8 buffer, v_uint32& value)

# Hex::encode

Write binary data as HEX string.

  • @param stream
  • @param data
  • @param size
  • @param alphabet

static void encode(data::stream::ConsistentOutputStream* stream,
                   const void* data, v_buff_size size,
                   const char* alphabet = ALPHABET_UPPER)

# Hex::decode

Read binary data from hex string.

  • @param stream
  • @param data
  • @param size
  • @param allowSeparators - skip any char which is not ([A-Z], [a-z], [0-9]) without error.
  • @throws - Hex::DecodingError

static void decode(data::stream::ConsistentOutputStream* stream,
                   const void* data, v_buff_size size, bool allowSeparators = false)

# Hex::DecodingError

DecodingError.

namespace oatpp { namespace encoding { 
  class Hex {
    class DecodingError : public std::runtime_error {}
  };
}}

# Methods

Return Type Name Summary
[none] DecodingError Constructor.

# Hex::DecodingError::DecodingError

Constructor.

  • @param message - error message.

DecodingError(const char* message)
  :std::runtime_error(message)