chxavcleanstring.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:3k
- /************************************************************************
- * chxavcleanstring.h
- * ------------------
- *
- * Synopsis:
- * For on-the-fly conversion to a descriptor (from const char* or resource).
- * Cleanup is handled automatically.
- *
- * Target:
- * Symbian OS
- *
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *****************************************************************************/
- #ifndef _chxavcleanstring_h_
- #define _chxavcleanstring_h_
- // Symbian includes...
- #include <aknpopup.h>
- #include <akntitle.h>
- #include <eikenv.h>
- #include <coemain.h>
- // Helix includes...
- #include "hxassert.h"
- // Include from this project...
- #include "chxavstringutils.h"
- // class CHXAvCleanString
- class CHXAvCleanString
- {
- public:
- explicit CHXAvCleanString(TInt resId)
- {
- m_pText = CEikonEnv::Static()->AllocReadResourceLC(resId);
- }
- explicit CHXAvCleanString(const CHXString& str)
- {
- m_pText = CHXAvStringUtils::AllocTextL(str);
- CleanupStack::PushL(m_pText);
- }
- // format with int (%d) argument
- CHXAvCleanString(TInt resId, TInt arg)
- {
- m_pText = CHXAvStringUtils::AllocResFormatTextL(resId, arg);
- CleanupStack::PushL(m_pText);
- }
- // format with float (%f) argument
- CHXAvCleanString(TInt resId, double arg)
- {
- m_pText = CHXAvStringUtils::AllocResFormatTextL(resId, arg);
- CleanupStack::PushL(m_pText);
- }
- // format with string descriptor (%S) argument
- CHXAvCleanString(TInt resId, const TDesC& desc)
- {
- m_pText = CHXAvStringUtils::AllocResFormatTextL(resId, desc);
- CleanupStack::PushL(m_pText);
- }
- // format; int %d argument
- CHXAvCleanString(const TDesC& formatString, TInt arg)
- {
- m_pText = CHXAvStringUtils::AllocFormatTextL(formatString, arg);
- CleanupStack::PushL(m_pText);
- }
-
- // explicit conversions are safer; funny semantic aids ease-of-use
- // operator const TDesC&() const { return *m_pText; }
- // operator TDesC&() { return *m_pText; }
- HBufC* operator&() { return m_pText; }
- TDesC& operator()() { return *m_pText; }
- const HBufC* operator&() const { return m_pText; }
- const TDesC& operator()() const { return *m_pText; }
- ~CHXAvCleanString(){ CleanupStack::PopAndDestroy(); }
- private:
- // automatic instanciation only, no funny stuff
- void * operator new(size_t);
- CHXAvCleanString& operator=(const CHXAvCleanString&);
- CHXAvCleanString(const CHXAvCleanString&);
- HBufC* m_pText;
- };
- #endif //_chxavcleanstring_h_