VTK  9.6.1
vtkDelimitedTextReader.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4
49
50#ifndef vtkDelimitedTextReader_h
51#define vtkDelimitedTextReader_h
52
53#include "vtkIOInfovisModule.h" // For export macro
54#include "vtkStdString.h" // Needed for vtkStdString
55#include "vtkTableAlgorithm.h"
56
57#include <memory>
58#include <string>
59
60VTK_ABI_NAMESPACE_BEGIN
61
62class vtkTextCodec;
63
64class VTKIOINFOVIS_EXPORT vtkDelimitedTextReader : public vtkTableAlgorithm
65{
66public:
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
72
78
80
86 void SetInputString(const char* in);
87 vtkGetStringMacro(InputString);
88 void SetInputString(const char* in, int len);
89 vtkGetMacro(InputStringLength, int);
90 void SetInputString(const vtkStdString& input)
91 {
92 this->SetInputString(input.c_str(), static_cast<int>(input.length()));
93 }
94
95
97
105
107
118 vtkGetStringMacro(UnicodeCharacterSet);
119 vtkSetStringMacro(UnicodeCharacterSet);
121
123
128 void SetUTF8RecordDelimiters(const char* delimiters);
131
133
140 vtkSetStringMacro(FieldDelimiterCharacters);
141 vtkGetStringMacro(FieldDelimiterCharacters);
143
144 void SetUTF8FieldDelimiters(const char* delimiters);
146
148
157 vtkGetMacro(StringDelimiter, char);
158 vtkSetMacro(StringDelimiter, char);
160
161 void SetUTF8StringDelimiters(const char* delimiters);
163
165
168 vtkSetMacro(UseStringDelimiter, bool);
169 vtkGetMacro(UseStringDelimiter, bool);
170 vtkBooleanMacro(UseStringDelimiter, bool);
172
174
178 vtkGetMacro(HaveHeaders, bool);
179 vtkSetMacro(HaveHeaders, bool);
181
183
188 vtkSetMacro(MergeConsecutiveDelimiters, bool);
189 vtkGetMacro(MergeConsecutiveDelimiters, bool);
190 vtkBooleanMacro(MergeConsecutiveDelimiters, bool);
192
194
199 vtkGetMacro(MaxRecords, vtkIdType);
200 vtkSetMacro(MaxRecords, vtkIdType);
202
204
211
213
222 vtkSetMacro(DetectNumericColumns, bool);
223 vtkGetMacro(DetectNumericColumns, bool);
224 vtkBooleanMacro(DetectNumericColumns, bool);
226
228
233 vtkSetMacro(ForceDouble, bool);
234 vtkGetMacro(ForceDouble, bool);
235 vtkBooleanMacro(ForceDouble, bool);
237
239
258
260
264 vtkSetMacro(DefaultIntegerValue, int);
265 vtkGetMacro(DefaultIntegerValue, int);
267
269
273 vtkSetMacro(DefaultDoubleValue, double);
274 vtkGetMacro(DefaultDoubleValue, double);
276
278
282 vtkSetStringMacro(PedigreeIdArrayName);
283 vtkGetStringMacro(PedigreeIdArrayName);
285
287
291 vtkSetMacro(GeneratePedigreeIds, bool);
292 vtkGetMacro(GeneratePedigreeIds, bool);
293 vtkBooleanMacro(GeneratePedigreeIds, bool);
295
297
300 vtkSetMacro(OutputPedigreeIds, bool);
301 vtkGetMacro(OutputPedigreeIds, bool);
302 vtkBooleanMacro(OutputPedigreeIds, bool);
304
306
311 vtkSetMacro(AddTabFieldDelimiter, bool);
312 vtkGetMacro(AddTabFieldDelimiter, bool);
313 vtkBooleanMacro(AddTabFieldDelimiter, bool);
315
322
324
329 vtkSetMacro(ReplacementCharacter, vtkTypeUInt32);
330 vtkGetMacro(ReplacementCharacter, vtkTypeUInt32);
332
339 vtkGetMacro(Preview, std::string);
340
342
349
351
357 vtkGetMacro(CommentCharacters, std::string);
358 vtkSetMacro(CommentCharacters, std::string);
360
361protected:
364
367
368 // Read the content of the input file.
369 int ReadData(vtkTable* output_table);
370
371 char* FileName = nullptr;
373 char* InputString = nullptr;
375 char* UnicodeCharacterSet = nullptr;
378 std::string UnicodeRecordDelimiters = "\r\n";
379 std::string UnicodeFieldDelimiters = ",";
380 std::string UnicodeStringDelimiters = "\"";
381 std::string UnicodeWhitespace = " \t\r\n\v\f";
382 std::string UnicodeEscapeCharacter = "\\";
383 std::string CommentCharacters = "#";
385 bool ForceDouble = false;
390 char StringDelimiter = '"';
392 bool HaveHeaders = false;
394 char* PedigreeIdArrayName = nullptr;
396 bool OutputPedigreeIds = false;
399 vtkTypeUInt32 ReplacementCharacter = 'x';
400
401 std::string Preview;
403
404private:
409 std::unique_ptr<std::istream> OpenStream();
410
415 void ReadBOM(std::istream* stream);
416
421 vtkTextCodec* CreateTextCodec(std::istream* input_stream);
422
424 void operator=(const vtkDelimitedTextReader&) = delete;
425};
426
427VTK_ABI_NAMESPACE_END
428#endif
void SetInputString(const char *in, int len)
Specify the InputString for use when reading from a character array.
int ReadData(vtkTable *output_table)
~vtkDelimitedTextReader() override
void SetUTF8RecordDelimiters(const char *delimiters)
Specify the character(s) that will be used to separate records.
vtkStdString GetLastError()
Returns a human-readable description of the most recent error, if any.
void SetInputString(const char *in)
Specify the InputString for use when reading from a character array.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void SetUTF8StringDelimiters(const char *delimiters)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGetFilePathMacro(FileName)
Specifies the delimited text file to be loaded.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
const char * GetUTF8StringDelimiters()
vtkSetFilePathMacro(FileName)
Specifies the delimited text file to be loaded.
static vtkDelimitedTextReader * New()
const char * GetUTF8RecordDelimiters()
Specify the character(s) that will be used to separate records.
void SetInputString(const vtkStdString &input)
Specify the InputString for use when reading from a character array.
const char * GetUTF8FieldDelimiters()
void SetUTF8FieldDelimiters(const char *delimiters)
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Wrapper around std::string to keep symbols short.
A table, which contains similar-typed columns of data.
Definition vtkTable.h:60
Virtual class to act as an interface for all text codecs.
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:368