Esempio n. 1
0
char const *Str_CopyDelim2(ddstring_t *str, char const *src, char delimiter, int cdflags)
{
    DENG_ASSERT(str);
    if(!str) return 0;

    Str_Clear(str);

    if(!src) return 0;

    { char const *cursor;
    ddstring_t buf; Str_Init(&buf);
    for(cursor = src; *cursor && *cursor != delimiter; ++cursor)
    {
        if((cdflags & CDF_OMIT_WHITESPACE) && isspace(*cursor))
            continue;
        Str_PartAppend(&buf, cursor, 0, 1);
    }
    if(!Str_IsEmpty(&buf))
        Str_Copy(str, &buf);
    Str_Free(&buf);

    if(!*cursor)
        return 0; // It ended.

    if(!(cdflags & CDF_OMIT_DELIMITER))
        Str_PartAppend(str, cursor, 0, 1);

    // Skip past the delimiter.
    return cursor + 1;
    }
}
Esempio n. 2
0
char const *Str_GetLine(ddstring_t *str, char const *src)
{
    DENG_ASSERT(str);
    if(!str) return 0;

    if(src != 0)
    {
        // We'll append the chars one by one.
        char buf[2];
        memset(buf, 0, sizeof(buf));
        for(Str_Clear(str); *src && *src != '\n'; src++)
        {
            if(*src != '\r')
            {
                buf[0] = *src;
                Str_Append(str, buf);
            }
        }

        // Strip whitespace around the line.
        Str_Strip(str);

        // The newline is excluded.
        if(*src == '\n')
            src++;
    }
    return src;
}
Esempio n. 3
0
/**
 * Does the opposite of the B_Parse* methods for event descriptor, including the
 * state conditions.
 */
void B_EventBindingToString(const evbinding_t* eb, ddstring_t* str)
{
    int         i;

    Str_Clear(str);
    B_AppendDeviceDescToString(eb->device, eb->type, eb->id, str);

    if(eb->type == E_TOGGLE)
    {
        B_AppendToggleStateToString(eb->state, str);
    }
    else if(eb->type == E_AXIS)
    {
        B_AppendAxisPositionToString(eb->state, eb->pos, str);
    }
    else if(eb->type == E_ANGLE)
    {
        B_AppendAnglePositionToString(eb->pos, str);
    }
    else if(eb->type == E_SYMBOLIC)
    {
        Str_Appendf(str, "-%s", eb->symbolicName);
    }

    // Append any state conditions.
    for(i = 0; i < eb->numConds; ++i)
    {
        Str_Append(str, " + ");
        B_AppendConditionToString(&eb->conds[i], str);
    }
}
Esempio n. 4
0
ddstring_t *Str_CopyOrClear(ddstring_t *dest, const ddstring_t *src)
{
    DENG_ASSERT(dest);
    if(!dest) return 0;

    if(src)
    {
        return Str_Copy(dest, src);
    }
    return Str_Clear(dest);
}