Ejemplo n.º 1
0
void ON_TextLog::Print( const wchar_t* wformat, ... )
{
  // format message and append it to the log
  const int MAX_MSG_LENGTH = 2047;
  wchar_t s[MAX_MSG_LENGTH+1];
  va_list args;

  s[0] = 0;
  if (wformat) 
  {
    va_start(args, wformat);
    on_vsnwprintf( s, MAX_MSG_LENGTH-1, wformat, args);
    va_end(args);
    s[MAX_MSG_LENGTH] = 0;
  }
  if ( *s ) 
  {
    wchar_t* s0 = s;
    wchar_t* s1 = s;
    for ( s1 = s0; *s1; s1++) {
      if ( *s1 == '\n' ) {
        *s1 = 0;
        if ( m_beginning_of_line && m_indent && m_indent[0] )
          AppendText( m_indent );
        if (*s0) 
          AppendText(s0);
        AppendText("\n");
        m_beginning_of_line = 1;
        s0 = s1+1;
      }
    }
    if (*s0) {
      if ( m_beginning_of_line && m_indent && m_indent[0] )
        AppendText( m_indent );
      AppendText(s0);
      m_beginning_of_line = 0;
    }
  }
}
Ejemplo n.º 2
0
void ON_MSC_CDECL ON_wString::Format( const wchar_t* sFormat, ...)
{
#define MAX_MSG_LENGTH 2048
  wchar_t sMessage[MAX_MSG_LENGTH];
  va_list args;

  /* put formatted message in sMessage */
  memset(sMessage,0,sizeof(sMessage));
  if (sFormat) {
    va_start(args, sFormat);
    on_vsnwprintf(sMessage, MAX_MSG_LENGTH-1, sFormat, args);
    sMessage[MAX_MSG_LENGTH-1] = 0;
    va_end(args);
  }
  const int len = Length(sMessage);
  if ( len < 1 ) {
    Destroy();
    Create();
  }
  else {
    ReserveArray( len );
    CopyToArray( len, sMessage );
  }
}