Skip to content

Commit 26ba079

Browse files
committed
fix: clang 3
1 parent 61b95ee commit 26ba079

3 files changed

Lines changed: 37 additions & 27 deletions

File tree

.clang-tidy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ Checks: >
88
-google-runtime-int,
99
-google-readability-braces-around-statements,
1010
-modernize-use-trailing-return-type
11-
12-
ExtraArgs: ['-std=c++20']

src/binance/FixApp.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,16 @@
1212
#include <iomanip>
1313
#include <memory>
1414
#include <string>
15+
#include <string_view>
1516
#include <vector>
1617

18+
#include "MessageHandlingMode.h"
1719
#include "spdlog/spdlog.h"
1820

1921
namespace Binance {
2022

2123
// PRIVATE
2224

23-
/// Binance Message Handling Mode
24-
/// Controls how the matching engine processes your messages
25-
/// [More
26-
/// info](https://developers.binance.com/docs/binance-spot-api-docs/fix-api#on-message-processing-order)
27-
enum class MessageHandlingMode : uint8_t {
28-
/// UNORDERED(1) - Messages from the client are allowed to be sent to the
29-
/// matching engine in any order
30-
Unordered = 1,
31-
/// SEQUENTIAL(2) - Messages from the client are always sent to the matching
32-
/// engine in MsgSeqNum (34) order
33-
Sequential = 2
34-
};
35-
std::string toString(const MessageHandlingMode m) {
36-
switch (m) {
37-
case MessageHandlingMode::Unordered:
38-
return "1";
39-
case MessageHandlingMode::Sequential:
40-
return "2";
41-
default:
42-
return "Unknown";
43-
}
44-
}
45-
4625
// better FIX message logging
4726
std::string replaceSoh(const std::string &input) {
4827
std::string output = input;
@@ -70,7 +49,7 @@ void FixApp::toAdmin(FIX::Message &msg, const FIX::SessionID &sessionId) {
7049
sessionId.toString(), msgType.getString(),
7150
replaceSoh(msg.toString())));
7251

73-
if (msgType == FIX::MsgType_Logon) {
52+
if (msgType.getString() == static_cast<const char *>(FIX::MsgType_Logon)) {
7453
spdlog::info(std::format("authenticating"));
7554

7655
// collect required fields
@@ -91,7 +70,8 @@ void FixApp::toAdmin(FIX::Message &msg, const FIX::SessionID &sessionId) {
9170
msg.setField(FIX::Username(auth_->getApiKey()));
9271
msg.setField(FIX::RawData(signature));
9372
msg.setField(FIX::RawDataLength(static_cast<FIX::LENGTH>(signature.size())));
94-
msg.setField(FIX::StringField(25035, toString(MessageHandlingMode::Sequential)));
73+
msg.setField(FIX::StringField(toInt(MessageHandlingMode::FIELD_ID),
74+
toString(MessageHandlingMode::Sequential)));
9575
}
9676
};
9777
void FixApp::toApp(FIX::Message &msg, const FIX::SessionID &sessionId) noexcept(false) {

src/binance/MessageHandlingMode.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef BINANCE_MESSAGE_HANDLING_MODE_H
2+
#define BINANCE_MESSAGE_HANDLING_MODE_H
3+
4+
#include <cstdint>
5+
#include <string>
6+
7+
namespace Binance {
8+
9+
/// @brief Binance Message Handling Mode
10+
/// Controls how the matching engine processes your messages
11+
/// [More
12+
/// info](https://developers.binance.com/docs/binance-spot-api-docs/fix-api#on-message-processing-order)
13+
enum class MessageHandlingMode : uint16_t {
14+
/// @brief UNORDERED(1) - Messages from the client are allowed to be sent to the
15+
/// matching engine in any order
16+
Unordered = 1,
17+
/// @brief SEQUENTIAL(2) - Messages from the client are always sent to the matching
18+
/// engine in MsgSeqNum (34) order
19+
Sequential = 2,
20+
/// @brief FIELD_ID(25035) - The Field ID that Binance uses for "Message Handling Mode"
21+
FIELD_ID = 25035,
22+
};
23+
24+
int toInt(const MessageHandlingMode m) { return static_cast<int>(m); }
25+
26+
std::string toString(const MessageHandlingMode m) {
27+
return std::to_string(static_cast<int>(m));
28+
}
29+
30+
} // namespace Binance
31+
32+
#endif // BINANCE_MESSAGE_HANDLING_MODE_H

0 commit comments

Comments
 (0)