Skip to content

Commit

Permalink
Convert CFString without using std::basic_string<UniCode>
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Aug 1, 2023
1 parent 2510c16 commit 457d192
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/log4cxx-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
cd main
mkdir build
cd build
cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DLOG4CXX_ENABLE_ODBC=on -DLOG4CXX_CFSTRING=on ..
cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DLOG4CXX_ENABLE_ODBC=ON -DLOG4CXX_CFSTRING=ON ..
cmake --build .
- name: run unit tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/log4cxx-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
cd main
mkdir build
cd build
cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DLOG4CXX_ENABLE_ODBC=on ..
cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DLOG4CXX_ENABLE_ODBC=ON ..
cmake --build .
- name: run unit tests
Expand Down
17 changes: 9 additions & 8 deletions src/main/cpp/messagebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,6 @@ UniCharMessageBuffer& MessageBuffer::operator<<(const CFStringRef& msg)
#include <CoreFoundation/CFString.h>
#include <vector>

#if LOG4CXX_WCHAR_T_API
CharMessageBuffer& MessageBuffer::operator<<(const CFStringRef& msg)
{
LOG4CXX_DECODE_CFSTRING(tmp, msg);
return m_priv->cbuf << tmp;
}
#else // MessageBuffer is CharMessageBuffer
CharMessageBuffer& CharMessageBuffer::operator<<(const CFStringRef& msg)
{
LOG4CXX_DECODE_CFSTRING(tmp, msg);
Expand All @@ -799,6 +792,14 @@ CharMessageBuffer& CharMessageBuffer::operator<<(const CFStringRef& msg)
}
return *this;
}
#endif // MessageBuffer is CharMessageBuffer

#if LOG4CXX_WCHAR_T_API
CharMessageBuffer& MessageBuffer::operator<<(const CFStringRef& msg)
{
LOG4CXX_DECODE_CFSTRING(tmp, msg);
return m_priv->cbuf << tmp;
}
#endif // LOG4CXX_WCHAR_T_API

#endif // LOG4CXX_CFSTRING_API

4 changes: 1 addition & 3 deletions src/main/include/log4cxx/helpers/messagebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ class LOG4CXX_EXPORT CharMessageBuffer
* @return this buffer.
*/
CharMessageBuffer& operator<<(const char msg);
#if LOG4CXX_CFSTRING_API && !LOG4CXX_WCHAR_T_API
#if LOG4CXX_CFSTRING_API
/**
* Appends a string into the buffer and
* fixes the buffer to use char characters.
* @param msg message to append.
* @return encapsulated CharMessageBuffer.
*/
CharMessageBuffer& operator<<(const CFStringRef& msg);

#endif

/**
Expand Down Expand Up @@ -743,7 +742,6 @@ class LOG4CXX_EXPORT MessageBuffer
* @return encapsulated CharMessageBuffer.
*/
CharMessageBuffer& operator<<(const CFStringRef& msg);

#endif

/**
Expand Down

0 comments on commit 457d192

Please sign in to comment.