static void pgNoticeProcessor(void *arg, const char *message) { wxString str(message, wxConvUTF8); wxLogNotice(wxT("%s"), str.Trim().c_str()); ((pgQueryThread *)arg)->appendMessage(str); }
wxString CSVTokenizer::GetNextToken() { wxString token; if ( !HasMoreTokens() ) return token; // skip leading blanks if not quoted. while (m_pos < m_string.length() && m_string[m_pos] == wxT(' ')) m_pos ++; // Are we a quoted field? Must handle this special. bool quoted_string = (m_string[m_pos] == wxT('\"')); bool inquote = false; size_t pos = m_pos; // find the end of this token. for (; pos < m_string.length(); pos++) { if (quoted_string && m_string[pos] == wxT('\"')) inquote = !inquote; if (!inquote) { // Check to see if we have found the end of this token. // Tokens normally end with a ',' delimiter. if (m_string[pos] == wxT(',')) break; // Last token is delimited by '\n' or by end of string. if (m_string[pos] == wxT('\n') && pos == m_string.length() - 1) break; } } if (quoted_string && !inquote) { token.assign(m_string, m_pos + 1, pos - m_pos - 2); // Remove leading and trailing quotes // Remove double doublequote chars, replace with single doublequote chars token.Replace(wxT("\"\""), wxT("\""), true); } else token.assign(m_string, m_pos, pos - m_pos); if (quoted_string && inquote) { wxLogNotice(wxT("unterminated double quoted string: %s\n"), token.c_str()); } m_pos = pos + 1; // Skip token and delimiter if (m_pos > m_string.length()) // Perhaps no delimiter if at end of string if orig string didn't have '\n'. m_pos = m_string.length(); return token; }
// default notice processor for the pgQueryThread // we do assume that the argument passed will be always the // object of pgQueryThread void pgNoticeProcessor(void *_arg, const char *_message) { wxString str(_message, wxConvUTF8); wxLogNotice(wxT("%s"), str.Trim().c_str()); if (_arg) { ((pgQueryThread *)_arg)->AppendMessage(str); } }
void pgConn::Notice(const char *msg) { if (noticeArg && noticeProc) (*noticeProc)(noticeArg, msg); else { wxString str(msg, *conv); // Display the notice if required if (settings->GetShowNotices()) wxMessageBox(str, _("Notice"), wxICON_INFORMATION | wxOK); wxLogNotice(wxT("%s"), str.Trim().c_str()); } }