Logo Search packages:      
Sourcecode: einstein version File versions  Download package

Formatter::Formatter ( unsigned char *  data,
int  offset 
)

Create localized message from message buffer.

Parameters:
data buffer contained message file
offset offset to message from buffer start

Definition at line 14 of file formatter.cpp.

{
    int cnt = readInt(data + offset);
    if (! cnt) {
        commandsCnt = argsCnt = 0;
        commands = NULL;
        args = NULL;
    }
    
    offset += 4;
    commands = new Command[cnt];
    commandsCnt = 0;
    
    int maxArg = 0, argNo;
    
    for (int i = 0; i < cnt; i++) {
        int type = data[offset];
        offset++;
        int size = readInt(data + offset);
        offset += 4;
        switch (type) {
            case 1:
                commands[commandsCnt].type = TEXT_COMMAND;
                commands[commandsCnt].data = new std::wstring(
                        fromUtf8((char*)data + offset, size));
                commandsCnt++;
                break;
            
            case 2: ADD_ARG(INT_ARG); break;
            case 3: ADD_ARG(STRING_ARG); break;
            case 4: ADD_ARG(FLOAT_ARG); break;
            case 5: ADD_ARG(DOUBLE_ARG); break;
        }
        offset += size;
    }

    argsCnt = maxArg;
    if (! argsCnt)
        args = NULL;
    else {
        args = new CmdType[argsCnt];
        memset(args, 0, sizeof(CmdType) * argsCnt);
        for (int i = 0; i < commandsCnt; i++) {
            Command &c = commands[i];
            if ((c.type == INT_ARG) || (c.type == STRING_ARG) ||
                    (c.type == FLOAT_ARG) || (c.type == DOUBLE_ARG))
            {
                int no = (int)c.data;
                args[no - 1] = c.type;
            }
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index