forked from real-logic/artio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting custom FIX tags in encoders (WIP) real-logic#462
- Loading branch information
Showing
5 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Helps IDEA users apply some of the formatting rules enforced by checkstyle | ||
|
||
root = true | ||
|
||
[*] | ||
|
||
[*.java] | ||
indent_size = 4 | ||
ij_java_method_brace_style = next_line | ||
ij_java_block_brace_style = next_line | ||
ij_java_class_brace_style = next_line | ||
ij_java_space_after_type_cast = false |
45 changes: 45 additions & 0 deletions
45
artio-codecs/src/main/java/uk/co/real_logic/artio/builder/CommonEncoderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package uk.co.real_logic.artio.builder; | ||
|
||
import uk.co.real_logic.artio.util.MutableAsciiBuffer; | ||
|
||
/** | ||
* Class provides common implementation methods used by encoders. | ||
*/ | ||
public class CommonEncoderImpl | ||
{ | ||
// TODO resizable buffer or way to set a size | ||
protected MutableAsciiBuffer customTagsBuffer = new MutableAsciiBuffer(new byte[64]); | ||
|
||
protected int customTagsLength = 0; | ||
|
||
private int putTagHeader(final int tag) | ||
{ | ||
int pos = customTagsLength; | ||
pos += customTagsBuffer.putIntAscii(pos, tag); | ||
customTagsBuffer.putByte(pos++, (byte)'='); | ||
return pos; | ||
} | ||
|
||
public CommonEncoderImpl customTag(final int tag, final int value) | ||
{ | ||
int pos = putTagHeader(tag); | ||
pos += customTagsBuffer.putIntAscii(pos, value); | ||
customTagsBuffer.putSeparator(pos++); | ||
customTagsLength = pos; | ||
return this; | ||
} | ||
|
||
public CommonEncoderImpl customTagAscii(final int tag, final CharSequence value) | ||
{ | ||
int pos = putTagHeader(tag); | ||
pos += customTagsBuffer.putStringWithoutLengthAscii(pos, value); | ||
customTagsBuffer.putSeparator(pos++); | ||
customTagsLength = pos; | ||
return this; | ||
} | ||
|
||
public void resetCustomTags() | ||
{ | ||
customTagsLength = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters