WSTestUTF32HeadWithArgCount (C Function)

int WSTestUTF32HeadWithArgCount(WSLINK l, const unsigned int *s, int v, int *n)

tests that the next object to be read from the WSTP connection specified by l is an expression with head s, an UTF-32 encoded character string of length v, and that the number of arguments of the expression is n.


  • WSTestUTF32HeadWithArgCount() fails if the current expression on the link is not a function with a symbol as a head, if the name of the symbol does not match s, or if the number of arguments for the function is not n.
  • WSTestUTF32HeadWithArgCount() stores the actual number of arguments to the function in n when the function returns.
  • The symbol s encoded as an UTF-32 string must begin with a byte order mark.
  • The length of the symbol v must include the byte order mark.
  • WSTestUTF32HeadWithArgCount() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSTestUTF32HeadWithArgCount() fails.
  • WSTestUTF32HeadWithArgCount() will reset the stream pointer to the expression on the link just prior to calling WSTestUTF32HeadWithArgCount() if the function fails. This operation behaves as if the programmer has called WSCreateMark(l); WSTestUTF32HeadWithArgCount(...); WSSeekToMark(...).
  • WSTestUTF32HeadWithArgCount() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* A function to test whether the next expression on the Link is Plus[a,b] */

void f(WSLINK l)
    unsigned int symbol[5];
    int args = 2;
    const char *symbol;

    symbol[0] = 0xFEFF;
    symbol[1] = 'P';
    symbol[2] = 'l';
    symbol[3] = 'u';
    symbol[4] = 's';

    if(! WSTestUTF32HeadWithArgCount(l, (const unsigned int *)symbol, 5, &args))
    { /* Next expression is not Plus, or does not have two args */ }

    if(! WSGetSymbol(l, &symbol))
    { /* Unable to read symbol */ }

    /* Check if symbol is 'a' */

    WSReleaseSymbol(l, symbol);

    if(! WSGetSymbol(l, &symbol))
    { /* Unable to read symbol */ }

    /* Check if the symbol is 'b' */

    WSReleaseSymbol(l, symbol);