Added WriteString to jsonfile which takes an std::string

This commit is contained in:
Jordan Cristiano 2015-07-13 21:09:07 -04:00
parent 04b79ff3f8
commit 2bf16179ad
3 changed files with 12 additions and 3 deletions

View File

@ -156,13 +156,20 @@ namespace base
writer.String(value);
}
void JsonWriterFile::WriteString(const char* name, const char* value, std::int32_t length)
void JsonWriterFile::WriteString(const char* name, const char* value, std::size_t length)
{
auto& writer = m_writer;
writer.String(name);
writer.String(value, length);
}
void JsonWriterFile::WriteString(const char* name, const std::string& value)
{
auto& writer = m_writer;
writer.String(name);
writer.String(value.c_str(), value.length());
}
void JsonWriterFile::WriteFloat(const char* name, const double value)
{
auto& writer = m_writer;

View File

@ -6,6 +6,7 @@
#include <cstdint>
#include <cstdio>
#include <cstddef>
#include <string>
namespace base
{
@ -36,7 +37,8 @@ namespace base
void WriteUInt32(const char* name, std::uint32_t value, bool writeCondition);
void WriteUint64(const char* name, std::uint64_t value);
void WriteString(const char* name, const char* value);
void WriteString(const char* name, const char* value, std::int32_t length);
void WriteString(const char* name, const char* value, std::size_t length);
void WriteString(const char* name, const std::string& value);
void WriteFloat(const char* name, const double value);
void WriteBits(const char* name, const unsigned char* data, std::size_t numBits);

View File

@ -27,7 +27,7 @@ namespace DemHandlers
bool Dem_ConsoleCmd_JsonWrite_Internal(JsonWrite& jsonbuf, DemMsg::Dem_ConsoleCmd* data)
{
jsonbuf.WriteString("command", data->command.c_str(), data->command.length());
jsonbuf.WriteString("command", data->command);
return true;
}
}