# IDL DEFINITION

module Messenger {

    @extensibility(FINAL) @nested
    union TestUnion_t switch (char) {
        case 'A':
            long LongU;
        default:
            octet OctetU;
    };

    @bit_bound(7)
    enum TestEnum_t {
        A,
        B,
        C,
        D
    };
    
    typedef octet TestArray_t[5];
    
    @extensibility(FINAL) @nested
    struct NestedStruct_t {
        @key TestArray_t TestArray;
        octet TestOctet;
        short TestShort;
        long long TestLongLong;
    };

    typedef sequence<NestedStruct_t, 4> TestSequence_t;
    typedef string<12> TestString_t;

    @topic
    @extensibility(FINAL)
    struct Message {
        @key long id;
        TestSequence_t TestSequence;
        TestEnum_t TestEnum;
        @optional TestUnion_t TestUnion;
        TestString_t TestString;
    };
};

# CONTENT INITIALIZATION

Messenger::Message message;
message.id = 10;
message.TestSequence.length(2);
message.TestSequence[0] = Messenger::NestedStruct_t();
message.TestSequence[0].TestArray[0] = 1;
message.TestSequence[0].TestArray[1] = 2;
message.TestSequence[0].TestArray[2] = 3;
message.TestSequence[0].TestArray[3] = 4;
message.TestSequence[0].TestArray[4] = 5;
message.TestSequence[0].TestOctet = 'a';
message.TestSequence[0].TestShort = L'b';
message.TestSequence[0].TestLongLong = 1024;
message.TestSequence[1] = Messenger::NestedStruct_t();
message.TestSequence[1].TestArray[0] = 6;
message.TestSequence[1].TestArray[1] = 7;
message.TestSequence[1].TestArray[2] = 8;
message.TestSequence[1].TestArray[3] = 9;
message.TestSequence[1].TestArray[4] = 10;
message.TestSequence[1].TestOctet = 'A';
message.TestSequence[1].TestShort = L'B';
message.TestSequence[1].TestLongLong = 4096;
message.TestEnum = Messenger::TestEnum_t::C;
message.TestUnion._d(0);
message.TestUnion.LongU(512);
message.TestUnion.OctetU(128);
message.TestString = "HelloWorld";

   31............24..............16..............8...............0
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |     Representation_id         |   Representation_options      |
            00 01 (=CDR_LE)                   00 00
  |                               id                              |
                             0a 00 00 00
  |                      TestSequence.length                      |
                            02 00 00 00
  | TS[0].TA[0]   | TS[0].TA[1]   | TS[0].TA[2]   | TS[0].TA[3]   | (TS...TestSequence, TA..TestArray)
         01             02               03             04
  | TS[0].TA[4]   |TS[0].TestOctet|         TS[0].TestShort       |
        05              61                      62 00
  |                        TS[0].TestLongLong                     |
  |                                                               |
                        00 04 00 00 00 00 00 00
  | TS[1].TA[0]   | TS[2].TA[1]   | TS[3].TA[2]   | TS[4].TA[3]   |
        06              07              08               09
  | TS[1].TA[4]   |TS[1].TestOctet|         TS[1].TestShort       |
        0a              41                      42 00
  |                        TS[0].TestLongLong                     |
  |                                                               |
                        00 10 00 00 00 00 00 00
  |                           TestEnum                            |
                            02 00 00 00
  | TestUnion._d  | TU.OctetU     |            PADDING            |
        00                80                    00 00
  |                      TestString.length                        |
                             0b 00 00 00
  | TestString[0] | TestString[1] | TestString[2] | TestString[3] |
        48              65              6c              6c
  | TestString[4] | TestString[5] | TestString[6] | TestString[7] |
        6f              57              6f              72
  | TestString[8] | TestString[9] | TestString[10]|###############|
        6c              64              00
  +---------------------------------------------------------------+
