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, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <wx/string.h>
23#include <wx/stream.h>
24
25#include <istream>
26
27
29{
30public:
31 CSV_WRITER( wxOutputStream& aStream );
32
36 void WriteLine( const std::vector<wxString>& aCols );
42 void WriteLines( const std::vector<std::vector<wxString>>& aRows );
43
44 void SetDelimiter( const wxString& aDelimiter )
45 {
46 m_delimiter = aDelimiter;
47 }
48
53 void SetEscape( const wxString& aEscape )
54 {
55 m_escape = aEscape;
56 }
57
58private:
59 wxOutputStream& m_stream;
60 wxString m_delimiter;
61 wxString m_quote;
63 wxString m_escape;
64};
65
66
74bool AutoDecodeCSV( const wxString& aInput, std::vector<std::vector<wxString>>& aData );
void SetEscape(const wxString &aEscape)
Set the delimiter escape char.
Definition csv.h:53
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:61
void WriteLine(const std::vector< wxString > &aCols)
Write a single row to the stream.
Definition csv.cpp:27
wxString m_delimiter
Definition csv.h:60
wxOutputStream & m_stream
Definition csv.h:59
CSV_WRITER(wxOutputStream &aStream)
Definition csv.cpp:10
void SetDelimiter(const wxString &aDelimiter)
Definition csv.h:44
wxString m_lineTerminator
Definition csv.h:62
wxString m_escape
Definition csv.h:63
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