From 126dfdb155a5c9ffa819a631d33b153e67ee8932 Mon Sep 17 00:00:00 2001 From: beder Date: Tue, 6 Sep 2011 00:39:31 -0500 Subject: [PATCH] Switched YAML::Binary interface to use unsigned chars, not chars --- include/yaml-cpp/emittermanip.h | 6 +++--- src/emitterutils.cpp | 2 +- src/emitterutils.h | 2 +- test/emittertests.cpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/yaml-cpp/emittermanip.h b/include/yaml-cpp/emittermanip.h index a096d10..5c63419 100644 --- a/include/yaml-cpp/emittermanip.h +++ b/include/yaml-cpp/emittermanip.h @@ -127,12 +127,12 @@ namespace YAML } struct _Binary { - _Binary(const char *data_, std::size_t size_): data(data_), size(size_) {} - const char *data; + _Binary(const unsigned char *data_, std::size_t size_): data(data_), size(size_) {} + const unsigned char *data; std::size_t size; }; - inline _Binary Binary(const char *data, std::size_t size) { + inline _Binary Binary(const unsigned char *data, std::size_t size) { return _Binary(data, size); } } diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp index be512af..95a01fa 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp @@ -347,7 +347,7 @@ namespace YAML return true; } - bool WriteBinary(ostream& out, const char *data, std::size_t size) + bool WriteBinary(ostream& out, const unsigned char *data, std::size_t size) { static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const char PAD = '='; diff --git a/src/emitterutils.h b/src/emitterutils.h index b6c0b70..27ca115 100644 --- a/src/emitterutils.h +++ b/src/emitterutils.h @@ -22,7 +22,7 @@ namespace YAML bool WriteAnchor(ostream& out, const std::string& str); bool WriteTag(ostream& out, const std::string& str, bool verbatim); bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag); - bool WriteBinary(ostream& out, const char *data, std::size_t size); + bool WriteBinary(ostream& out, const unsigned char *data, std::size_t size); } } diff --git a/test/emittertests.cpp b/test/emittertests.cpp index a7c13d8..4c5c668 100644 --- a/test/emittertests.cpp +++ b/test/emittertests.cpp @@ -759,19 +759,19 @@ namespace Test void Binary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("Hello, World!", 13); + out << YAML::Binary(reinterpret_cast("Hello, World!"), 13); desiredOutput = "!!binary \"SGVsbG8sIFdvcmxkIQ==\""; } void LongBinary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n", 270); + out << YAML::Binary(reinterpret_cast("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270); desiredOutput = "!!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\""; } void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("", 0); + out << YAML::Binary(reinterpret_cast(""), 0); desiredOutput = "!!binary \"\""; }