From d6156890f400255edd4d76569c0e03b14e8bce95 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 31 May 2020 12:48:12 -0700 Subject: [PATCH] print array of quoted strings --- src/sharedarray.cpp | 10 ++++++---- test/testtype.cpp | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sharedarray.cpp b/src/sharedarray.cpp index 7837a21..840b9c3 100644 --- a/src/sharedarray.cpp +++ b/src/sharedarray.cpp @@ -67,11 +67,13 @@ namespace detail { namespace { template -struct Print { static inline const E& as(const E& val) { return val; } }; +struct Print { static inline void as(std::ostream& strm,const E& val) { strm< -struct Print { static inline int as(int8_t val) { return val; } }; +struct Print { static inline void as(std::ostream& strm,int8_t val) { strm< -struct Print { static inline unsigned as(uint8_t val) { return val; } }; +struct Print { static inline void as(std::ostream& strm,uint8_t val) { strm< +struct Print { static inline void as(std::ostream& strm,const std::string& val) { strm<<"\""< void showArr(std::ostream& strm, const void* raw, size_t count, size_t limit) @@ -89,7 +91,7 @@ void showArr(std::ostream& strm, const void* raw, size_t count, size_t limit) strm<<"..."; break; } - strm<::as(base[i]); + Print::as(strm, base[i]); } strm<<']'; } diff --git a/test/testtype.cpp b/test/testtype.cpp index d2def22..fa46e25 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -374,7 +374,7 @@ void testFormat() " } scalar\n" " struct {\n" " int32_t[] i32 = {4}[1, -1, 2, -3]\n" - " string[] s = {3}[one, two, three]\n" + " string[] s = {3}[\"one\", \"two\", \"three\"]\n" " any[] wildcard [\n" " string = \"simple\"\n" " null\n" @@ -407,7 +407,7 @@ void testFormat() "scalar.choice->one int32_t = 1024\n" "array struct\n" "array.i32 int32_t[] = {4}[1, -1, 2, -3]\n" - "array.s string[] = {3}[one, two, three]\n" + "array.s string[] = {3}[\"one\", \"two\", \"three\"]\n" "array.wildcard any[]\n" "array.wildcard[0] string = \"simple\"\n" "array.wildcard[1] null\n"