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 
102 #ifndef vtkDelimitedTextReader_h
103 #define vtkDelimitedTextReader_h
104 
105 #include "vtkIOInfovisModule.h" // For export macro
106 #include "vtkStdString.h" // Needed for vtkStdString
107 #include "vtkTableAlgorithm.h"
108 #include "vtkUnicodeString.h" // Needed for vtkUnicodeString
109 
110 class VTKIOINFOVIS_EXPORT vtkDelimitedTextReader : public vtkTableAlgorithm
111 {
112 public:
115  void PrintSelf(ostream& os, vtkIndent indent) override;
116 
118 
124 
126 
132  void SetInputString(const char* in);
133  vtkGetStringMacro(InputString);
134  void SetInputString(const char* in, int len);
135  vtkGetMacro(InputStringLength, int);
136  void SetInputString(const vtkStdString& input)
137  {
138  this->SetInputString(input.c_str(), static_cast<int>(input.length()));
139  }
141 
143 
147  vtkSetMacro(ReadFromInputString, vtkTypeBool);
148  vtkGetMacro(ReadFromInputString, vtkTypeBool);
149  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
151 
153 
164  vtkGetStringMacro(UnicodeCharacterSet);
165  vtkSetStringMacro(UnicodeCharacterSet);
167 
169 
174  void SetUTF8RecordDelimiters(const char* delimiters);
175  const char* GetUTF8RecordDelimiters();
176  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8RecordDelimiters(const char* delimiters)")
177  void SetUnicodeRecordDelimiters(const vtkUnicodeString& delimiters);
178  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8RecordDelimiters()")
179  vtkUnicodeString GetUnicodeRecordDelimiters();
181 
183 
190  vtkSetStringMacro(FieldDelimiterCharacters);
191  vtkGetStringMacro(FieldDelimiterCharacters);
193 
194  void SetUTF8FieldDelimiters(const char* delimiters);
195  const char* GetUTF8FieldDelimiters();
196  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8FieldDelimiters(const char* delimiters)")
197  void SetUnicodeFieldDelimiters(const vtkUnicodeString& delimiters);
198  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8FieldDelimiters()")
199  vtkUnicodeString GetUnicodeFieldDelimiters();
200 
202 
211  vtkGetMacro(StringDelimiter, char);
212  vtkSetMacro(StringDelimiter, char);
214 
215  void SetUTF8StringDelimiters(const char* delimiters);
216  const char* GetUTF8StringDelimiters();
217  VTK_DEPRECATED_IN_9_1_0("Use void SetUTF8StringDelimiters(const char* delimiters)")
218  void SetUnicodeStringDelimiters(const vtkUnicodeString& delimiters);
219  VTK_DEPRECATED_IN_9_1_0("Use const char* GetUTF8StringDelimiters()")
220  vtkUnicodeString GetUnicodeStringDelimiters();
221 
223 
226  vtkSetMacro(UseStringDelimiter, bool);
227  vtkGetMacro(UseStringDelimiter, bool);
228  vtkBooleanMacro(UseStringDelimiter, bool);
230 
232 
236  vtkGetMacro(HaveHeaders, bool);
237  vtkSetMacro(HaveHeaders, bool);
239 
241 
246  vtkSetMacro(MergeConsecutiveDelimiters, bool);
247  vtkGetMacro(MergeConsecutiveDelimiters, bool);
248  vtkBooleanMacro(MergeConsecutiveDelimiters, bool);
250 
252 
256  vtkGetMacro(MaxRecords, vtkIdType);
257  vtkSetMacro(MaxRecords, vtkIdType);
259 
261 
266  vtkSetMacro(DetectNumericColumns, bool);
267  vtkGetMacro(DetectNumericColumns, bool);
268  vtkBooleanMacro(DetectNumericColumns, bool);
270 
272 
277  vtkSetMacro(ForceDouble, bool);
278  vtkGetMacro(ForceDouble, bool);
279  vtkBooleanMacro(ForceDouble, bool);
281 
283 
298  vtkSetMacro(TrimWhitespacePriorToNumericConversion, bool);
299  vtkGetMacro(TrimWhitespacePriorToNumericConversion, bool);
300  vtkBooleanMacro(TrimWhitespacePriorToNumericConversion, bool);
302 
304 
308  vtkSetMacro(DefaultIntegerValue, int);
309  vtkGetMacro(DefaultIntegerValue, int);
311 
313 
317  vtkSetMacro(DefaultDoubleValue, double);
318  vtkGetMacro(DefaultDoubleValue, double);
320 
322 
326  vtkSetStringMacro(PedigreeIdArrayName);
327  vtkGetStringMacro(PedigreeIdArrayName);
329 
331 
335  vtkSetMacro(GeneratePedigreeIds, bool);
336  vtkGetMacro(GeneratePedigreeIds, bool);
337  vtkBooleanMacro(GeneratePedigreeIds, bool);
339 
341 
344  vtkSetMacro(OutputPedigreeIds, bool);
345  vtkGetMacro(OutputPedigreeIds, bool);
346  vtkBooleanMacro(OutputPedigreeIds, bool);
348 
350 
355  vtkSetMacro(AddTabFieldDelimiter, bool);
356  vtkGetMacro(AddTabFieldDelimiter, bool);
357  vtkBooleanMacro(AddTabFieldDelimiter, bool);
359 
365  vtkStdString GetLastError();
366 
368 
373  vtkSetMacro(ReplacementCharacter, vtkTypeUInt32);
374  vtkGetMacro(ReplacementCharacter, vtkTypeUInt32);
376 
377 protected:
380 
382 
383  // Read the content of the input file.
384  int ReadData(vtkTable* const output_table);
385 
386  char* FileName;
387  vtkTypeBool ReadFromInputString;
388  char* InputString;
389  int InputStringLength;
390  char* UnicodeCharacterSet;
391  vtkIdType MaxRecords;
392  vtkUnicodeString UnicodeRecordDelimiters;
393  vtkUnicodeString UnicodeFieldDelimiters;
394  vtkUnicodeString UnicodeStringDelimiters;
395  vtkUnicodeString UnicodeWhitespace;
396  vtkUnicodeString UnicodeEscapeCharacter;
397  bool DetectNumericColumns;
398  bool ForceDouble;
399  bool TrimWhitespacePriorToNumericConversion;
400  int DefaultIntegerValue;
401  double DefaultDoubleValue;
402  char* FieldDelimiterCharacters;
403  char StringDelimiter;
404  bool UseStringDelimiter;
405  bool HaveHeaders;
406  bool UnicodeOutputArrays;
407  bool MergeConsecutiveDelimiters;
408  char* PedigreeIdArrayName;
409  bool GeneratePedigreeIds;
410  bool OutputPedigreeIds;
411  bool AddTabFieldDelimiter;
412  vtkStdString LastError;
413  vtkTypeUInt32 ReplacementCharacter;
414 
415 private:
417  void operator=(const vtkDelimitedTextReader&) = delete;
418 };
419 
420 #endif
vtkStdString.h
vtkDelimitedTextReader::SetUTF8RecordDelimiters
void SetUTF8RecordDelimiters(const char *delimiters)
Specify the character(s) that will be used to separate records.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkDelimitedTextReader::SetInputString
void SetInputString(const char *in)
Specify the InputString for use when reading from a character array.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
vtkDelimitedTextReader::GetUTF8RecordDelimiters
const char * GetUTF8RecordDelimiters()
Specify the character(s) that will be used to separate records.
vtkUnicodeString.h
VTK_DEPRECATED_IN_9_1_0
#define VTK_DEPRECATED_IN_9_1_0(reason)
Definition: vtkDeprecation.h:117
vtkDelimitedTextReader::vtkGetFilePathMacro
vtkGetFilePathMacro(FileName)
Specifies the delimited text file to be loaded.
vtkDelimitedTextReader::SetInputString
void SetInputString(const vtkStdString &input)
Specify the InputString for use when reading from a character array.
Definition: vtkDelimitedTextReader.h:136
vtkTableAlgorithm
Superclass for algorithms that produce only vtkTables as output.
Definition: vtkTableAlgorithm.h:49
vtkDelimitedTextReader::New
static vtkDelimitedTextReader * New()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkUnicodeString
String class that stores Unicode text.
Definition: vtkUnicodeString.h:80
vtkDelimitedTextReader
reads in delimited ascii or unicode text files and outputs a vtkTable data structure.
Definition: vtkDelimitedTextReader.h:111
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkDelimitedTextReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTableAlgorithm.h
vtkDelimitedTextReader::SetInputString
void SetInputString(const char *in, int len)
Specify the InputString for use when reading from a character array.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkDelimitedTextReader::vtkSetFilePathMacro
vtkSetFilePathMacro(FileName)
Specifies the delimited text file to be loaded.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69