VTK  9.0.3
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 
63 #ifndef vtkDelimitedTextReader_h
64 #define vtkDelimitedTextReader_h
65 
66 #include "vtkIOInfovisModule.h" // For export macro
67 #include "vtkStdString.h" // Needed for vtkStdString
68 #include "vtkTableAlgorithm.h"
69 #include "vtkUnicodeString.h" // Needed for vtkUnicodeString
70 
71 class VTKIOINFOVIS_EXPORT vtkDelimitedTextReader : public vtkTableAlgorithm
72 {
73 public:
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
79 
82  vtkGetStringMacro(FileName);
83  vtkSetStringMacro(FileName);
85 
87 
93  void SetInputString(const char* in);
94  vtkGetStringMacro(InputString);
95  void SetInputString(const char* in, int len);
96  vtkGetMacro(InputStringLength, int);
97  void SetInputString(const vtkStdString& input)
98  {
99  this->SetInputString(input.c_str(), static_cast<int>(input.length()));
100  }
102 
104 
108  vtkSetMacro(ReadFromInputString, vtkTypeBool);
109  vtkGetMacro(ReadFromInputString, vtkTypeBool);
110  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
112 
114 
125  vtkGetStringMacro(UnicodeCharacterSet);
126  vtkSetStringMacro(UnicodeCharacterSet);
128 
130 
135  void SetUTF8RecordDelimiters(const char* delimiters);
136  const char* GetUTF8RecordDelimiters();
140 
142 
149  vtkSetStringMacro(FieldDelimiterCharacters);
150  vtkGetStringMacro(FieldDelimiterCharacters);
152 
153  void SetUTF8FieldDelimiters(const char* delimiters);
154  const char* GetUTF8FieldDelimiters();
157 
159 
168  vtkGetMacro(StringDelimiter, char);
169  vtkSetMacro(StringDelimiter, char);
171 
172  void SetUTF8StringDelimiters(const char* delimiters);
173  const char* GetUTF8StringDelimiters();
176 
178 
181  vtkSetMacro(UseStringDelimiter, bool);
182  vtkGetMacro(UseStringDelimiter, bool);
183  vtkBooleanMacro(UseStringDelimiter, bool);
185 
187 
191  vtkGetMacro(HaveHeaders, bool);
192  vtkSetMacro(HaveHeaders, bool);
194 
196 
201  vtkSetMacro(MergeConsecutiveDelimiters, bool);
202  vtkGetMacro(MergeConsecutiveDelimiters, bool);
203  vtkBooleanMacro(MergeConsecutiveDelimiters, bool);
205 
207 
211  vtkGetMacro(MaxRecords, vtkIdType);
212  vtkSetMacro(MaxRecords, vtkIdType);
214 
216 
221  vtkSetMacro(DetectNumericColumns, bool);
222  vtkGetMacro(DetectNumericColumns, bool);
223  vtkBooleanMacro(DetectNumericColumns, bool);
225 
227 
232  vtkSetMacro(ForceDouble, bool);
233  vtkGetMacro(ForceDouble, bool);
234  vtkBooleanMacro(ForceDouble, bool);
236 
238 
253  vtkSetMacro(TrimWhitespacePriorToNumericConversion, bool);
254  vtkGetMacro(TrimWhitespacePriorToNumericConversion, bool);
255  vtkBooleanMacro(TrimWhitespacePriorToNumericConversion, bool);
257 
259 
263  vtkSetMacro(DefaultIntegerValue, int);
264  vtkGetMacro(DefaultIntegerValue, int);
266 
268 
272  vtkSetMacro(DefaultDoubleValue, double);
273  vtkGetMacro(DefaultDoubleValue, double);
275 
277 
281  vtkSetStringMacro(PedigreeIdArrayName);
282  vtkGetStringMacro(PedigreeIdArrayName);
284 
286 
290  vtkSetMacro(GeneratePedigreeIds, bool);
291  vtkGetMacro(GeneratePedigreeIds, bool);
292  vtkBooleanMacro(GeneratePedigreeIds, bool);
294 
296 
299  vtkSetMacro(OutputPedigreeIds, bool);
300  vtkGetMacro(OutputPedigreeIds, bool);
301  vtkBooleanMacro(OutputPedigreeIds, bool);
303 
305 
310  vtkSetMacro(AddTabFieldDelimiter, bool);
311  vtkGetMacro(AddTabFieldDelimiter, bool);
312  vtkBooleanMacro(AddTabFieldDelimiter, bool);
314 
321 
323 
328  vtkSetMacro(ReplacementCharacter, vtkTypeUInt32);
329  vtkGetMacro(ReplacementCharacter, vtkTypeUInt32);
331 
332 protected:
335 
337 
338  // Read the content of the input file.
339  int ReadData(vtkTable* const output_table);
340 
341  char* FileName;
343  char* InputString;
368  vtkTypeUInt32 ReplacementCharacter;
369 
370 private:
372  void operator=(const vtkDelimitedTextReader&) = delete;
373 };
374 
375 #endif
reads in delimited ascii or unicode text files and outputs a vtkTable data structure.
void SetInputString(const char *in, int len)
vtkUnicodeString GetUnicodeRecordDelimiters()
void SetUnicodeRecordDelimiters(const vtkUnicodeString &delimiters)
const char * GetUTF8StringDelimiters()
static vtkDelimitedTextReader * New()
vtkUnicodeString UnicodeWhitespace
vtkUnicodeString UnicodeRecordDelimiters
vtkUnicodeString UnicodeFieldDelimiters
~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.
vtkUnicodeString UnicodeStringDelimiters
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.
void SetUnicodeFieldDelimiters(const vtkUnicodeString &delimiters)
vtkUnicodeString GetUnicodeStringDelimiters()
void SetUnicodeStringDelimiters(const vtkUnicodeString &delimiters)
vtkUnicodeString GetUnicodeFieldDelimiters()
int ReadData(vtkTable *const output_table)
vtkUnicodeString UnicodeEscapeCharacter
void SetInputString(const vtkStdString &input)
const char * GetUTF8FieldDelimiters()
void SetUTF8FieldDelimiters(const char *delimiters)
const char * GetUTF8RecordDelimiters()
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
Superclass for algorithms that produce only vtkTables as output.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:63
String class that stores Unicode text.
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338