KiCad PCB EDA Suite
Loading...
Searching...
No Matches
csv.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * https://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <wx/string.h>
27#include <wx/stream.h>
28
29#include <istream>
30
31
33{
34public:
35 CSV_WRITER( wxOutputStream& aStream );
36
40 void WriteLine( const std::vector<wxString>& aCols );
46 void WriteLines( const std::vector<std::vector<wxString>>& aRows );
47
48 void SetDelimiter( const wxString& aDelimiter )
49 {
50 m_delimiter = aDelimiter;
51 }
52
57 void SetEscape( const wxString& aEscape )
58 {
59 m_escape = aEscape;
60 }
61
62private:
63 wxOutputStream& m_stream;
64 wxString m_delimiter;
65 wxString m_quote;
67 wxString m_escape;
68};
69
70
78bool AutoDecodeCSV( const wxString& aInput, std::vector<std::vector<wxString>>& aData );
Definition: csv.h:33
void SetEscape(const wxString &aEscape)
Set the delimiter escape char.
Definition: csv.h:57
void WriteLines(const std::vector< std::vector< wxString > > &aRows)
Write a vector of rows to the stream.
Definition: csv.cpp:18
wxString m_quote
Definition: csv.h:65
void WriteLine(const std::vector< wxString > &aCols)
Write a single row to the stream.
Definition: csv.cpp:27
wxString m_delimiter
Definition: csv.h:64
wxOutputStream & m_stream
Definition: csv.h:63
void SetDelimiter(const wxString &aDelimiter)
Definition: csv.h:48
wxString m_lineTerminator
Definition: csv.h:66
wxString m_escape
Definition: csv.h:67
bool AutoDecodeCSV(const wxString &aInput, std::vector< std::vector< wxString > > &aData)
Try to guess the format of a T/CSV file and decode it into aData.
Definition: csv.cpp:66