]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/spirit/home/x3/support/traits/print_attribute.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / support / traits / print_attribute.hpp
index 4c7f7d7376348fb2a578af3279dc8cedf3a84e3a..b74ff0daa19251b06a33541e86dab0efae5139f5 100644 (file)
@@ -14,6 +14,9 @@
 #include <boost/fusion/include/for_each.hpp>
 #include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
 #include <boost/spirit/home/x3/support/traits/is_variant.hpp>
+#ifdef BOOST_SPIRIT_X3_UNICODE
+# include <boost/spirit/home/support/char_encoding/unicode.hpp>
+#endif
 
 namespace boost { namespace spirit { namespace x3 { namespace traits
 {
@@ -80,6 +83,28 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
             out << val;
         }
 
+#ifdef BOOST_SPIRIT_X3_UNICODE
+        static void call(Out& out, char_encoding::unicode::char_type val, plain_attribute)
+        {
+            if (val >= 0 && val < 127)
+            {
+              if (iscntrl(val))
+                out << "\\" << std::oct << int(val) << std::dec;
+              else if (isprint(val))
+                out << char(val);
+              else
+                out << "\\x" << std::hex << int(val) << std::dec;
+            }
+            else
+              out << "\\x" << std::hex << int(val) << std::dec;
+        }
+
+        static void call(Out& out, char val, plain_attribute tag)
+        {
+            call(out, static_cast<char_encoding::unicode::char_type>(val), tag);
+        }
+#endif
+
         // for fusion data types
         template <typename T_>
         static void call(Out& out, T_ const& val, tuple_attribute)