Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field Attributes #483

Closed
adkapur opened this issue Jul 28, 2017 · 9 comments
Closed

Field Attributes #483

adkapur opened this issue Jul 28, 2017 · 9 comments

Comments

@adkapur
Copy link

adkapur commented Jul 28, 2017

Field attributes such as presence do not seem to be accessible

<field description="Account mnemonic as agreed between buy and sell sides, e.g. broker and institution or investor/intermediary and fund manager." id="1" name="Account" semanticType="String" presence="required" offset="25" type="String12"/>

sbe-rc2

//String example in rlsbe

public static int accountId()
{
return 1;
}

public static int accountSinceVersion()
{
return 0;
}

public static String accountMetaAttribute(final MetaAttribute metaAttribute)
{
switch (metaAttribute)
{
case EPOCH: return "unix";
case TIME_UNIT: return "nanosecond";
case SEMANTIC_TYPE: return "String";
}

return "";

}

public static byte accountNullValue()
{
return (byte)0;
}

public static byte accountMinValue()
{
return (byte)32;
}

public static byte accountMaxValue()
{
return (byte)126;
}

public static int accountLength()
{
return 12;
}

public byte account(final int index)
{
if (index < 0 || index >= 12)
{
throw new IndexOutOfBoundsException("index out of range: index=" + index);
}

final int pos = this.offset + 25 + (index * 1);

return buffer.getByte(pos);

}

public static String accountCharacterEncoding()
{
return "UTF-8";
}

public int getAccount(final byte[] dst, final int dstOffset)
{
final int length = 12;
if (dstOffset < 0 || dstOffset > (dst.length - length))
{
throw new IndexOutOfBoundsException("dstOffset out of range for copy: offset=" + dstOffset);
}

buffer.getBytes(this.offset + 25, dst, dstOffset, length);

return length;

}
we’d expect in something related to presence in meta attribute function, although right now that’s not even a member of the MetaAttribute enum:

public static String accountMetaAttribute(final MetaAttribute metaAttribute)
{
switch (metaAttribute)
{
case EPOCH: return "unix";
case TIME_UNIT: return "nanosecond";
case SEMANTIC_TYPE: return "String";
case PRESENCE: return “required”;
}

return "";

}

@mjpt777
Copy link
Contributor

mjpt777 commented Jul 28, 2017

I've added this feature.

@billsegall
Copy link
Contributor

I'll have a look at this for Golang and CSharp but I'll be a few days.

@mjpt777
Copy link
Contributor

mjpt777 commented Jul 30, 2017

Thanks @billsegall. The Java and C++ generator changes were pretty trivial for this.

billsegall added a commit to MarketFactory/simple-binary-encoding that referenced this issue Aug 3, 2017
billsegall added a commit to MarketFactory/simple-binary-encoding that referenced this issue Aug 3, 2017
mjpt777 added a commit that referenced this issue Aug 3, 2017
[CSharp] Add meta attribute PRESENCE to generated codecs. Issue #483.
billsegall added a commit to MarketFactory/simple-binary-encoding that referenced this issue Aug 4, 2017
mjpt777 added a commit that referenced this issue Aug 4, 2017
[golang] Add meta attribute PRESENCE to generated codecs. Issue #483.
@mjpt777 mjpt777 closed this as completed Aug 22, 2017
@adkapur
Copy link
Author

adkapur commented Aug 25, 2017

Thanks martin for the quick turnaround on this

@adkapur
Copy link
Author

adkapur commented Aug 29, 2017

Just to clarify that this change will support enforcement of presence=required for a repeating group such that the count has to be greater than zero

@mjpt777
Copy link
Contributor

mjpt777 commented Aug 29, 2017

@adkapur Can you elaborate please. How does the enforcement work?

@donmendelson
Copy link

A repeating group is always present, even if it has zero entries. In the version 1.0 spec, the way to control the number of instances of a group is explained in section "Restricting repeating group entries", by setting the attributes minValue and/or maxValue.

@adkapur
Copy link
Author

adkapur commented Aug 29, 2017

The min and max values are tied to the groupSizeEncoding data type but we wanted to know if the real logic codegen will expose presence=required for a field representing number of repeating group entries such as for example Number of Party Roles

We are trying to convert FIX into SBE and our message validations will be leveraging the presence=required attribute

@adkapur
Copy link
Author

adkapur commented Aug 29, 2017

Also within a repeating group some entries may be required and others may be optional so ideally presence should be able to tell us this for each field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants