示例#1
0
void writeUTF8(wxTextOutputStream& stream, const String& str) {
#ifdef UNICODE
    stream.WriteString(str);
#else
    wxWCharBuffer buf = str.wc_str(*wxConvCurrent);
    stream.WriteString(wxString(buf, wxConvUTF8));
#endif
}
void t4p::SqlCopyOptionsClass::EndRow(wxTextOutputStream& stream) {
    wxString trueRowDelim;
    if (RowDelim == wxT("\\t")) {
        trueRowDelim = wxT("\t");
    } else if (RowDelim == wxT("\\n")) {
        trueRowDelim = wxT("\n");
    } else if (RowDelim == wxT("\\f")) {
        trueRowDelim = wxT("\f");
    } else {
        trueRowDelim = RowDelim;
    }
    stream.WriteString(trueRowDelim);
}
void t4p::SqlCopyOptionsClass::Export(std::vector<wxString> values, wxTextOutputStream& stream) {
    wxString trueColumnDelim;
    if (ColumnDelim == wxT("\\t")) {
        trueColumnDelim = wxT("\t");
    } else if (ColumnDelim == wxT("\\n")) {
        trueColumnDelim = wxT("\n");
    } else if (ColumnDelim == wxT("\\f")) {
        trueColumnDelim = wxT("\f");
    } else {
        trueColumnDelim = ColumnDelim;
    }


    size_t size = values.size();
    for (size_t i = 0; i < size; ++i) {
        wxString val = values[i];

        stream.WriteString(ColumnEnclosure);

        // write the cell value
        if (val == wxT("<NULL>")) {
            stream.WriteString(NullFiller);
        } else {
            for (size_t j = 0; j < val.length(); ++j) {
                if (val[j] == ColumnEnclosure) {
                    stream.PutChar(wxT('\\'));
                    stream.WriteString(ColumnEnclosure);
                } else {
                    stream.PutChar(val[j]);
                }
            }
        }
        stream.WriteString(ColumnEnclosure);

        if (i < (size - 1)) {
            stream.WriteString(trueColumnDelim);
        }
    }
}