/** \file
 *  \brief Utility functions used by the command interpreter.
 *
 *  \note As always, <project.h> and <RTOS.h> should be included <I>before</I> this file.
 */

#ifndef COMM_CONSOLE_UTIL_H
#define COMM_CONSOLE_UTIL_H

#ifdef __cplusplus
extern "C" {
#endif

#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)

/* Include Files */

/* Preprocessor and Type Definitions */

/* Public Variables */

/* Public Functions */
COMM_Console_Parameter_Result_T COMM_Console_FindNthParameter(const char * const buffer, const uint8_t parameterNumber, const char ** parameterLocation);
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt8(const char * const buffer, uint8_t * const parameterUInt8);
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt16(const char * const buffer, uint16_t * const parameterUInt16);
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterInt32(const char * const buffer, int32_t * const parameterInt32);
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt32(const char * const buffer, uint32_t * const parameterUInt32);
COMM_Console_Parameter_Result_T COMM_Console_DecodeHexParameterUInt64(const char * const buffer, uint64_t * const parameterUInt64);

//! Returns `true` if this character marks the end of a console message; `false` otherwise.
inline bool COMM_Console_IsEndOfMessage(char8 character)
{
    bool result = false;
    
    if ( (character == COMM_CONSOLE_END_OF_MESSAGE) ||
         (character == COMM_CONSOLE_STRING_TERMINATOR) )
    {
        result = true;
    }
    
    return result;
}

#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)

#ifdef __cplusplus
}
#endif

#endif // COMM_CONSOLE_UTIL_H
