tool/coe_datatypes.cpp
author Florian Pose <fp@igh-essen.com>
Thu, 24 Jul 2008 13:29:13 +0000
changeset 1143 09ee878d7214
parent 1126 b09fd81894cb
permissions -rw-r--r--
Fixed duplicate alias command.
1126
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 * $Id$
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 ****************************************************************************/
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#include "coe_datatypes.h"
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
/****************************************************************************/
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
static const CoEDataType dataTypes[] = {
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
    {"int8",   0x0002, 1},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
    {"int16",  0x0003, 2},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
    {"int32",  0x0004, 4},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
    {"uint8",  0x0005, 1},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
    {"uint16", 0x0006, 2},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
    {"uint32", 0x0007, 4},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
    {"string", 0x0009, 0},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
    {"raw",    0xffff, 0},
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
    {}
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
};
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
/****************************************************************************/
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
const CoEDataType *findDataType(const string &str)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
{
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
    const CoEDataType *d;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
    
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
    for (d = dataTypes; d->name; d++)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
        if (str == d->name)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
            return d;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
    return NULL;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
}
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
/****************************************************************************/
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
const CoEDataType *findDataType(uint16_t code)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
{
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
    const CoEDataType *d;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
    
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
    for (d = dataTypes; d->name; d++)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
        if (code == d->coeCode)
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
            return d;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
    return NULL;
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
}
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/*****************************************************************************/