-#ifdef wxNEED_PRINTF_CONVERSION
-
-// ----------------------------------------------------------------------------
-// wxFormatConverter: class doing the "%s" -> "%ls" conversion
-// ----------------------------------------------------------------------------
-
-/*
- Here are the gory details. We want to follow the Windows/MS conventions,
- that is to have
-
- In ANSI mode:
-
- format specifier results in
- -----------------------------------
- %c, %hc, %hC char
- %lc, %C, %lC wchar_t
-
- In Unicode mode:
-
- format specifier results in
- -----------------------------------
- %hc, %C, %hC char
- %c, %lc, %lC wchar_t
-
-
- while on POSIX systems we have %C identical to %lc and %c always means char
- (in any mode) while %lc always means wchar_t,
-
- So to use native functions in order to get our semantics we must do the
- following translations in Unicode mode (nothing to do in ANSI mode):
-
- wxWidgets specifier POSIX specifier
- ----------------------------------------
-
- %hc, %C, %hC %c
- %c %lc
-
-
- And, of course, the same should be done for %s as well.
-*/
-
-class wxFormatConverter
-{
-public:
- wxFormatConverter(const wchar_t *format);
-
- // notice that we only translated the string if m_fmtOrig == NULL (as set
- // by CopyAllBefore()), otherwise we should simply use the original format
- operator const wchar_t *() const
- { return m_fmtOrig ? m_fmtOrig : m_fmt.c_str(); }
-
-private:
- // copy another character to the translated format: this function does the
- // copy if we are translating but doesn't do anything at all if we don't,
- // so we don't create the translated format string at all unless we really
- // need to (i.e. InsertFmtChar() is called)
- wchar_t CopyFmtChar(wchar_t ch)
- {
- if ( !m_fmtOrig )
- {
- // we're translating, do copy
- m_fmt += ch;
- }
- else
- {
- // simply increase the count which should be copied by
- // CopyAllBefore() later if needed
- m_nCopied++;
- }
-
- return ch;
- }
-
- // insert an extra character
- void InsertFmtChar(wchar_t ch)
- {
- if ( m_fmtOrig )
- {
- // so far we haven't translated anything yet
- CopyAllBefore();
- }
-
- m_fmt += ch;
- }
-
- void CopyAllBefore()
- {
- wxASSERT_MSG( m_fmtOrig && m_fmt.empty(), _T("logic error") );
-
- m_fmt = wxString(m_fmtOrig, m_nCopied);
-
- // we won't need it any longer
- m_fmtOrig = NULL;
- }
-
- static bool IsFlagChar(wchar_t ch)
- {
- return ch == _T('-') || ch == _T('+') ||
- ch == _T('0') || ch == _T(' ') || ch == _T('#');
- }
-
- void SkipDigits(const wchar_t **ptpc)
- {
- while ( **ptpc >= _T('0') && **ptpc <= _T('9') )
- CopyFmtChar(*(*ptpc)++);
- }
-
- // the translated format
- wxString m_fmt;
-
- // the original format
- const wchar_t *m_fmtOrig;
-
- // the number of characters already copied
- size_t m_nCopied;
-};
-
-wxFormatConverter::wxFormatConverter(const wchar_t *format)