You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
753 B
C++

#pragma once
#include <vector>
#include "fmt/format.h"
constexpr auto SG_TERMINATOR = '\r';
class CSGMessageBuilder
{
public:
CSGMessageBuilder& Command(const std::string& cmd)
{
m_vecToken.clear(); // Start fresh
m_vecToken.push_back(cmd);
return *this;
}
CSGMessageBuilder& AddArg(const std::string& arg)
{
m_vecToken.push_back(arg);
return *this;
}
template <typename T>
CSGMessageBuilder& AddArg(T value)
{
m_vecToken.push_back(fmt::format("{}", value));
return *this;
}
std::string Build() const
{
return fmt::format("{}{}", fmt::join(m_vecToken, ","), SG_TERMINATOR);
}
private:
std::vector<std::string> m_vecToken;
};