This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new d17cd491 Add documention for the string processing methods (#689)
d17cd491 is described below
commit d17cd491bc365365790b1d08bcd6493ace93773c
Author: Stephen Webb <[email protected]>
AuthorDate: Tue May 26 11:16:31 2026 +1000
Add documention for the string processing methods (#689)
---
src/main/cpp/stringhelper.cpp | 6 +++++
src/main/include/log4cxx/helpers/stringhelper.h | 26 +++++++++++++++++-----
src/main/include/log4cxx/helpers/stringtokenizer.h | 5 +++++
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/main/cpp/stringhelper.cpp b/src/main/cpp/stringhelper.cpp
index c8142c11..42ad3e32 100644
--- a/src/main/cpp/stringhelper.cpp
+++ b/src/main/cpp/stringhelper.cpp
@@ -144,6 +144,8 @@ void StringHelper::toString(int n, LogString& dst)
{
#if LOG4CXX_LOGCHAR_IS_WCHAR
dst.append(std::to_wstring(n));
+#elif LOG4CXX_LOGCHAR_IS_UTF8
+ dst.append(std::to_string(n));
#else
Transcoder::decode(std::to_string(n), dst);
#endif
@@ -166,6 +168,8 @@ void StringHelper::toString(int64_t n, LogString& dst)
{
#if LOG4CXX_LOGCHAR_IS_WCHAR
dst.append(std::to_wstring(n));
+#elif LOG4CXX_LOGCHAR_IS_UTF8
+ dst.append(std::to_string(n));
#else
Transcoder::decode(std::to_string(n), dst);
#endif
@@ -176,6 +180,8 @@ void StringHelper::toString(size_t n, LogString& dst)
{
#if LOG4CXX_LOGCHAR_IS_WCHAR
dst.append(std::to_wstring(n));
+#elif LOG4CXX_LOGCHAR_IS_UTF8
+ dst.append(std::to_string(n));
#else
Transcoder::decode(std::to_string(n), dst);
#endif
diff --git a/src/main/include/log4cxx/helpers/stringhelper.h
b/src/main/include/log4cxx/helpers/stringhelper.h
index f84ede5e..d0d2d1ac 100644
--- a/src/main/include/log4cxx/helpers/stringhelper.h
+++ b/src/main/include/log4cxx/helpers/stringhelper.h
@@ -35,16 +35,22 @@ String manipulation routines
class LOG4CXX_EXPORT StringHelper
{
public:
+ /// A copy of \c s without any leading or trailing space
characters
static LogString trim(const LogString& s);
- static bool startsWith(const LogString& s, const LogString&
suffix);
+ /// Does \c s begin with the characters of \c prefix?
+ static bool startsWith(const LogString& s, const LogString&
prefix);
+ /// Does \c s end with the characters of \c suffix?
static bool endsWith(const LogString& s, const LogString&
suffix);
- static bool equalsIgnoreCase(const LogString& s1,
- const logchar* upper, const logchar* lower);
- static bool equalsIgnoreCase(const LogString& s1,
- const LogString& upper, const LogString& lower);
-
+ /// Is each character in \c s identical to the character at the
corresponding position in either \c upper or \c lower?
+ static bool equalsIgnoreCase(const LogString& s, const logchar*
upper, const logchar* lower);
+ /// Is each character in \c s identical to the character at the
corresponding position in either \c upper or \c lower?
+ static bool equalsIgnoreCase(const LogString& s, const
LogString& upper, const LogString& lower);
+ /// The numeric value at the start of \c s.
+ /// See <a
href=https://en.cppreference.com/cpp/string/basic_string/stol>std::stoi</a> for
more details.
static int toInt(const LogString& s);
+ /// The numeric value at the start of \c s.
+ /// See <a
href=https://en.cppreference.com/cpp/string/basic_string/stol>std::stoll</a>
for more details.
static int64_t toInt64(const LogString& s);
#if LOG4CXX_ABI_VERSION <= 15
@@ -58,13 +64,21 @@ class LOG4CXX_EXPORT StringHelper
[[ deprecated( "Pool is no longer required" ) ]]
static void toString(size_t i, Pool& pool, LogString& dst);
#endif
+ /// Append a textual version of \c i to \c dst.
static void toString(int i, LogString& dst);
+ /// Append a textual version of \c i to \c dst.
static void toString(int64_t i, LogString& dst);
+ /// Append a textual version of \c i to \c dst.
static void toString(size_t i, LogString& dst);
+ /// Using \c val, append either "true" or "false" to \c dst.
static void toString(bool val, LogString& dst);
+ /// A copy of \c s with any character in [A-Z]
+ /// replaced by the corresponding character in [a-z]
static LogString toLowerCase(const LogString& s);
+ /// A copy of \c pattern with any 3-character '{', [0-9], '}',
substring
+ /// replaced by the corresponding value from \c params
static LogString format(const LogString& pattern, const
std::vector<LogString>& params);
};
}
diff --git a/src/main/include/log4cxx/helpers/stringtokenizer.h
b/src/main/include/log4cxx/helpers/stringtokenizer.h
index 23e3241a..767b5919 100644
--- a/src/main/include/log4cxx/helpers/stringtokenizer.h
+++ b/src/main/include/log4cxx/helpers/stringtokenizer.h
@@ -24,12 +24,17 @@ namespace LOG4CXX_NS
{
namespace helpers
{
+/// An iterator over substrings
class LOG4CXX_EXPORT StringTokenizer
{
public:
+ /// The substrings of \c str between one of the characters in
\c delim.
StringTokenizer(const LogString& str, const LogString& delim);
~StringTokenizer();
+ /// Will nextToken() return a string?
bool hasMoreTokens() const;
+ /// Step past the current token which is returned.
+ /// \exception NoSuchElementException No substring is available.
LogString nextToken();
private: