Skip to content

Commit 520b1f7

Browse files
committed
Fix compilation with C++98
1 parent 9f50590 commit 520b1f7

File tree

5 files changed

+23
-37
lines changed

5 files changed

+23
-37
lines changed

src/Event.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ Event::Event(Event::Type type, int id, const std::string& msg, clock_t evtTime)
3131
_hashType = NO_HASH;
3232
}
3333

34-
Event::Event(Event::Type type, int id, int64 size, clock_t evtTime, uint64 hash, HashType hashType)
34+
Event::Event(Event::Type type, int id, int64 size, clock_t evtTime, uint64 hash, HashType hashType, int64 offset)
3535
: _type(type)
3636
, _time(evtTime)
3737
, _id(id)
3838
, _size(size)
39+
, _offset(offset)
3940
, _hash(hash)
4041
, _hashType(hashType)
4142
{

src/Event.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace kanzi
4747

4848
Event(Type type, int id, const std::string& msg, clock_t evtTime = 0);
4949

50-
Event(Type type, int id, int64 size, clock_t evtTime, uint64 hash = 0, HashType hashType = NO_HASH);
50+
Event(Type type, int id, int64 size, clock_t evtTime, uint64 hash = 0, HashType hashType = NO_HASH, int64 offset = -1);
5151

5252
virtual ~Event() {}
5353

@@ -63,6 +63,8 @@ namespace kanzi
6363

6464
uint64 getHash() const { return _hashType != NO_HASH ? _hash : 0; }
6565

66+
int64 getOffset() const { return _offset; }
67+
6668
HashType getHashType() const { return _hashType; }
6769

6870
std::string toString() const;
@@ -73,6 +75,7 @@ namespace kanzi
7375
std::string _msg;
7476
int _id;
7577
int64 _size;
78+
int64 _offset;
7679
uint64 _hash;
7780
HashType _hashType;
7881
};

src/io/CompressedInputStream.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -878,20 +878,7 @@ T DecodingTask<T>::run()
878878
if (_listeners.size() > 0) {
879879
#if !defined(_MSC_VER) || _MSC_VER > 1500
880880
if (_ctx.getInt("verbosity", 0) > 4) {
881-
char buf1[9] = { 0 };
882-
uint8 sf = uint8(skipFlags);
883-
884-
for (int i = 7; i >= 0; i--) {
885-
buf1[i] = (sf & 1) ? '1' : '0';
886-
sf >>= 1;
887-
}
888-
889-
// Create message (use snprintf because stringstream is too slow)
890-
char buf2[100];
891-
snprintf(buf2, sizeof(buf2),
892-
"{ \"type\":\"%s\", \"id\":%d, \"offset\":%lli, \"skipFlags\":%s }",
893-
"BLOCK_INFO", blockId, (long long)blockOffset, buf1);
894-
Event evt1(Event::BLOCK_INFO, blockId, string(buf2));
881+
Event evt1(Event::BLOCK_INFO, blockId, int64(r), clock(), checksum1, hashType, blockOffset);
895882
CompressedInputStream::notifyListeners(_listeners, evt1);
896883
}
897884
#endif

src/io/CompressedOutputStream.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515

1616
#include <algorithm>
1717
#include <sstream>
18+
#include <stdio.h>
1819
#include "CompressedOutputStream.hpp"
1920
#include "IOException.hpp"
2021
#include "../Error.hpp"
@@ -779,20 +780,8 @@ T EncodingTask<T>::run()
779780
}
780781

781782
const int64 blockOffset = (oName != "NONE") ? _obs->tell() : _obs->written();
782-
char buf1[9] = { 0 };
783-
uint8 sf = uint8(skipFlags);
784-
785-
for (int i = 7; i >= 0; i--) {
786-
buf1[i] = (sf & 1) ? '1' : '0';
787-
sf >>= 1;
788-
}
789-
790-
// Create message (use snprintf because stringstream is too slow)
791-
char buf2[100];
792-
snprintf(buf2, sizeof(buf2),
793-
"{ \"type\":\"%s\", \"id\":%d, \"offset\":%lli, \"skipFlags\":%s }",
794-
"BLOCK_INFO", blockId, (long long)blockOffset, buf1);
795-
Event evt2(Event::BLOCK_INFO, blockId, string(buf2));
783+
Event evt2(Event::BLOCK_INFO, blockId,
784+
int64((written + 7) >> 3), clock(), checksum, hashType, blockOffset);
796785
CompressedOutputStream::notifyListeners(_listeners, evt2);
797786
}
798787
#endif

src/util/XXHash.hpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ namespace kanzi
3131
class XXHash32
3232
{
3333
private:
34-
enum PrimeSeeds {
35-
PRIME32_1 = uint32(-1640531535),
36-
PRIME32_2 = uint32(-2048144777),
37-
PRIME32_3 = uint32(-1028477379),
38-
PRIME32_4 = uint32(668265263),
39-
PRIME32_5 = uint32(374761393)
40-
};
34+
#if __cplusplus >= 201103L
35+
static constexpr uint32 PRIME32_1 = uint32(-1640531535);
36+
static constexpr uint32 PRIME32_2 = uint32(-2048144777);
37+
static constexpr uint32 PRIME32_3 = uint32(-1028477379);
38+
static constexpr uint32 PRIME32_4 = uint32(668265263);
39+
static constexpr uint32 PRIME32_5 = uint32(374761393);
40+
#else
41+
static const uint32 PRIME32_1 = uint32(-1640531535);
42+
static const uint32 PRIME32_2 = uint32(-2048144777);
43+
static const uint32 PRIME32_3 = uint32(-1028477379);
44+
static const uint32 PRIME32_4 = uint32(668265263);
45+
static const uint32 PRIME32_5 = uint32(374761393);
46+
#endif
4147

4248
int _seed;
4349

0 commit comments

Comments
 (0)