include/rtl/string.hxx                     |    4 ++++
 include/rtl/stringconcat.hxx               |   14 ++++++++++++++
 include/rtl/ustring.hxx                    |    4 ++++
 sal/qa/rtl/strings/test_strings_valuex.cxx |    4 ++--
 4 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 1e9f4de320f67d1218c710bcee1969a2324c6888
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Apr 4 11:27:54 2023 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Apr 4 23:01:56 2023 +0200

    Make O(U)String::boolean also return an O(U)StringNumber
    
    Change-Id: I184fa0e4e45662e0fac86076d1c8733a0465bb56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149978
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 70829b43aae2..9c2c6ae61f60 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -2125,6 +2125,9 @@ public:
         return boolean(b);
     }
 
+#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
+    static OStringNumber<bool> boolean(bool b) { return 
OStringNumber<bool>(b); }
+#else
     /**
       Returns the string representation of the boolean argument.
 
@@ -2141,6 +2144,7 @@ public:
         char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
         return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
     }
+#endif
 
     /**
       Returns the string representation of the char argument.
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index da32c7982792..118d93df5007 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -393,6 +393,13 @@ struct OStringNumber< double >
     OStringNumber(number_t d) { length = rtl_str_valueOfDouble(buf, d); }
 };
 
+template<>
+struct OStringNumber< bool >
+    : public StringNumberBase<char, bool, RTL_STR_MAX_VALUEOFBOOLEAN>
+{
+    OStringNumber(number_t b) { length = rtl_str_valueOfBoolean(buf, b); }
+};
+
 /**
  @internal
 
@@ -439,6 +446,13 @@ struct OUStringNumber< double >
     OUStringNumber(number_t d) { length = rtl_ustr_valueOfDouble(buf, d); }
 };
 
+template<>
+struct OUStringNumber< bool >
+    : public StringNumberBase<sal_Unicode, bool, RTL_USTR_MAX_VALUEOFBOOLEAN>
+{
+    OUStringNumber(number_t b) { length = rtl_ustr_valueOfBoolean(buf, b); }
+};
+
 template< typename C, typename T, std::size_t nBufSize >
 struct ToStringHelper< StringNumberBase< C, T, nBufSize > >
 {
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index ddc0b5d2c0b2..36d122c1fe5a 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -3186,6 +3186,9 @@ public:
         return boolean(b);
     }
 
+#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
+    static OUStringNumber<bool> boolean(bool b) { return 
OUStringNumber<bool>(b); }
+#else
     /**
       Returns the string representation of the boolean argument.
 
@@ -3202,6 +3205,7 @@ public:
         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
         return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
     }
+#endif
 
     /**
       Returns the string representation of the char argument.
diff --git a/sal/qa/rtl/strings/test_strings_valuex.cxx 
b/sal/qa/rtl/strings/test_strings_valuex.cxx
index 6c9c836442e1..953cf8b68efb 100644
--- a/sal/qa/rtl/strings/test_strings_valuex.cxx
+++ b/sal/qa/rtl/strings/test_strings_valuex.cxx
@@ -42,8 +42,8 @@ namespace {
 
 template< typename T >
 void testBoolean() {
-    CPPUNIT_ASSERT_EQUAL( T( "false" ), T::boolean( false ) );
-    CPPUNIT_ASSERT_EQUAL( T( "true" ), T::boolean( true ) );
+    CPPUNIT_ASSERT_EQUAL( T( "false" ), T(T::boolean( false )) );
+    CPPUNIT_ASSERT_EQUAL( T( "true" ), T(T::boolean( true )) );
 }
 
 }

Reply via email to