📄 messagebuffer.h
字号:
* @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(ios_base_manip manip); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(bool val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(short val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(int val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(unsigned int val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(long val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(unsigned long val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(float val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(double val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(long double val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::basic_ostream<wchar_t>& operator<<(void* val); /** * Cast to ostream. */ operator std::basic_ostream<wchar_t>&(); /** * Get content of buffer. * @param os used only to signal that * the embedded stream was used. */ const std::basic_string<wchar_t>& str(std::basic_ostream<wchar_t>& os); /** * Get content of buffer. * @param buf used only to signal that * the embedded stream was not used. */ const std::basic_string<wchar_t>& str(WideMessageBuffer& buf); /** * Returns true if buffer has an encapsulated STL stream. * @return true if STL stream was created. */ bool hasStream() const; private: /** * Prevent use of default copy constructor. */ WideMessageBuffer(const WideMessageBuffer&); /** * Prevent use of default assignment operator. */ WideMessageBuffer& operator=(const WideMessageBuffer&); /** * Encapsulated std::string. */ std::basic_string<wchar_t> buf; /** * Encapsulated stream, created on demand. */ std::basic_ostringstream<wchar_t>* stream; };template<class V>std::basic_ostream<wchar_t>& operator<<(WideMessageBuffer& os, const V& val) { return ((std::basic_ostream<wchar_t>&) os) << val;} /** * 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: /** * Creates a new instance. */ MessageBuffer(); /** * Destructor. */ ~MessageBuffer(); /** * Cast to ostream. */ operator std::ostream&(); /** * 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<<(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); /** * Get content of buffer. * @param buf used only to signal * the character type and that * the embedded stream was not used. */ const std::string& str(CharMessageBuffer& buf); /** * Get content of buffer. * @param os used only to signal * the character type and that * the embedded stream was used. */ const std::string& str(std::ostream& os); /** * Appends a string into the buffer and * fixes the buffer to use char characters. * @param msg message to append. * @return encapsulated CharMessageBuffer. */ WideMessageBuffer& operator<<(const std::wstring& msg); /** * Appends a string into the buffer and * fixes the buffer to use char characters. * @param msg message to append. * @return encapsulated CharMessageBuffer. */ 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. */ WideMessageBuffer& operator<<(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. */ WideMessageBuffer& operator<<(const wchar_t msg);#if LOG4CXX_UNICHAR_API || 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. */ UniCharMessageBuffer& operator<<(const std::basic_string<UniChar>& msg); /** * Appends a string into the buffer and * fixes the buffer to use char characters. * @param msg message to append. * @return encapsulated CharMessageBuffer. */ UniCharMessageBuffer& operator<<(const UniChar* msg); /** * Appends a string into the buffer and * fixes the buffer to use char characters. * @param msg message to append. * @return encapsulated CharMessageBuffer. */ UniCharMessageBuffer& operator<<(UniChar* msg); /** * Appends a string into the buffer and * fixes the buffer to use char characters. * @param msg message to append. * @return encapsulated CharMessageBuffer. */ UniCharMessageBuffer& operator<<(const UniChar msg);#endif#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. */ UniCharMessageBuffer& operator<<(const CFStringRef& msg);#endif /** * Insertion operator for STL manipulators such as std::fixed. * @param manip manipulator. * @return encapsulated STL stream. */ std::ostream& operator<<(ios_base_manip manip); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(bool val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(short val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(int val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(unsigned int val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(long val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(unsigned long val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(float val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(double val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(long double val); /** * Insertion operator for built-in type. * @param val build in type. * @return encapsulated STL stream. */ std::ostream& operator<<(void* val); /** * Get content of buffer. * @param buf used only to signal * the character type and that * the embedded stream was not used. */ const std::wstring& str(WideMessageBuffer& buf); /** * Get content of buffer. * @param os used only to signal * the character type and that * the embedded stream was used. */ const std::wstring& str(std::basic_ostream<wchar_t>& os); #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API /** * Get content of buffer. * @param buf used only to signal * the character type and that * the embedded stream was not used. */ const std::basic_string<UniChar>& str(UniCharMessageBuffer& buf); /** * Get content of buffer. * @param os used only to signal * the character type and that * the embedded stream was used. */ const std::basic_string<UniChar>& str(UniCharMessageBuffer::uostream& os);#endif /** * Returns true if buffer has an encapsulated STL stream. * @return true if STL stream was created. */ bool hasStream() const; private: /** * Prevent use of default copy constructor. */ MessageBuffer(const MessageBuffer&); /** * Prevent use of default assignment operator. */ MessageBuffer& operator=(const MessageBuffer&); /** * Character message buffer. */ CharMessageBuffer cbuf; /** * Encapsulated wide message buffer, created on demand. */ WideMessageBuffer* wbuf; #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API /** * Encapsulated wide message buffer, created on demand. */ UniCharMessageBuffer* ubuf; #endif };template<class V>std::ostream& operator<<(MessageBuffer& os, const V& val) { return ((std::ostream&) os) << val;}#if LOG4CXX_LOGCHAR_IS_UTF8typedef CharMessageBuffer LogCharMessageBuffer;#endif#if LOG4CXX_LOGCHAR_IS_WCHARtypedef WideMessageBuffer LogCharMessageBuffer;#endif#if LOG4CXX_LOGCHAR_IS_UNICHARtypedef UniCharMessageBuffer LogCharMessageBuffer;#endif#elsetypedef CharMessageBuffer MessageBuffer;typedef CharMessageBuffer LogCharMessageBuffer;#endif}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -