mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Use std::string_view in logging code
This commit is contained in:
parent
ac11a14509
commit
b8b99d5cf1
7 changed files with 61 additions and 54 deletions
25
src/log.cpp
25
src/log.cpp
|
@ -55,7 +55,7 @@ public:
|
||||||
return m_logger.hasOutput(m_level);
|
return m_logger.hasOutput(m_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void log(const std::string &buf) override {
|
virtual void log(std::string_view buf) override {
|
||||||
if (!m_raw) {
|
if (!m_raw) {
|
||||||
m_logger.log(m_level, buf);
|
m_logger.log(m_level, buf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,7 +106,7 @@ thread_local LogStream dout_con(trace_target);
|
||||||
// Android
|
// Android
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
|
|
||||||
static unsigned int g_level_to_android[] = {
|
constexpr static unsigned int g_level_to_android[] = {
|
||||||
ANDROID_LOG_INFO, // LL_NONE
|
ANDROID_LOG_INFO, // LL_NONE
|
||||||
ANDROID_LOG_ERROR, // LL_ERROR
|
ANDROID_LOG_ERROR, // LL_ERROR
|
||||||
ANDROID_LOG_WARN, // LL_WARNING
|
ANDROID_LOG_WARN, // LL_WARNING
|
||||||
|
@ -116,11 +116,12 @@ static unsigned int g_level_to_android[] = {
|
||||||
ANDROID_LOG_VERBOSE, // LL_TRACE
|
ANDROID_LOG_VERBOSE, // LL_TRACE
|
||||||
};
|
};
|
||||||
|
|
||||||
void AndroidLogOutput::logRaw(LogLevel lev, const std::string &line)
|
void AndroidLogOutput::logRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
static_assert(ARRLEN(g_level_to_android) == LL_MAX,
|
static_assert(ARRLEN(g_level_to_android) == LL_MAX,
|
||||||
"mismatch between android and internal loglevels");
|
"mismatch between android and internal loglevels");
|
||||||
__android_log_write(g_level_to_android[lev], PROJECT_NAME_C, line.c_str());
|
__android_log_print(g_level_to_android[lev], PROJECT_NAME_C, "%.*s",
|
||||||
|
line.size(), line.data());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ void AndroidLogOutput::logRaw(LogLevel lev, const std::string &line)
|
||||||
//// Logger
|
//// Logger
|
||||||
////
|
////
|
||||||
|
|
||||||
LogLevel Logger::stringToLevel(const std::string &name)
|
LogLevel Logger::stringToLevel(std::string_view name)
|
||||||
{
|
{
|
||||||
if (name == "none")
|
if (name == "none")
|
||||||
return LL_NONE;
|
return LL_NONE;
|
||||||
|
@ -202,7 +203,7 @@ void Logger::setLevelSilenced(LogLevel lev, bool silenced)
|
||||||
m_silenced_levels[lev] = silenced;
|
m_silenced_levels[lev] = silenced;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::registerThread(const std::string &name)
|
void Logger::registerThread(std::string_view name)
|
||||||
{
|
{
|
||||||
std::thread::id id = std::this_thread::get_id();
|
std::thread::id id = std::this_thread::get_id();
|
||||||
MutexAutoLock lock(m_mutex);
|
MutexAutoLock lock(m_mutex);
|
||||||
|
@ -252,7 +253,7 @@ const std::string &Logger::getThreadName()
|
||||||
return fallback_name;
|
return fallback_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::log(LogLevel lev, const std::string &text)
|
void Logger::log(LogLevel lev, std::string_view text)
|
||||||
{
|
{
|
||||||
if (isLevelSilenced(lev))
|
if (isLevelSilenced(lev))
|
||||||
return;
|
return;
|
||||||
|
@ -268,7 +269,7 @@ void Logger::log(LogLevel lev, const std::string &text)
|
||||||
logToOutputs(lev, line, timestamp, thread_name, text);
|
logToOutputs(lev, line, timestamp, thread_name, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logRaw(LogLevel lev, const std::string &text)
|
void Logger::logRaw(LogLevel lev, std::string_view text)
|
||||||
{
|
{
|
||||||
if (isLevelSilenced(lev))
|
if (isLevelSilenced(lev))
|
||||||
return;
|
return;
|
||||||
|
@ -276,7 +277,7 @@ void Logger::logRaw(LogLevel lev, const std::string &text)
|
||||||
logToOutputsRaw(lev, text);
|
logToOutputsRaw(lev, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logToOutputsRaw(LogLevel lev, const std::string &line)
|
void Logger::logToOutputsRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_mutex);
|
MutexAutoLock lock(m_mutex);
|
||||||
for (size_t i = 0; i != m_outputs[lev].size(); i++)
|
for (size_t i = 0; i != m_outputs[lev].size(); i++)
|
||||||
|
@ -285,7 +286,7 @@ void Logger::logToOutputsRaw(LogLevel lev, const std::string &line)
|
||||||
|
|
||||||
void Logger::logToOutputs(LogLevel lev, const std::string &combined,
|
void Logger::logToOutputs(LogLevel lev, const std::string &combined,
|
||||||
const std::string &time, const std::string &thread_name,
|
const std::string &time, const std::string &thread_name,
|
||||||
const std::string &payload_text)
|
std::string_view payload_text)
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_mutex);
|
MutexAutoLock lock(m_mutex);
|
||||||
for (size_t i = 0; i != m_outputs[lev].size(); i++)
|
for (size_t i = 0; i != m_outputs[lev].size(); i++)
|
||||||
|
@ -334,7 +335,7 @@ StreamLogOutput::StreamLogOutput(std::ostream &stream) :
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamLogOutput::logRaw(LogLevel lev, const std::string &line)
|
void StreamLogOutput::logRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
bool colored_message = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
|
bool colored_message = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
|
||||||
(Logger::color_mode == LOG_COLOR_AUTO && is_tty);
|
(Logger::color_mode == LOG_COLOR_AUTO && is_tty);
|
||||||
|
@ -385,7 +386,7 @@ void LogOutputBuffer::updateLogLevel()
|
||||||
m_logger.addOutputMaxLevel(this, log_level);
|
m_logger.addOutputMaxLevel(this, log_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogOutputBuffer::logRaw(LogLevel lev, const std::string &line)
|
void LogOutputBuffer::logRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
std::string color;
|
std::string color;
|
||||||
|
|
||||||
|
|
32
src/log.h
32
src/log.h
|
@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <string>
|
#include <string_view>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -62,14 +62,14 @@ public:
|
||||||
LogLevelMask removeOutput(ILogOutput *out);
|
LogLevelMask removeOutput(ILogOutput *out);
|
||||||
void setLevelSilenced(LogLevel lev, bool silenced);
|
void setLevelSilenced(LogLevel lev, bool silenced);
|
||||||
|
|
||||||
void registerThread(const std::string &name);
|
void registerThread(std::string_view name);
|
||||||
void deregisterThread();
|
void deregisterThread();
|
||||||
|
|
||||||
void log(LogLevel lev, const std::string &text);
|
void log(LogLevel lev, std::string_view text);
|
||||||
// Logs without a prefix
|
// Logs without a prefix
|
||||||
void logRaw(LogLevel lev, const std::string &text);
|
void logRaw(LogLevel lev, std::string_view text);
|
||||||
|
|
||||||
static LogLevel stringToLevel(const std::string &name);
|
static LogLevel stringToLevel(std::string_view name);
|
||||||
static const char *getLevelLabel(LogLevel lev);
|
static const char *getLevelLabel(LogLevel lev);
|
||||||
|
|
||||||
bool hasOutput(LogLevel level) {
|
bool hasOutput(LogLevel level) {
|
||||||
|
@ -83,10 +83,10 @@ public:
|
||||||
static LogColor color_mode;
|
static LogColor color_mode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void logToOutputsRaw(LogLevel, const std::string &line);
|
void logToOutputsRaw(LogLevel, std::string_view line);
|
||||||
void logToOutputs(LogLevel, const std::string &combined,
|
void logToOutputs(LogLevel, const std::string &combined,
|
||||||
const std::string &time, const std::string &thread_name,
|
const std::string &time, const std::string &thread_name,
|
||||||
const std::string &payload_text);
|
std::string_view payload_text);
|
||||||
|
|
||||||
const std::string &getThreadName();
|
const std::string &getThreadName();
|
||||||
|
|
||||||
|
@ -99,17 +99,17 @@ private:
|
||||||
|
|
||||||
class ILogOutput {
|
class ILogOutput {
|
||||||
public:
|
public:
|
||||||
virtual void logRaw(LogLevel, const std::string &line) = 0;
|
virtual void logRaw(LogLevel, std::string_view line) = 0;
|
||||||
virtual void log(LogLevel, const std::string &combined,
|
virtual void log(LogLevel, const std::string &combined,
|
||||||
const std::string &time, const std::string &thread_name,
|
const std::string &time, const std::string &thread_name,
|
||||||
const std::string &payload_text) = 0;
|
std::string_view payload_text) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ICombinedLogOutput : public ILogOutput {
|
class ICombinedLogOutput : public ILogOutput {
|
||||||
public:
|
public:
|
||||||
void log(LogLevel lev, const std::string &combined,
|
void log(LogLevel lev, const std::string &combined,
|
||||||
const std::string &time, const std::string &thread_name,
|
const std::string &time, const std::string &thread_name,
|
||||||
const std::string &payload_text)
|
std::string_view payload_text)
|
||||||
{
|
{
|
||||||
logRaw(lev, combined);
|
logRaw(lev, combined);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class StreamLogOutput : public ICombinedLogOutput {
|
||||||
public:
|
public:
|
||||||
StreamLogOutput(std::ostream &stream);
|
StreamLogOutput(std::ostream &stream);
|
||||||
|
|
||||||
void logRaw(LogLevel lev, const std::string &line);
|
void logRaw(LogLevel lev, std::string_view line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostream &m_stream;
|
std::ostream &m_stream;
|
||||||
|
@ -130,7 +130,7 @@ class FileLogOutput : public ICombinedLogOutput {
|
||||||
public:
|
public:
|
||||||
void setFile(const std::string &filename, s64 file_size_max);
|
void setFile(const std::string &filename, s64 file_size_max);
|
||||||
|
|
||||||
void logRaw(LogLevel lev, const std::string &line)
|
void logRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
m_stream << line << std::endl;
|
m_stream << line << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ public:
|
||||||
|
|
||||||
void updateLogLevel();
|
void updateLogLevel();
|
||||||
|
|
||||||
void logRaw(LogLevel lev, const std::string &line);
|
void logRaw(LogLevel lev, std::string_view line);
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
@ -190,7 +190,7 @@ private:
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
class AndroidLogOutput : public ICombinedLogOutput {
|
class AndroidLogOutput : public ICombinedLogOutput {
|
||||||
public:
|
public:
|
||||||
void logRaw(LogLevel lev, const std::string &line);
|
void logRaw(LogLevel lev, std::string_view line);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class LogTarget {
|
||||||
public:
|
public:
|
||||||
// Must be thread-safe. These can be called from any thread.
|
// Must be thread-safe. These can be called from any thread.
|
||||||
virtual bool hasOutput() = 0;
|
virtual bool hasOutput() = 0;
|
||||||
virtual void log(const std::string &buf) = 0;
|
virtual void log(std::string_view buf) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public:
|
||||||
return m_target.hasOutput();
|
return m_target.hasOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void internalFlush(const std::string &buf) {
|
void internalFlush(std::string_view buf) {
|
||||||
m_target.log(buf);
|
m_target.log(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,27 +122,30 @@ void script_error(lua_State *L, int pcall_result, const char *mod, const char *f
|
||||||
throw LuaError(err_msg);
|
throw LuaError(err_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void script_log_add_source(lua_State *L, std::string &message, int stack_depth)
|
[[nodiscard]] static std::string script_log_add_source(lua_State *L,
|
||||||
|
std::string_view message, int stack_depth)
|
||||||
{
|
{
|
||||||
|
std::string ret(message);
|
||||||
if (stack_depth <= 0)
|
if (stack_depth <= 0)
|
||||||
return;
|
return ret;
|
||||||
|
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
if (lua_getstack(L, stack_depth, &ar)) {
|
if (lua_getstack(L, stack_depth, &ar)) {
|
||||||
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
|
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
|
||||||
message.append(" (at " + std::string(ar.short_src) + ":"
|
ret.append(" (at ").append(ar.short_src).append(":"
|
||||||
+ std::to_string(ar.currentline) + ")");
|
+ std::to_string(ar.currentline) + ")");
|
||||||
} else {
|
} else {
|
||||||
message.append(" (at ?:?)");
|
ret.append(" (at ?:?)");
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool script_log_unique(lua_State *L, std::string message, std::ostream &log_to,
|
bool script_log_unique(lua_State *L, std::string_view message_in, std::ostream &log_to,
|
||||||
int stack_depth)
|
int stack_depth)
|
||||||
{
|
{
|
||||||
thread_local std::vector<u64> logged_messages;
|
thread_local std::vector<u64> logged_messages;
|
||||||
|
|
||||||
script_log_add_source(L, message, stack_depth);
|
auto message = script_log_add_source(L, message_in, stack_depth);
|
||||||
u64 hash = murmur_hash_64_ua(message.data(), message.length(), 0xBADBABE);
|
u64 hash = murmur_hash_64_ua(message.data(), message.length(), 0xBADBABE);
|
||||||
|
|
||||||
if (std::find(logged_messages.begin(), logged_messages.end(), hash)
|
if (std::find(logged_messages.begin(), logged_messages.end(), hash)
|
||||||
|
@ -174,7 +177,7 @@ DeprecatedHandlingMode get_deprecated_handling_mode()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_deprecated(lua_State *L, std::string message, int stack_depth, bool once)
|
void log_deprecated(lua_State *L, std::string_view message, int stack_depth, bool once)
|
||||||
{
|
{
|
||||||
DeprecatedHandlingMode mode = get_deprecated_handling_mode();
|
DeprecatedHandlingMode mode = get_deprecated_handling_mode();
|
||||||
if (mode == DeprecatedHandlingMode::Ignore)
|
if (mode == DeprecatedHandlingMode::Ignore)
|
||||||
|
@ -184,12 +187,12 @@ void log_deprecated(lua_State *L, std::string message, int stack_depth, bool onc
|
||||||
if (once) {
|
if (once) {
|
||||||
log = script_log_unique(L, message, warningstream, stack_depth);
|
log = script_log_unique(L, message, warningstream, stack_depth);
|
||||||
} else {
|
} else {
|
||||||
script_log_add_source(L, message, stack_depth);
|
auto message2 = script_log_add_source(L, message, stack_depth);
|
||||||
warningstream << message << std::endl;
|
warningstream << message2 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == DeprecatedHandlingMode::Error)
|
if (mode == DeprecatedHandlingMode::Error)
|
||||||
throw LuaError(message);
|
throw LuaError(std::string(message));
|
||||||
else if (log)
|
else if (log)
|
||||||
infostream << script_get_backtrace(L) << std::endl;
|
infostream << script_get_backtrace(L) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
@ -127,7 +129,7 @@ int script_error_handler(lua_State *L);
|
||||||
// Takes an error from lua_pcall and throws it as a LuaError
|
// Takes an error from lua_pcall and throws it as a LuaError
|
||||||
void script_error(lua_State *L, int pcall_result, const char *mod, const char *fxn);
|
void script_error(lua_State *L, int pcall_result, const char *mod, const char *fxn);
|
||||||
|
|
||||||
bool script_log_unique(lua_State *L, std::string message, std::ostream &log_to,
|
bool script_log_unique(lua_State *L, std::string_view message, std::ostream &log_to,
|
||||||
int stack_depth = 1);
|
int stack_depth = 1);
|
||||||
|
|
||||||
enum DeprecatedHandlingMode {
|
enum DeprecatedHandlingMode {
|
||||||
|
@ -152,7 +154,8 @@ DeprecatedHandlingMode get_deprecated_handling_mode();
|
||||||
* (ie: not builtin or core). -1 to disabled.
|
* (ie: not builtin or core). -1 to disabled.
|
||||||
* @param once Log the deprecation warning only once per callsite.
|
* @param once Log the deprecation warning only once per callsite.
|
||||||
*/
|
*/
|
||||||
void log_deprecated(lua_State *L, std::string message, int stack_depth = 1, bool once = false);
|
void log_deprecated(lua_State *L, std::string_view message,
|
||||||
|
int stack_depth = 1, bool once = false);
|
||||||
|
|
||||||
// Safely call string.dump on a function value
|
// Safely call string.dump on a function value
|
||||||
// (does not pop, leaves one value on stack)
|
// (does not pop, leaves one value on stack)
|
||||||
|
|
|
@ -61,13 +61,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
int ModApiUtil::l_log(lua_State *L)
|
int ModApiUtil::l_log(lua_State *L)
|
||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
std::string text;
|
std::string_view text;
|
||||||
LogLevel level = LL_NONE;
|
LogLevel level = LL_NONE;
|
||||||
if (lua_isnone(L, 2)) {
|
if (lua_isnoneornil(L, 2)) {
|
||||||
text = luaL_checkstring(L, 1);
|
text = readParam<std::string_view>(L, 1);
|
||||||
} else {
|
} else {
|
||||||
std::string name = luaL_checkstring(L, 1);
|
auto name = readParam<std::string_view>(L, 1);
|
||||||
text = luaL_checkstring(L, 2);
|
text = readParam<std::string_view>(L, 2);
|
||||||
if (name == "deprecated") {
|
if (name == "deprecated") {
|
||||||
log_deprecated(L, text, 2);
|
log_deprecated(L, text, 2);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -32,14 +32,14 @@ struct ChatInterface;
|
||||||
class TermLogOutput : public ILogOutput {
|
class TermLogOutput : public ILogOutput {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void logRaw(LogLevel lev, const std::string &line)
|
void logRaw(LogLevel lev, std::string_view line)
|
||||||
{
|
{
|
||||||
queue.push_back(std::make_pair(lev, line));
|
queue.push_back(std::make_pair(lev, std::string(line)));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void log(LogLevel lev, const std::string &combined,
|
virtual void log(LogLevel lev, const std::string &combined,
|
||||||
const std::string &time, const std::string &thread_name,
|
const std::string &time, const std::string &thread_name,
|
||||||
const std::string &payload_text)
|
std::string_view payload_text)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios_base::binary);
|
std::ostringstream os(std::ios_base::binary);
|
||||||
os << time << ": [" << thread_name << "] " << payload_text;
|
os << time << ": [" << thread_name << "] " << payload_text;
|
||||||
|
|
|
@ -20,10 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string_view>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
template<int BufferLength, typename Emitter = std::function<void(const std::string &)> >
|
template<int BufferLength, typename Emitter = std::function<void(std::string_view)> >
|
||||||
class StringStreamBuffer : public std::streambuf {
|
class StringStreamBuffer : public std::streambuf {
|
||||||
public:
|
public:
|
||||||
StringStreamBuffer(Emitter emitter) : m_emitter(emitter) {
|
StringStreamBuffer(Emitter emitter) : m_emitter(emitter) {
|
||||||
|
@ -38,19 +38,19 @@ public:
|
||||||
void push_back(char c) {
|
void push_back(char c) {
|
||||||
if (c == '\n' || c == '\r') {
|
if (c == '\n' || c == '\r') {
|
||||||
if (buffer_index)
|
if (buffer_index)
|
||||||
m_emitter(std::string(buffer, buffer_index));
|
m_emitter(std::string_view(buffer, buffer_index));
|
||||||
buffer_index = 0;
|
buffer_index = 0;
|
||||||
} else {
|
} else {
|
||||||
buffer[buffer_index++] = c;
|
buffer[buffer_index++] = c;
|
||||||
if (buffer_index >= BufferLength) {
|
if (buffer_index >= BufferLength) {
|
||||||
m_emitter(std::string(buffer, buffer_index));
|
m_emitter(std::string_view(buffer, buffer_index));
|
||||||
buffer_index = 0;
|
buffer_index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize xsputn(const char *s, std::streamsize n) {
|
std::streamsize xsputn(const char *s, std::streamsize n) {
|
||||||
for (int i = 0; i < n; ++i)
|
for (std::streamsize i = 0; i < n; ++i)
|
||||||
push_back(s[i]);
|
push_back(s[i]);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue