Files
qt5-legatus-legacy/Lts/DDS/Core/function_reply_object.cpp
T
2026-08-13 18:33:10 +02:00

53 lines
1.0 KiB
C++
Executable File

/**
* Helper class to properly fill FunctionReply objects
* $Id$
* $HeadURL$
* $Author$
*/
#include "function_reply_object.h"
#include <QtCore/QString>
#include <QtCore/QCoreApplication>
namespace Core
{
FunctionReplyObject &FunctionReplyObject::arg(qint64 val)
{
m_args.push_back(std::to_string(val));
return *this;
}
FunctionReplyObject &FunctionReplyObject::arg(const std::string &str)
{
m_args.push_back(str);
return *this;
}
FunctionReplyObject &FunctionReplyObject::arg(const QString &str)
{
m_args.push_back(str.toStdString());
return *this;
}
std::string FunctionReplyObject::operator()() const
{
if (m_args.empty())
return m_str;
QString ret(QString::fromStdString(m_str));
for (const std::string &s : m_args)
ret = ret.arg(QString::fromStdString(s));
return ret.toStdString();
}
QString FunctionReplyObject::translated() const
{
QString ret(QCoreApplication::translate("dds", m_str.c_str()));
for (const std::string &s : m_args)
ret = ret.arg(QString::fromStdString(s));
return ret;
}
} // namespace Core