diff --git a/server/src/core/console.cpp b/server/src/core/console.cpp index 5d091714..a6d398f5 100644 --- a/server/src/core/console.cpp +++ b/server/src/core/console.cpp @@ -61,7 +61,7 @@ std::ostream& operator<<(std::ostream& out, const Console::Level& value) return out; } -std::string to_string(const Console::Level& value) +std::string toString(const Console::Level& value) { switch(value) { diff --git a/server/src/core/console.hpp b/server/src/core/console.hpp index b0c9b203..47337b55 100644 --- a/server/src/core/console.hpp +++ b/server/src/core/console.hpp @@ -88,6 +88,6 @@ class Console : public Object, public Table TableModelPtr getModel() final; }; -std::string to_string(const Console::Level& value); +std::string toString(const Console::Level& value); #endif diff --git a/server/src/core/consoletablemodel.cpp b/server/src/core/consoletablemodel.cpp index 1a5f8eaf..03164083 100644 --- a/server/src/core/consoletablemodel.cpp +++ b/server/src/core/consoletablemodel.cpp @@ -66,7 +66,7 @@ std::string ConsoleTableModel::getText(uint32_t column, uint32_t row) const return s; } case columnLevel: - return to_string(log.level); + return toString(log.level); case columnId: return log.id; diff --git a/server/src/hardware/commandstation/rocoz21.cpp b/server/src/hardware/commandstation/rocoz21.cpp index ab69047d..9ec19dab 100644 --- a/server/src/hardware/commandstation/rocoz21.cpp +++ b/server/src/hardware/commandstation/rocoz21.cpp @@ -28,7 +28,7 @@ #include "../decoder/decoderchangeflags.hpp" #include "../protocol/xpressnet/messages.hpp" #include "../protocol/z21/messages.hpp" -#include "../../utils/to_hex.hpp" +#include "../../utils/tohex.hpp" @@ -330,7 +330,7 @@ void RocoZ21::receive() hwType = "Z21 start (starter set variant from 2016)"; break; default: - hwType = "0x" + to_hex(reply->hardwareType()); + hwType = "0x" + toHex(reply->hardwareType()); break; } @@ -400,7 +400,7 @@ void RocoZ21::receive() break; default: - EventLoop::call([this, xheader](){ logDebug("unknown xheader 0x" + to_hex(xheader)); }); + EventLoop::call([this, xheader](){ logDebug("unknown xheader 0x" + toHex(xheader)); }); break; } break; @@ -464,7 +464,7 @@ void RocoZ21::receive() { std::string message = "unknown loconet message: "; for(int i = 4; i < cmd->dataLen; i++) - message += to_hex(reinterpret_cast(cmd)[i]); + message += toHex(reinterpret_cast(cmd)[i]); EventLoop::call([this, message](){ logDebug(id, message); }); } break; @@ -476,12 +476,12 @@ void RocoZ21::receive() default: //if(debugEnabled) { - std::string log = "unknown message: dataLen=0x" + to_hex(message->dataLen()) + ", header=0x" + to_hex(message->header()); + std::string log = "unknown message: dataLen=0x" + toHex(message->dataLen()) + ", header=0x" + toHex(message->header()); if(message->dataLen() > 4) { log += ", data="; for(int i = sizeof(Z21::Message); i < message->dataLen(); i++) - log += to_hex(reinterpret_cast(message)[i]); + log += toHex(reinterpret_cast(message)[i]); } EventLoop::call([this, log](){ logDebug(log); }); } diff --git a/server/src/hardware/controller/wlanmaus.cpp b/server/src/hardware/controller/wlanmaus.cpp index 3cbdd124..db30d68b 100644 --- a/server/src/hardware/controller/wlanmaus.cpp +++ b/server/src/hardware/controller/wlanmaus.cpp @@ -26,10 +26,10 @@ #include "../commandstation/commandstation.hpp" #include "../decoder/decoder.hpp" #include "../protocol/z21/messages.hpp" -#include "../../utils/to_hex.hpp" +#include "../../utils/tohex.hpp" #include "../../core/attributes.hpp" -static std::string to_string(const boost::asio::ip::udp::endpoint& endpoint) +static std::string toString(const boost::asio::ip::udp::endpoint& endpoint) { std::stringstream ss; ss << endpoint; @@ -146,7 +146,7 @@ void WLANmaus::receive() if(m_debugLog) EventLoop::call( - [this, log=to_string(m_receiveEndpoint) + " rx: " + Z21::to_string(*message)]() + [this, log=toString(m_receiveEndpoint) + " rx: " + Z21::toString(*message)]() { logDebug(log); }); @@ -389,7 +389,7 @@ void WLANmaus::receive() [this, broadcastFlags=static_cast(message)->broadcastFlags(), endpoint=m_receiveEndpoint]() { if(debugLog) - logDebug(to_string(endpoint) + " LAN_SET_BROADCASTFLAGS 0x" + to_hex(broadcastFlags)); + logDebug(toString(endpoint) + " LAN_SET_BROADCASTFLAGS 0x" + toHex(broadcastFlags)); m_clients[endpoint].broadcastFlags = broadcastFlags; }); @@ -405,7 +405,7 @@ void WLANmaus::receive() [this, endpoint=m_receiveEndpoint]() { if(debugLog) - logDebug(to_string(endpoint) + " LAN_SYSTEMSTATE_GETDATA"); + logDebug(toString(endpoint) + " LAN_SYSTEMSTATE_GETDATA"); Z21::LanSystemStateDataChanged response; @@ -428,7 +428,7 @@ void WLANmaus::receive() [this, endpoint=m_receiveEndpoint]() { if(debugLog) - logDebug(to_string(endpoint) + " LAN_LOGOFF"); + logDebug(toString(endpoint) + " LAN_LOGOFF"); m_clients.erase(endpoint); }); } @@ -443,12 +443,12 @@ void WLANmaus::receive() /*if(unknownMessage && debugLog) { - std::string log = "unknown message: dataLen=0x" + to_hex(message->dataLen()) + ", header=0x" + to_hex(message->header()); + std::string log = "unknown message: dataLen=0x" + toHex(message->dataLen()) + ", header=0x" + toHex(message->header()); if(message->dataLen() > 4) { log += ", data="; for(int i = sizeof(Z21::Message); i < message->dataLen(); i++) - log += to_hex(reinterpret_cast(message)[i]); + log += toHex(reinterpret_cast(message)[i]); } EventLoop::call([this, log](){ logDebug(log); }); }*/ @@ -467,7 +467,7 @@ void WLANmaus::receive() void WLANmaus::sendTo(const Z21::Message& message, const boost::asio::ip::udp::endpoint& endpoint) { if(debugLog) - logDebug(to_string(endpoint) + " tx: " + Z21::to_string(message)); + logDebug(toString(endpoint) + " tx: " + Z21::toString(message)); // TODO: add to queue, send async diff --git a/server/src/hardware/protocol/loconet/loconet.cpp b/server/src/hardware/protocol/loconet/loconet.cpp index aa40b3ee..2ddc408b 100644 --- a/server/src/hardware/protocol/loconet/loconet.cpp +++ b/server/src/hardware/protocol/loconet/loconet.cpp @@ -79,7 +79,7 @@ LocoNet::LocoNet(Object& _parent, const std::string& parentPropertyName, std::fu bool LocoNet::send(const Message& message) { if(m_debugLog) - logDebug("tx: " + to_string(message)); + logDebug("tx: " + toString(message)); assert(isValid(message)); return m_send(message); } @@ -113,7 +113,7 @@ void LocoNet::receive(const Message& message) assert(isValid(message)); if(m_debugLog) - EventLoop::call([this, log="rx: " + to_string(message)](){ logDebug(log); }); + EventLoop::call([this, log="rx: " + toString(message)](){ logDebug(log); }); switch(message.opCode) { diff --git a/server/src/hardware/protocol/loconet/messages.cpp b/server/src/hardware/protocol/loconet/messages.cpp index d744c8fa..3980b1e7 100644 --- a/server/src/hardware/protocol/loconet/messages.cpp +++ b/server/src/hardware/protocol/loconet/messages.cpp @@ -21,7 +21,7 @@ */ #include "messages.hpp" -#include "../../../utils/to_hex.hpp" +#include "../../../utils/tohex.hpp" namespace LocoNet { @@ -56,13 +56,13 @@ bool isValid(const Message& message) return true; } -std::string to_string(const Message& message, bool raw) +std::string toString(const Message& message, bool raw) { std::string s; - if(std::string_view sv = to_string(message.opCode); !sv.empty()) + if(std::string_view sv = toString(message.opCode); !sv.empty()) s = sv; else - s = to_hex(message.opCode); + s = toHex(message.opCode); switch(message.opCode) { @@ -217,7 +217,7 @@ std::string to_string(const Message& message, bool raw) { if(i != 0) s.append(" "); - s.append(to_hex(bytes[i])); + s.append(toHex(bytes[i])); } s.append("]"); } diff --git a/server/src/hardware/protocol/loconet/messages.hpp b/server/src/hardware/protocol/loconet/messages.hpp index 09974cf8..fec54352 100644 --- a/server/src/hardware/protocol/loconet/messages.hpp +++ b/server/src/hardware/protocol/loconet/messages.hpp @@ -41,7 +41,7 @@ uint8_t calcChecksum(const Message& msmessageg); void updateChecksum(Message& message); bool isChecksumValid(const Message& message); bool isValid(const Message& message); -std::string to_string(const Message& message, bool raw = false); +std::string toString(const Message& message, bool raw = false); constexpr uint8_t SLOT_LOCO_MIN = 1; constexpr uint8_t SLOT_LOCO_MAX = 119; diff --git a/server/src/hardware/protocol/loconet/opcode.hpp b/server/src/hardware/protocol/loconet/opcode.hpp index dd6c0b5c..e9e9de80 100644 --- a/server/src/hardware/protocol/loconet/opcode.hpp +++ b/server/src/hardware/protocol/loconet/opcode.hpp @@ -73,7 +73,7 @@ enum OpCode : uint8_t OPC_WR_SL_DATA = 0xEF, }; -constexpr std::string_view to_string(OpCode value) +constexpr std::string_view toString(OpCode value) { switch(value) { diff --git a/server/src/hardware/protocol/xpressnet/messages.cpp b/server/src/hardware/protocol/xpressnet/messages.cpp index e58ce7c3..0d1ea77d 100644 --- a/server/src/hardware/protocol/xpressnet/messages.cpp +++ b/server/src/hardware/protocol/xpressnet/messages.cpp @@ -21,7 +21,7 @@ */ #include "messages.hpp" -#include "../../../utils/to_hex.hpp" +#include "../../../utils/tohex.hpp" namespace XpressNet { @@ -40,7 +40,7 @@ bool isChecksumValid(const Message& msg) return calcChecksum(msg) == *(reinterpret_cast(&msg) + msg.dataSize() + 1); } -std::string to_string(const Message& message, bool raw) +std::string toString(const Message& message, bool raw) { std::string s; @@ -59,7 +59,7 @@ std::string to_string(const Message& message, bool raw) { if(i != 0) s.append(" "); - s.append(to_hex(bytes[i])); + s.append(toHex(bytes[i])); } s.append("]"); } diff --git a/server/src/hardware/protocol/xpressnet/messages.hpp b/server/src/hardware/protocol/xpressnet/messages.hpp index 43a684f8..d5e70d08 100644 --- a/server/src/hardware/protocol/xpressnet/messages.hpp +++ b/server/src/hardware/protocol/xpressnet/messages.hpp @@ -35,7 +35,7 @@ struct Message; uint8_t calcChecksum(const Message& msg); bool isChecksumValid(const Message& msg); -std::string to_string(const Message& message, bool raw = false); +std::string toString(const Message& message, bool raw = false); struct Message { diff --git a/server/src/hardware/protocol/xpressnet/xpressnet.cpp b/server/src/hardware/protocol/xpressnet/xpressnet.cpp index dbdc713a..527e59fb 100644 --- a/server/src/hardware/protocol/xpressnet/xpressnet.cpp +++ b/server/src/hardware/protocol/xpressnet/xpressnet.cpp @@ -106,7 +106,7 @@ void XpressNet::receive(const Message& message) assert(isChecksumValid(message)); if(m_debugLog) - EventLoop::call([this, log="rx: " + to_string(message)](){ logDebug(log); }); + EventLoop::call([this, log="rx: " + toString(message)](){ logDebug(log); }); if(m_commandStation) { diff --git a/server/src/hardware/protocol/z21/messages.cpp b/server/src/hardware/protocol/z21/messages.cpp index 05ef566d..ae0e4841 100644 --- a/server/src/hardware/protocol/z21/messages.cpp +++ b/server/src/hardware/protocol/z21/messages.cpp @@ -22,11 +22,11 @@ #include "messages.hpp" #include "../../decoder/decoder.hpp" -#include "../../../utils/to_hex.hpp" +#include "../../../utils/tohex.hpp" namespace Z21 { -static std::string_view to_string(Header header) +static std::string_view toString(Header header) { switch(header) { @@ -44,13 +44,13 @@ static std::string_view to_string(Header header) return {}; } -std::string to_string(const Message& message, bool raw) +std::string toString(const Message& message, bool raw) { std::string s; - if(std::string_view sv = to_string(message.header()); !sv.empty()) + if(std::string_view sv = toString(message.header()); !sv.empty()) s = sv; else - s = to_hex(message.header()); + s = toHex(message.header()); switch(message.header()) { @@ -92,14 +92,14 @@ std::string to_string(const Message& message, bool raw) if(message.dataLen() == sizeof(Z21::LanGetBroadcastFlags)) s = "LAN_GET_BROADCASTFLAGS"; //else if(message.dataLen() == sizeof(Z21::LanGetBroadcastFlagsReply)) - // s = "LAN_GET_BROADCASTFLAGS flags=0x" + to_hex(static_cast(message).broadcastFlags())); + // s = "LAN_GET_BROADCASTFLAGS flags=0x" + toHex(static_cast(message).broadcastFlags())); else raw = true; break; case Z21::LAN_SET_BROADCASTFLAGS: if(message.dataLen() == sizeof(Z21::LanSetBroadcastFlags)) - s = "LAN_SET_BROADCASTFLAGS flags=0x" + to_hex(static_cast(message).broadcastFlags()); + s = "LAN_SET_BROADCASTFLAGS flags=0x" + toHex(static_cast(message).broadcastFlags()); else raw = true; break; @@ -117,7 +117,7 @@ std::string to_string(const Message& message, bool raw) { if(i != sizeof(Message)) s.append(" "); - s.append(to_hex(bytes[i])); + s.append(toHex(bytes[i])); } s.append("]"); } diff --git a/server/src/hardware/protocol/z21/messages.hpp b/server/src/hardware/protocol/z21/messages.hpp index 3146b997..135c9fee 100644 --- a/server/src/hardware/protocol/z21/messages.hpp +++ b/server/src/hardware/protocol/z21/messages.hpp @@ -37,7 +37,7 @@ namespace Z21 { struct Message; -std::string to_string(const Message& message, bool raw = false); +std::string toString(const Message& message, bool raw = false); enum Header : uint16_t { diff --git a/server/src/utils/to_hex.hpp b/server/src/utils/tohex.hpp similarity index 85% rename from server/src/utils/to_hex.hpp rename to server/src/utils/tohex.hpp index 13d24e97..e3d8c72d 100644 --- a/server/src/utils/to_hex.hpp +++ b/server/src/utils/tohex.hpp @@ -1,5 +1,5 @@ /** - * server/src/utils/to_hex.hpp + * server/src/utils/tohex.hpp * * This file is part of the traintastic source code. * @@ -20,13 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef TRAINTASTIC_SERVER_UTILS_TO_HEX_HPP -#define TRAINTASTIC_SERVER_UTILS_TO_HEX_HPP +#ifndef TRAINTASTIC_SERVER_UTILS_TOHEX_HPP +#define TRAINTASTIC_SERVER_UTILS_TOHEX_HPP #include template -std::string to_hex(T value, size_t length = sizeof(T) * 2) +std::string toHex(T value, size_t length = sizeof(T) * 2) { static const char* digits = "0123456789ABCDEF"; std::string s(length, '0');