mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Common: Tokenizer -> Trinity::Tokenize (PR: #25327)
(cherry picked from commit 534a2388b7)
This commit is contained in:
@@ -237,6 +237,18 @@ std::string Field::GetString() const
|
||||
return std::string(string, data.length);
|
||||
}
|
||||
|
||||
std::string_view Field::GetStringView() const
|
||||
{
|
||||
if (!data.value)
|
||||
return {};
|
||||
|
||||
char const* const string = GetCString();
|
||||
if (!string)
|
||||
return {};
|
||||
|
||||
return { string, data.length };
|
||||
}
|
||||
|
||||
std::vector<uint8> Field::GetBinary() const
|
||||
{
|
||||
std::vector<uint8> result;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "Define.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
enum class DatabaseFieldTypes : uint8
|
||||
@@ -104,6 +106,7 @@ class TC_DATABASE_API Field
|
||||
double GetDouble() const;
|
||||
char const* GetCString() const;
|
||||
std::string GetString() const;
|
||||
std::string_view GetStringView() const;
|
||||
std::vector<uint8> GetBinary() const;
|
||||
template <size_t S>
|
||||
std::array<uint8, S> GetBinary() const
|
||||
|
||||
@@ -32,21 +32,19 @@
|
||||
|
||||
MySQLConnectionInfo::MySQLConnectionInfo(std::string const& infoString)
|
||||
{
|
||||
Tokenizer tokens(infoString, ';');
|
||||
std::vector<std::string_view> tokens = Trinity::Tokenize(infoString, ';', true);
|
||||
|
||||
if (tokens.size() != 5 && tokens.size() != 6)
|
||||
return;
|
||||
|
||||
uint8 i = 0;
|
||||
|
||||
host.assign(tokens[i++]);
|
||||
port_or_socket.assign(tokens[i++]);
|
||||
user.assign(tokens[i++]);
|
||||
password.assign(tokens[i++]);
|
||||
database.assign(tokens[i++]);
|
||||
host.assign(tokens[0]);
|
||||
port_or_socket.assign(tokens[1]);
|
||||
user.assign(tokens[2]);
|
||||
password.assign(tokens[3]);
|
||||
database.assign(tokens[4]);
|
||||
|
||||
if (tokens.size() == 6)
|
||||
ssl.assign(tokens[i++]);
|
||||
ssl.assign(tokens[5]);
|
||||
}
|
||||
|
||||
MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) :
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "LogMessage.h"
|
||||
#include "PreparedStatement.h"
|
||||
|
||||
AppenderDB::AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags /*flags*/, std::vector<char const*> /*extraArgs*/)
|
||||
AppenderDB::AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags /*flags*/, std::vector<std::string_view> const& /*args*/)
|
||||
: Appender(id, name, level), realmId(0), enabled(false) { }
|
||||
|
||||
AppenderDB::~AppenderDB() { }
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
class TC_DATABASE_API AppenderDB: public Appender
|
||||
{
|
||||
public:
|
||||
typedef std::integral_constant<AppenderType, APPENDER_DB>::type TypeIndex;
|
||||
static constexpr AppenderType type = APPENDER_DB;
|
||||
|
||||
AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags flags, std::vector<char const*> extraArgs);
|
||||
AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags flags, std::vector<std::string_view> const& args);
|
||||
~AppenderDB();
|
||||
|
||||
void setRealmId(uint32 realmId) override;
|
||||
AppenderType getType() const override { return TypeIndex::value; }
|
||||
AppenderType getType() const override { return type; }
|
||||
|
||||
private:
|
||||
uint32 realmId;
|
||||
|
||||
Reference in New Issue
Block a user