/** * Find next parameter * @param context * @param mandatory * @return */ scpi_bool_t paramNext(scpi_t * context, scpi_bool_t mandatory) { paramSkipWhitespace(context); if (context->paramlist.length == 0) { if (mandatory) { SCPI_ErrorPush(context, SCPI_ERROR_MISSING_PARAMETER); } return FALSE; } if (context->input_count != 0) { if (context->paramlist.parameters[0] == ',') { paramSkipBytes(context, 1); paramSkipWhitespace(context); } else { SCPI_ErrorPush(context, SCPI_ERROR_INVALID_SEPARATOR); return FALSE; } } context->input_count++; return TRUE; }
/** * Parse text parameter (can be inside "") * @param context * @param value Pointer to string buffer where pointer to non-null terminated string will be returned * @param len Length of returned non-null terminated string * @param mandatory * @return */ scpi_bool_t SCPI_ParamText(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory) { size_t length; if (!value || !len) { return FALSE; } if (!paramNext(context, mandatory)) { return FALSE; } if (locateText(context->paramlist.parameters, context->paramlist.length, value, &length)) { paramSkipBytes(context, length); if (len) { *len = length; } return TRUE; } return FALSE; }
/** * Parse string parameter * @param context * @param value * @param len * @param mandatory * @return */ scpi_bool_t SCPIParser::SCPI_ParamString(const char ** value, size_t * len, scpi_bool_t mandatory) { size_t length; if (!value || !len) { return FALSE; } if (!paramNext(mandatory)) { return FALSE; } if (locateStr(context.paramlist.parameters, context.paramlist.length, value, &length)) { paramSkipBytes(length); paramSkipWhitespace(); if (len) { *len = length; } return TRUE; } return FALSE; }
/** * Skip white spaces from the beggining of parameters * @param context */ void paramSkipWhitespace(scpi_t * context) { size_t ws = skipWhitespace(context->paramlist.parameters, context->paramlist.length); paramSkipBytes(context, ws); }
/** * Skip white spaces from the beggining of parameters * @param context */ void SCPIParser::paramSkipWhitespace() { size_t ws = skipWhitespace(context.paramlist.parameters, context.paramlist.length); paramSkipBytes(ws); }