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 
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 
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();
137  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8RecordDelimiters(const char* delimiters)")
138  void SetUnicodeRecordDelimiters(const vtkUnicodeString& delimiters);
139  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8RecordDelimiters()")
140  vtkUnicodeString GetUnicodeRecordDelimiters();
142 
144 
151  vtkSetStringMacro(FieldDelimiterCharacters);
152  vtkGetStringMacro(FieldDelimiterCharacters);
154 
155  void SetUTF8FieldDelimiters(const char* delimiters);
156  const char* GetUTF8FieldDelimiters();
157  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8FieldDelimiters(const char* delimiters)")
158  void SetUnicodeFieldDelimiters(const vtkUnicodeString& delimiters);
159  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8FieldDelimiters()")
160  vtkUnicodeString GetUnicodeFieldDelimiters();
161 
163 
172  vtkGetMacro(StringDelimiter, char);
173  vtkSetMacro(StringDelimiter, char);
175 
176  void SetUTF8StringDelimiters(const char* delimiters);
177  const char* GetUTF8StringDelimiters();
178  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8StringDelimiters(const char* delimiters)")
179  void SetUnicodeStringDelimiters(const vtkUnicodeString& delimiters);
180  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8StringDelimiters()")
181  vtkUnicodeString GetUnicodeStringDelimiters();
182 
184 
187  vtkSetMacro(UseStringDelimiter, bool);
188  vtkGetMacro(UseStringDelimiter, bool);
189  vtkBooleanMacro(UseStringDelimiter, bool);
191 
193 
197  vtkGetMacro(HaveHeaders, bool);
198  vtkSetMacro(HaveHeaders, bool);
200 
202 
207  vtkSetMacro(MergeConsecutiveDelimiters, bool);
208  vtkGetMacro(MergeConsecutiveDelimiters, bool);
209  vtkBooleanMacro(MergeConsecutiveDelimiters, bool);
211 
213 
217  vtkGetMacro(MaxRecords, vtkIdType);
218  vtkSetMacro(MaxRecords, vtkIdType);
220 
222 
227  vtkSetMacro(DetectNumericColumns, bool);
228  vtkGetMacro(DetectNumericColumns, bool);
229  vtkBooleanMacro(DetectNumericColumns, bool);
231 
233 
238  vtkSetMacro(ForceDouble, bool);
239  vtkGetMacro(ForceDouble, bool);
240  vtkBooleanMacro(ForceDouble, bool);
242 
244 
259  vtkSetMacro(TrimWhitespacePriorToNumericConversion, bool);
260  vtkGetMacro(TrimWhitespacePriorToNumericConversion, bool);
261  vtkBooleanMacro(TrimWhitespacePriorToNumericConversion, bool);
263 
265 
269  vtkSetMacro(DefaultIntegerValue, int);
270  vtkGetMacro(DefaultIntegerValue, int);
272 
274 
278  vtkSetMacro(DefaultDoubleValue, double);
279  vtkGetMacro(DefaultDoubleValue, double);
281 
283 
287  vtkSetStringMacro(PedigreeIdArrayName);
288  vtkGetStringMacro(PedigreeIdArrayName);
290 
292 
296  vtkSetMacro(GeneratePedigreeIds, bool);
297  vtkGetMacro(GeneratePedigreeIds, bool);
298  vtkBooleanMacro(GeneratePedigreeIds, bool);
300 
302 
305  vtkSetMacro(OutputPedigreeIds, bool);
306  vtkGetMacro(OutputPedigreeIds, bool);
307  vtkBooleanMacro(OutputPedigreeIds, bool);
309 
311 
316  vtkSetMacro(AddTabFieldDelimiter, bool);
317  vtkGetMacro(AddTabFieldDelimiter, bool);
318  vtkBooleanMacro(AddTabFieldDelimiter, bool);
320 
326  vtkStdString GetLastError();
327 
329 
334  vtkSetMacro(ReplacementCharacter, vtkTypeUInt32);
335  vtkGetMacro(ReplacementCharacter, vtkTypeUInt32);
337 
338 protected:
341 
343 
344  // Read the content of the input file.
345  int ReadData(vtkTable* const output_table);
346 
347  char* FileName;
348  vtkTypeBool ReadFromInputString;
349  char* InputString;
350  int InputStringLength;
351  char* UnicodeCharacterSet;
352  vtkIdType MaxRecords;
353  vtkUnicodeString UnicodeRecordDelimiters;
354  vtkUnicodeString UnicodeFieldDelimiters;
355  vtkUnicodeString UnicodeStringDelimiters;
356  vtkUnicodeString UnicodeWhitespace;
357  vtkUnicodeString UnicodeEscapeCharacter;
358  bool DetectNumericColumns;
359  bool ForceDouble;
360  bool TrimWhitespacePriorToNumericConversion;
361  int DefaultIntegerValue;
362  double DefaultDoubleValue;
363  char* FieldDelimiterCharacters;
364  char StringDelimiter;
365  bool UseStringDelimiter;
366  bool HaveHeaders;
367  bool UnicodeOutputArrays;
368  bool MergeConsecutiveDelimiters;
369  char* PedigreeIdArrayName;
370  bool GeneratePedigreeIds;
371  bool OutputPedigreeIds;
372  bool AddTabFieldDelimiter;
373  vtkStdString LastError;
374  vtkTypeUInt32 ReplacementCharacter;
375 
376 private:
378  void operator=(const vtkDelimitedTextReader&) = delete;
379 };
380 
381 #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.
static vtkDelimitedTextReader * New()
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.
void SetInputString(const vtkStdString &input)
Specify the InputString for use when reading from a character array.
const char * GetUTF8RecordDelimiters()
Specify the character(s) that will be used to separate records.
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:36
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
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkIdType
Definition: vtkType.h:332