* @param ... A variable number of format arguments.
* @return The formatted string
*/
- static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
- static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
+ static std::string Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
+ static std::string Format(va_list& vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
/** Determines whether a nickname is valid. */
TR1NS::function<bool(const std::string&)> IsNick;
do { \
va_list _vaList; \
va_start(_vaList, last); \
- ret = InspIRCd::Format(_vaList, format); \
+ ret.assign(InspIRCd::Format(_vaList, format)); \
va_end(_vaList); \
} while (false);
{
private:
/** The custom error message if one has been specified. */
- const char* message;
+ const std::string message;
public:
/** The code which represents this error. */
* @param c A code which represents this error.
*/
Error(ErrorCode c)
- : message(NULL)
- , code(c)
+ : code(c)
{
}
* @param c A code which represents this error.
* @param m A custom error message.
*/
- Error(ErrorCode c, const char* m)
+ Error(ErrorCode c, const std::string m)
: message(m)
, code(c)
{
/** Retrieves the error message. */
const char* ToString() const
{
- if (message)
- return message;
+ if (!message.empty())
+ return message.c_str();
switch (code)
{
return total + subtotal;
}
-const char* InspIRCd::Format(va_list &vaList, const char* formatString)
+std::string InspIRCd::Format(va_list& vaList, const char* formatString)
{
static std::vector<char> formatBuffer(1024);
formatBuffer.resize(formatBuffer.size() * 2);
}
- return &formatBuffer[0];
+ return std::string(&formatBuffer[0]);
}
-const char* InspIRCd::Format(const char* formatString, ...)
+std::string InspIRCd::Format(const char* formatString, ...)
{
- const char* ret;
+ std::string ret;
VAFORMAT(ret, formatString, formatString);
return ret;
}