Skip to content

Code generation for variable-length data field #2

Closed
@donmendelson

Description

@donmendelson

I generated Java code for a message schema with variable-length data. The generated code has functions set and get the length of the data but not a direct way to locate the data in the buffer or to populate it. Not sure how to use this. It seems to me that a method to set data into the field should also set its length.

The encoding is this:



The field is defined this way:

The generated code:

/* Generated SBE (Simple Binary Encoding) message codec */
package MarketData;

import java.nio.ByteOrder;
import java.util.;
import uk.co.real_logic.sbe.generation.java.
;

public class DATA implements FixedFlyweight
{
private DirectBuffer buffer;
private int offset;

public DATA reset(final DirectBuffer buffer, final int offset)
{
    this.buffer = buffer;
    this.offset = offset;
    return this;
}

public int size()
{
    return -1;
}

public int length()
{
    return CodecUtil.uint16Get(buffer, offset + 0, ByteOrder.LITTLE_ENDIAN);
}

public DATA length(final int value)
{
    CodecUtil.uint16Put(buffer, offset + 0, value, ByteOrder.LITTLE_ENDIAN);
    return this;
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions