VTK  9.1.0
vtkDelimitedTextReader.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDelimitedTextReader.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15/*-------------------------------------------------------------------------
16 Copyright 2008 Sandia Corporation.
17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18 the U.S. Government retains certain rights in this software.
19-------------------------------------------------------------------------*/
20
72#ifndef vtkDelimitedTextReader_h
73#define vtkDelimitedTextReader_h
74
75#include "vtkIOInfovisModule.h" // For export macro
76#include "vtkStdString.h" // Needed for vtkStdString
77#include "vtkTableAlgorithm.h"
78#include "vtkUnicodeString.h" // Needed for vtkUnicodeString
79
80class VTKIOINFOVIS_EXPORT vtkDelimitedTextReader : public vtkTableAlgorithm
81{
82public:
85 void PrintSelf(ostream& os, vtkIndent indent) override;
86
88
94
96
102 void SetInputString(const char* in);
103 vtkGetStringMacro(InputString);
104 void SetInputString(const char* in, int len);
105 vtkGetMacro(InputStringLength, int);
106 void SetInputString(const vtkStdString& input)
107 {
108 this->SetInputString(input.c_str(), static_cast<int>(input.length()));
109 }
111
113
117 vtkSetMacro(ReadFromInputString, vtkTypeBool);
118 vtkGetMacro(ReadFromInputString, vtkTypeBool);
119 vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
121
123
134 vtkGetStringMacro(UnicodeCharacterSet);
135 vtkSetStringMacro(UnicodeCharacterSet);
137
139
144 void SetUTF8RecordDelimiters(const char* delimiters);
146 VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8RecordDelimiters(const char* delimiters)")
147 void SetUnicodeRecordDelimiters(const vtkUnicodeString& delimiters);
148 VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8RecordDelimiters()")
149 vtkUnicodeString GetUnicodeRecordDelimiters();
151
153
160 vtkSetStringMacro(FieldDelimiterCharacters);
161 vtkGetStringMacro(FieldDelimiterCharacters);
163
164 void SetUTF8FieldDelimiters(const char* delimiters);
165 const char* GetUTF8FieldDelimiters();
166 VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8FieldDelimiters(const char* delimiters)")
167 void SetUnicodeFieldDelimiters(const vtkUnicodeString& delimiters);
168 VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8FieldDelimiters()")
169 vtkUnicodeString GetUnicodeFieldDelimiters();
170
172
181 vtkGetMacro(StringDelimiter, char);
182 vtkSetMacro(StringDelimiter, char);
184
185 void SetUTF8StringDelimiters(const char* delimiters);
186 const char* GetUTF8StringDelimiters();
187 VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8StringDelimiters(const char* delimiters)")
188 void SetUnicodeStringDelimiters(const vtkUnicodeString& delimiters);
189 VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8StringDelimiters()")
190 vtkUnicodeString GetUnicodeStringDelimiters();
191
193
196 vtkSetMacro(UseStringDelimiter, bool);
197 vtkGetMacro(UseStringDelimiter, bool);
198 vtkBooleanMacro(UseStringDelimiter, bool);
200
202
206 vtkGetMacro(HaveHeaders, bool);
207 vtkSetMacro(HaveHeaders, bool);
209
211
216 vtkSetMacro(MergeConsecutiveDelimiters, bool);
217 vtkGetMacro(MergeConsecutiveDelimiters, bool);
218 vtkBooleanMacro(MergeConsecutiveDelimiters, bool);
220
222
226 vtkGetMacro(MaxRecords, vtkIdType);
227 vtkSetMacro(MaxRecords, vtkIdType);
229
231
236 vtkSetMacro(DetectNumericColumns, bool);
237 vtkGetMacro(DetectNumericColumns, bool);
238 vtkBooleanMacro(DetectNumericColumns, bool);
240
242
247 vtkSetMacro(ForceDouble, bool);
248 vtkGetMacro(ForceDouble, bool);
249 vtkBooleanMacro(ForceDouble, bool);
251
253
268 vtkSetMacro(TrimWhitespacePriorToNumericConversion, bool);
269 vtkGetMacro(TrimWhitespacePriorToNumericConversion, bool);
270 vtkBooleanMacro(TrimWhitespacePriorToNumericConversion, bool);
272
274
278 vtkSetMacro(DefaultIntegerValue, int);
279 vtkGetMacro(DefaultIntegerValue, int);
281
283
287 vtkSetMacro(DefaultDoubleValue, double);
288 vtkGetMacro(DefaultDoubleValue, double);
290
292
296 vtkSetStringMacro(PedigreeIdArrayName);
297 vtkGetStringMacro(PedigreeIdArrayName);
299
301
305 vtkSetMacro(GeneratePedigreeIds, bool);
306 vtkGetMacro(GeneratePedigreeIds, bool);
307 vtkBooleanMacro(GeneratePedigreeIds, bool);
309
311
314 vtkSetMacro(OutputPedigreeIds, bool);
315 vtkGetMacro(OutputPedigreeIds, bool);
316 vtkBooleanMacro(OutputPedigreeIds, bool);
318
320
325 vtkSetMacro(AddTabFieldDelimiter, bool);
326 vtkGetMacro(AddTabFieldDelimiter, bool);
327 vtkBooleanMacro(AddTabFieldDelimiter, bool);
329
335 vtkStdString GetLastError();
336
338
343 vtkSetMacro(ReplacementCharacter, vtkTypeUInt32);
344 vtkGetMacro(ReplacementCharacter, vtkTypeUInt32);
346
347protected:
350
352
353 // Read the content of the input file.
354 int ReadData(vtkTable* const output_table);
355
356 char* FileName;
357 vtkTypeBool ReadFromInputString;
358 char* InputString;
359 int InputStringLength;
360 char* UnicodeCharacterSet;
361 vtkIdType MaxRecords;
362 vtkUnicodeString UnicodeRecordDelimiters;
363 vtkUnicodeString UnicodeFieldDelimiters;
364 vtkUnicodeString UnicodeStringDelimiters;
365 vtkUnicodeString UnicodeWhitespace;
366 vtkUnicodeString UnicodeEscapeCharacter;
367 bool DetectNumericColumns;
368 bool ForceDouble;
369 bool TrimWhitespacePriorToNumericConversion;
370 int DefaultIntegerValue;
371 double DefaultDoubleValue;
372 char* FieldDelimiterCharacters;
373 char StringDelimiter;
374 bool UseStringDelimiter;
375 bool HaveHeaders;
376 bool UnicodeOutputArrays;
377 bool MergeConsecutiveDelimiters;
378 char* PedigreeIdArrayName;
379 bool GeneratePedigreeIds;
380 bool OutputPedigreeIds;
381 bool AddTabFieldDelimiter;
382 vtkStdString LastError;
383 vtkTypeUInt32 ReplacementCharacter;
384
385private:
387 void operator=(const vtkDelimitedTextReader&) = delete;
388};
389
390#endif
reads in delimited ascii or unicode text files and outputs a vtkTable data structure.
void SetInputString(const char *in, int len)
Specify the InputString for use when reading from a character array.
void SetUTF8RecordDelimiters(const char *delimiters)
Specify the character(s) that will be used to separate records.
void SetInputString(const char *in)
Specify the InputString for use when reading from a character array.
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.
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.
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:45
Superclass for algorithms that produce only vtkTables as output.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:72
String class that stores Unicode text.
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkIdType
Definition: vtkType.h:332