Skip to content

Commit 8d8cf98

Browse files
committed
2 parents f5cb0cb + 27df23f commit 8d8cf98

File tree

9 files changed

+815
-794
lines changed

9 files changed

+815
-794
lines changed

sbe-tool/src/main/cpp/otf/IrDecoder.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ class IrDecoder
5555
{
5656
}
5757

58-
int decode(char *buffer, int length)
58+
int decode(char *buffer, std::uint64_t length)
5959
{
60+
m_length = length;
6061
return decodeIr();
6162
}
6263

6364
int decode(const char *filename)
6465
{
65-
if ((m_length = getFileSize(filename)) < 0)
66+
long fileSize = getFileSize(filename);
67+
68+
if (fileSize < 0)
6669
{
6770
return -1;
6871
}
72+
73+
m_length = static_cast<std::uint64_t>(fileSize);
6974
std::cout << "IR Filename " << filename << " length " << m_length << std::endl;
7075
if (m_length == 0)
7176
{
@@ -124,10 +129,10 @@ class IrDecoder
124129
return fileStat.st_size;
125130
}
126131

127-
static int readFileIntoBuffer(char *buffer, const char *filename, int length)
132+
static int readFileIntoBuffer(char *buffer, const char *filename, std::uint64_t length)
128133
{
129134
FILE *fptr = ::fopen(filename, "rb");
130-
int remaining = length;
135+
std::uint64_t remaining = length;
131136

132137
if (fptr == NULL)
133138
{
@@ -154,13 +159,13 @@ class IrDecoder
154159
std::shared_ptr<std::vector<Token>> m_headerTokens;
155160
std::vector<std::shared_ptr<std::vector<Token>>> m_messages;
156161
std::unique_ptr<char[]> m_buffer;
157-
long m_length;
162+
std::uint64_t m_length;
158163
int m_id;
159164

160165
int decodeIr()
161166
{
162167
FrameCodec frame;
163-
int offset = 0, tmpLen = 0;
168+
std::uint64_t offset = 0, tmpLen = 0;
164169
char tmp[256];
165170

166171
frame.wrapForDecode(m_buffer.get(), offset, frame.sbeBlockLength(), frame.sbeSchemaVersion(), m_length);
@@ -177,11 +182,11 @@ class IrDecoder
177182
frame.getNamespaceName(tmp, sizeof(tmp));
178183
frame.getSemanticVersion(tmp, sizeof(tmp));
179184

180-
offset += frame.size();
185+
offset += frame.encodedLength();
181186

182187
m_headerTokens.reset(new std::vector<Token>());
183188

184-
int headerLength = readHeader(offset);
189+
std::uint64_t headerLength = readHeader(offset);
185190

186191
m_id = frame.irId();
187192

@@ -195,7 +200,7 @@ class IrDecoder
195200
return 0;
196201
}
197202

198-
int decodeAndAddToken(std::shared_ptr<std::vector<Token>> tokens, int offset)
203+
std::uint64_t decodeAndAddToken(std::shared_ptr<std::vector<Token>> tokens, std::uint64_t offset)
199204
{
200205
TokenCodec tokenCodec;
201206
tokenCodec.wrapForDecode(m_buffer.get(), offset, tokenCodec.sbeBlockLength(), tokenCodec.sbeSchemaVersion(), m_length);
@@ -210,7 +215,7 @@ class IrDecoder
210215
std::int32_t version = tokenCodec.tokenVersion();
211216
std::int32_t componentTokenCount = tokenCodec.componentTokenCount();
212217
char tmpBuffer[256];
213-
int tmpLen = 0;
218+
std::uint64_t tmpLen = 0;
214219

215220
tmpLen = tokenCodec.getName(tmpBuffer, sizeof(tmpBuffer));
216221
std::string name(tmpBuffer, static_cast<std::size_t>(tmpLen));
@@ -251,12 +256,12 @@ class IrDecoder
251256

252257
tokens->push_back(token);
253258

254-
return tokenCodec.size();
259+
return tokenCodec.encodedLength();
255260
}
256261

257-
int readHeader(int offset)
262+
std::uint64_t readHeader(std::uint64_t offset)
258263
{
259-
int size = 0;
264+
std::uint64_t size = 0;
260265

261266
while (offset + size < m_length)
262267
{
@@ -280,9 +285,9 @@ class IrDecoder
280285
return size;
281286
}
282287

283-
int readMessage(int offset)
288+
std::uint64_t readMessage(std::uint64_t offset)
284289
{
285-
int size = 0;
290+
std::uint64_t size = 0;
286291

287292
std::shared_ptr<std::vector<Token>> tokensForMessage(new std::vector<Token>());
288293

sbe-tool/src/main/cpp/uk_co_real_logic_sbe_ir_generated/ByteOrderCodec.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# include <cstdint>
1919
# include <functional>
2020
# include <string>
21+
# include <cstring>
2122
#endif
2223

2324
#include <sbe/sbe.h>
@@ -32,12 +33,12 @@ class ByteOrderCodec
3233

3334
enum Value
3435
{
35-
SBE_LITTLE_ENDIAN = (sbe_uint8_t)0,
36-
SBE_BIG_ENDIAN = (sbe_uint8_t)1,
37-
NULL_VALUE = (sbe_uint8_t)255
36+
SBE_LITTLE_ENDIAN = (std::uint8_t)0,
37+
SBE_BIG_ENDIAN = (std::uint8_t)1,
38+
NULL_VALUE = (std::uint8_t)255
3839
};
3940

40-
static ByteOrderCodec::Value get(const sbe_uint8_t value)
41+
static ByteOrderCodec::Value get(const std::uint8_t value)
4142
{
4243
switch (value)
4344
{

0 commit comments

Comments
 (0)