Author: carnold
Date: Tue Sep 25 09:58:52 2007
New Revision: 579315
URL: http://svn.apache.org/viewvc?rev=579315&view=rev
Log:
LOGCXX-18: Add doc comments for MessageBuffer
Modified:
logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
Modified: logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp?rev=579315&r1=579314&r2=579315&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp Tue Sep 25 09:58:52
2007
@@ -54,16 +54,42 @@
return stream->str();
}
-
+MessageBuffer::MessageBuffer()
#if LOG4CXX_HAS_WCHAR_T
-MessageBuffer::MessageBuffer() {
- wbuf = 0;
+ : wbuf(0)
+#endif
+{
}
MessageBuffer::~MessageBuffer() {
+#if LOG4CXX_HAS_WCHAR_T
delete wbuf;
+#endif
+}
+
+
+CharMessageBuffer& MessageBuffer::operator<<(const std::string& msg) {
+ return CharMessageBuffer::operator<<(msg);
+}
+
+CharMessageBuffer& MessageBuffer::operator<<(const char* msg) {
+ return CharMessageBuffer::operator<<(msg);
+}
+
+CharMessageBuffer& MessageBuffer::operator<<(const char msg) {
+ return CharMessageBuffer::operator<<(msg);
+}
+
+const std::string& MessageBuffer::str(const CharMessageBuffer& msg) const {
+ return CharMessageBuffer::str(msg);
+}
+
+std::string MessageBuffer::str(const std::ostream& msg) const {
+ return CharMessageBuffer::str(msg);
}
-
+
+
+#if LOG4CXX_HAS_WCHAR_T
WideMessageBuffer& MessageBuffer::operator<<(const std::wstring& msg) {
wbuf = new WideMessageBuffer(msg);
return *wbuf;
@@ -131,25 +157,6 @@
return *this;
}
-CharMessageBuffer& MessageBuffer::operator<<(const std::string& msg) {
- return CharMessageBuffer::operator<<(msg);
-}
-
-CharMessageBuffer& MessageBuffer::operator<<(const char* msg) {
- return CharMessageBuffer::operator<<(msg);
-}
-
-CharMessageBuffer& MessageBuffer::operator<<(const char msg) {
- return CharMessageBuffer::operator<<(msg);
-}
-
-const std::string& MessageBuffer::str(const CharMessageBuffer& msg) const {
- return CharMessageBuffer::str(msg);
-}
-
-std::string MessageBuffer::str(const std::ostream& msg) const {
- return CharMessageBuffer::str(msg);
-}
#endif
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h?rev=579315&r1=579314&r2=579315&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
(original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h Tue
Sep 25 09:58:52 2007
@@ -26,46 +26,155 @@
namespace log4cxx {
namespace helpers {
+ /**
+ * This class is used by the LOG4CXX_INFO and similar
+ * macros to support insertion operators in the message parameter.
+ * The class is not intended for use outside of that context.
+ */
class LOG4CXX_EXPORT CharMessageBuffer {
public:
+ /**
+ * Creates a new instance.
+ */
CharMessageBuffer();
+ /**
+ * Destructor.
+ */
~CharMessageBuffer();
+ /**
+ * Appends string to buffer.
+ * @param msg string append.
+ * @return this buffer.
+ */
CharMessageBuffer& operator<<(const std::string& msg);
+ /**
+ * Appends string to buffer.
+ * @param msg string to append.
+ * @return this buffer.
+ */
CharMessageBuffer& operator<<(const char* msg);
+ /**
+ * Appends character to buffer.
+ * @param msg character to append.
+ * @return this buffer.
+ */
CharMessageBuffer& operator<<(const char msg);
+ /**
+ * This template allows any other insertion
+ * operator to operate on an encapsulated std::ostringstream
+ * created on demand.
+ * @param arg instance to append.
+ * @return reference to encapsulated std::ostringstream.
+ */
template<class T>
std::ostream& operator<<(T arg) {
stream = new std::ostringstream();
return *stream << buf << arg;
}
- const std::string& str(const CharMessageBuffer&) const;
- std::string str(const std::ostream&) const;
+ /**
+ * Gets the content of the encapsulated std::string.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::string or the encapsulated std::ostringstream.
+ * @return reference to encapsulated std::stream.
+ */
+ const std::string& str(const CharMessageBuffer& expression) const;
+ /**
+ * Gets the content of the encapsulated std::ostringstream.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::string or the encapsulated std::ostringstream.
+ * @return content of encapsulated std::ostringstream.
+ */
+ std::string str(const std::ostream& expression) const;
private:
+ /**
+ * Encapsulated std::string.
+ */
std::string buf;
+ /**
+ * Encapsulated stream, created on demand.
+ */
std::ostringstream* stream;
};
#if LOG4CXX_HAS_WCHAR_T
+ /**
+ * This class is used by the LOG4CXX_INFO and similar
+ * macros to support insertion operators in the message parameter.
+ * The class is not intended for use outside of that context.
+ */
class LOG4CXX_EXPORT WideMessageBuffer {
public:
- WideMessageBuffer(const wchar_t);
- WideMessageBuffer(const wchar_t*);
- WideMessageBuffer(const std::wstring&);
+ /**
+ * Creates a new instance.
+ * @param msg initial content of buffer.
+ */
+ WideMessageBuffer(const wchar_t msg);
+ /**
+ * Creates a new instance.
+ * @param msg initial content of buffer.
+ */
+ WideMessageBuffer(const wchar_t* msg);
+ /**
+ * Creates a new instance.
+ * @param msg initial content of buffer.
+ */
+ WideMessageBuffer(const std::wstring& msg);
+ /**
+ * Destructor.
+ */
~WideMessageBuffer();
+ /**
+ * Gets the content of the encapsulated std::wstring.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::wstring or the encapsulated std::wostringstream.
+ * @return reference to encapsulated std::wstream.
+ */
const std::wstring& str(const WideMessageBuffer&) const;
+ /**
+ * Gets the content of the encapsulated std::wostringstream.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::wstring or the encapsulated std::wostringstream.
+ * @return content of encapsulated std::wostringstream.
+ */
std::wstring str(const std::wostream&) const;
+ /**
+ * Appends character to buffer.
+ * @param msg character to append.
+ * @return this buffer.
+ */
WideMessageBuffer& operator<<(const std::wstring& msg);
+ /**
+ * Appends character to buffer.
+ * @param msg character to append.
+ * @return this buffer.
+ */
WideMessageBuffer& operator<<(const wchar_t* msg);
+ /**
+ * Appends character to buffer.
+ * @param msg character to append.
+ * @return this buffer.
+ */
WideMessageBuffer& operator<<(const wchar_t msg);
+ /**
+ * This template allows any other insertion
+ * operator to operate on an encapsulated std::wostringstream
+ * created on demand.
+ * @param arg instance to append.
+ * @return reference to encapsulated std::wostringstream.
+ */
template<class T>
std::wostream& operator<<(T arg) {
stream = new std::wostringstream();
@@ -73,42 +182,132 @@
}
private:
- std::wstring buf;
+ /**
+ * Encapsulated std::wstring.
+ */
+ std::wstring buf;
+ /**
+ * Encapsulated stream, created on demand.
+ */
std::wostringstream* stream;
};
+#endif
+ /**
+ * This class is used by the LOG4CXX_INFO and similar
+ * macros to support insertion operators in the message parameter.
+ * The class is not intended for use outside of that context.
+ */
class LOG4CXX_EXPORT MessageBuffer : public CharMessageBuffer {
public:
+ /**
+ * Creates a new instance.
+ */
MessageBuffer();
+ /**
+ * Destructor.
+ */
~MessageBuffer();
-
- WideMessageBuffer& operator<<(const std::wstring& msg);
- WideMessageBuffer& operator<<(const wchar_t* msg);
- WideMessageBuffer& operator<<(const wchar_t msg);
+ /**
+ * 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 std::string& msg);
+ /**
+ * 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 char* msg);
+ /**
+ * 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 char msg);
-
- const std::wstring& str(const WideMessageBuffer&) const;
- std::wstring str(const std::wostream&) const;
+
+ /**
+ * Gets the content of the encapsulated std::string.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::string or the encapsulated std::ostringstream.
+ * @return reference to encapsulated std::stream.
+ */
const std::string& str(const CharMessageBuffer&) const;
+ /**
+ * Gets the content of the encapsulated std::ostringstream.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::string or the encapsulated std::ostringstream.
+ * @return content of encapsulated std::ostringstream.
+ */
std::string str(const std::ostream&) const;
+ /**
+ * This template allows any other insertion
+ * operator to operate on an encapsulated std::ostringstream
+ * created on demand and fixes the buffer to use char characters.
+ * @param arg instance to append.
+ * @return reference to encapsulated std::ostringstream.
+ */
template<class T>
std::ostream& operator<<(T arg) {
return CharMessageBuffer::operator<<(arg);
}
+
+
+#if LOG4CXX_HAS_WCHAR_T
+ /**
+ * Appends a wide string into the buffer and
+ * fixes the buffer to use wchar_t characters.
+ * @param msg message to append.
+ * @return encapsulated WideMessageBuffer.
+ */
+ WideMessageBuffer& operator<<(const std::wstring& msg);
+ /**
+ * Appends a wide string into the buffer and
+ * fixes the buffer to use wchar_t characters.
+ * @param msg message to append.
+ * @return encapsulated WideMessageBuffer.
+ */
+ WideMessageBuffer& operator<<(const wchar_t* msg);
+ /**
+ * Appends a wide character into the buffer and
+ * fixes the buffer to use wchar_t characters.
+ * @param msg message to append.
+ * @return encapsulated WideMessageBuffer.
+ */
+ WideMessageBuffer& operator<<(const wchar_t msg);
-
-
+ /**
+ * Gets the content of the encapsulated std::wstring.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::wstring or the encapsulated std::wostringstream.
+ * @return reference to encapsulated std::wstream.
+ */
+ const std::wstring& str(const WideMessageBuffer&) const;
+ /**
+ * Gets the content of the encapsulated std::wostringstream.
+ * @param expression insertion expression whose type is used to
+ * determine whether to return the content of the encapsulated
+ * std::wstring or the encapsulated std::wostringstream.
+ * @return content of encapsulated std::wostringstream.
+ */
+ std::wstring str(const std::wostream&) const;
private:
+ /**
+ * Encapsulated wide message buffer, created on demand.
+ */
WideMessageBuffer* wbuf;
- };
-#else
-typedef class CharMessageBuffer MessageBuffer;
#endif
+ };
}
}