Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
CsvParser.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/Array.h"
7#include "Containers/UnrealString.h"
8
9/** A simple, efficient csv parser */
11{
12 typedef TArray<TArray<const TCHAR*>> FRows;
13
14 /**
15 * Construct with a string.
16 * Takes a copy because the parser tramples over the file to create null-terminated cell strings
17 * Avoid a copy by passing overship of the source string with MoveTemp()
18 */
19 FCsvParser(FString InSourceString);
20
21 /**
22 * Const access to the parsed rows
23 * Rows are stored as arrays of parsed, null-terminated cell-strings.
24 * Object (and contained strings) is valid for the lifetime of the parser.
25 */
26 const FRows& GetRows() const
27 {
28 return Rows;
29 }
30
31private:
32 /** Non copyable - has pointers to itself */
35
36 /** Internal enum to control parsing progress */
38
39 /** Parse all the rows in the source data */
40 void ParseRows();
41
42 /** Parse a single row at the current read position */
44
45 /** Parse a cell at the current read position */
47
48private:
49
50 /** Raw csv buffer, sliced and diced by the parser */
52
53 /** Fixed pointer to the start of the buffer */
55
56 /** Current parser read position */
57 const TCHAR* ReadAt;
58
59 /** Array of cell string arrays */
61
62private:
63
64 /** Helper to measure the size of a new line at the current read position */
65 int8 MeasureNewLine(const TCHAR* At);
66};
int8 MeasureNewLine(const TCHAR *At)
EParseResult ParseCell()
const TCHAR * ReadAt
Definition CsvParser.h:57
FCsvParser(FString InSourceString)
TArray< TArray< const TCHAR * > > FRows
Definition CsvParser.h:12
FString SourceString
Definition CsvParser.h:51
const FRows & GetRows() const
Definition CsvParser.h:26
FRows Rows
Definition CsvParser.h:60
TCHAR * BufferStart
Definition CsvParser.h:54
EParseResult ParseRow()
void ParseRows()
FCsvParser & operator=(const FCsvParser &)
FCsvParser(const FCsvParser &)