📄 warutf8.h
字号:
/** */#ifndef WAR_UTF8_H#define WAR_UTF8_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_TYPES_H# include "WarTypes.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplus/** Conversion between Unicode and UTF */class WarUtf8 {public: // LIFECYCLE /** * Default constructor. */ WarUtf8(void) {} /** * Copy constructor. * * @param from The value to copy to this object. */ WarUtf8(const WarUtf8& from) : mUtf8Encoded(from.mUtf8Encoded), mUnicode(from.mUnicode) {} WarUtf8(war_ccstr_t from) { ToUnicode(from); } WarUtf8(war_cwstr_t from) { ToUtf8(from); } WarUtf8(const std::string& from) { ToUnicode(from.c_str()); } WarUtf8(const std::wstring& from) { ToUtf8(from.c_str()); } /** * Destructor. */ ~WarUtf8(void) {} // OPERATORS operator const std::wstring& () { return mUnicode; } operator const std::string& () { return mUtf8Encoded; } static bool IsUtf8(const war_ccstr_t from); static bool IsUtf8(const std::string& from); /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarUtf8& operator=(WarUtf8& from); // OPERATIONS // ACCESS const std::wstring& GetUnicode() const { return mUnicode; } const std::string& GetUtf8() const { return mUtf8Encoded; } const std::basic_string<war_sysch_t>& GetSysStr() const {#ifdef UNICODE return mUnicode;#else return mUtf8Encoded;#endif } // INQUIRY bool IsEmpty() const { return mUtf8Encoded.empty(); } protected:private: void ToUnicode(const war_ccstr_t from); void ToUtf8(const war_cwstr_t from); std::string mUtf8Encoded; std::wstring mUnicode;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_UTF8_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -