WSF
UtCsv.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef UTCSV_HPP
16#define UTCSV_HPP
17#include <iosfwd>
18#include <string>
19#include <vector>
20
21#include "WsfUtExport.hpp"
22
23// Comma Separated Value file utilities
24namespace UtCsv
25{
26typedef std::vector<std::string> StringList;
34
37{
38public:
40 : mAtEof(false)
41 {
42 }
43 ParseResult ReadToken(std::istream& aStream, std::string& aFieldValue);
44
45 ParseResult ReadRow(std::istream& aStream, StringList& aRowValues);
46
47private:
48 bool mAtEof;
49};
50
51WSF_UT_EXPORT void Escape(std::string& aText);
52WSF_UT_EXPORT std::vector<StringList> ToStrings(std::istream& aCsvStream);
53WSF_UT_EXPORT std::string FromStrings(const std::vector<StringList>& aRows);
54WSF_UT_EXPORT std::string RowFromStrings(const StringList& aRows);
55
56} // namespace UtCsv
57
58#endif
#define WSF_UT_EXPORT
Definition WsfUtExport.hpp:32
Parser()
Definition UtCsv.hpp:39
Definition UtCsv.hpp:25
WSF_UT_EXPORT std::string RowFromStrings(const StringList &aRows)
Definition UtCsv.cpp:261
ParseResult
Definition UtCsv.hpp:28
@ cCSV_ERROR
Definition UtCsv.hpp:32
@ cCSV_NEW_ROW
Definition UtCsv.hpp:30
@ cCSV_FIELD
Definition UtCsv.hpp:29
@ cCSV_EOF
Definition UtCsv.hpp:31
std::vector< std::string > StringList
Definition UtCsv.hpp:26
WSF_UT_EXPORT void Escape(std::string &aText)
Definition UtCsv.cpp:177
WSF_UT_EXPORT std::string FromStrings(const std::vector< StringList > &aRows)
Create CSV text given an array of array of strings.
Definition UtCsv.cpp:233
WSF_UT_EXPORT std::vector< StringList > ToStrings(std::istream &aCsvStream)
Parse a CSV text stream into an array of array of strings representing the rows of cells.
Definition UtCsv.cpp:198
Copyrights Multiple, All Rights Reserved