Update SkWriteBuffer::writeString to take a string_view.
This will work fine with existing call sites passing a const char*, and unlocks the ability for passing string_views when we don't have null-terminated text handy. Change-Id: I4e69b1cbccceba19bc77d70a48c6fc9dff8ba87e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/557587 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
467762b90f
commit
a33befc610
@ -431,6 +431,7 @@ skia_core_sources = [
|
||||
"$_src/core/SkVertState.cpp",
|
||||
"$_src/core/SkVertices.cpp",
|
||||
"$_src/core/SkWriteBuffer.cpp",
|
||||
"$_src/core/SkWriteBuffer.h",
|
||||
"$_src/core/SkWriter32.cpp",
|
||||
"$_src/core/SkWriter32.h",
|
||||
"$_src/core/SkXfermode.cpp",
|
||||
|
@ -68,8 +68,8 @@ void SkBinaryWriteBuffer::writeUInt(uint32_t value) {
|
||||
fWriter.write32(value);
|
||||
}
|
||||
|
||||
void SkBinaryWriteBuffer::writeString(const char* value) {
|
||||
fWriter.writeString(value);
|
||||
void SkBinaryWriteBuffer::writeString(std::string_view value) {
|
||||
fWriter.writeString(value.data(), value.size());
|
||||
}
|
||||
|
||||
void SkBinaryWriteBuffer::writeColor(SkColor color) {
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "include/private/SkTHash.h"
|
||||
#include "src/core/SkWriter32.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class SkFactorySet;
|
||||
class SkImage;
|
||||
class SkM44;
|
||||
@ -45,7 +47,7 @@ public:
|
||||
void write32(int32_t value) {
|
||||
this->writeInt(value);
|
||||
}
|
||||
virtual void writeString(const char* value) = 0;
|
||||
virtual void writeString(std::string_view value) = 0;
|
||||
|
||||
virtual void writeFlattenable(const SkFlattenable* flattenable) = 0;
|
||||
virtual void writeColor(SkColor color) = 0;
|
||||
@ -108,7 +110,7 @@ public:
|
||||
void writeInt(int32_t value) override;
|
||||
void writeIntArray(const int32_t* value, uint32_t count) override;
|
||||
void writeUInt(uint32_t value) override;
|
||||
void writeString(const char* value) override;
|
||||
void writeString(std::string_view value) override;
|
||||
|
||||
void writeFlattenable(const SkFlattenable* flattenable) override;
|
||||
void writeColor(SkColor color) override;
|
||||
|
@ -89,9 +89,9 @@ void JsonWriteBuffer::writeUInt(uint32_t value) {
|
||||
fWriter->appendU32(value);
|
||||
}
|
||||
|
||||
void JsonWriteBuffer::writeString(const char* value) {
|
||||
void JsonWriteBuffer::writeString(std::string_view value) {
|
||||
this->append("string");
|
||||
fWriter->appendCString(value);
|
||||
fWriter->appendString(value.data(), value.size());
|
||||
}
|
||||
|
||||
void JsonWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) {
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class SkFlattenable;
|
||||
class SkImage;
|
||||
class SkJSONWriter;
|
||||
@ -43,7 +45,7 @@ public:
|
||||
void writeInt(int32_t value) override;
|
||||
void writeIntArray(const int32_t* value, uint32_t count) override;
|
||||
void writeUInt(uint32_t value) override;
|
||||
void writeString(const char* value) override;
|
||||
void writeString(std::string_view value) override;
|
||||
|
||||
void writeFlattenable(const SkFlattenable* flattenable) override;
|
||||
void writeColor(SkColor color) override;
|
||||
|
Loading…
Reference in New Issue
Block a user