VTK  9.7.1
vtkDelimitedTextWriter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2009 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
13 #ifndef vtkDelimitedTextWriter_h
14 #define vtkDelimitedTextWriter_h
15 
16 #include "vtkIOCoreModule.h" // For export macro
17 #include "vtkWriter.h"
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 class vtkStdString;
21 class vtkTable;
22 
23 class VTKIOCORE_EXPORT vtkDelimitedTextWriter : public vtkWriter
24 {
25 public:
26  static vtkDelimitedTextWriter* New();
28  void PrintSelf(ostream& os, vtkIndent indent) override;
29 
31 
34  vtkSetStringMacro(FieldDelimiter);
35  vtkGetStringMacro(FieldDelimiter);
37 
39 
43  vtkSetStringMacro(StringDelimiter);
44  vtkGetStringMacro(StringDelimiter);
46 
48 
51  vtkSetFilePathMacro(FileName);
52  vtkGetFilePathMacro(FileName);
54 
56 
60  vtkSetMacro(UseStringDelimiter, bool);
61  vtkGetMacro(UseStringDelimiter, bool);
63 
65 
68  vtkSetMacro(WriteToOutputString, bool);
69  vtkGetMacro(WriteToOutputString, bool);
70  vtkBooleanMacro(WriteToOutputString, bool);
72 
77  char* RegisterAndGetOutputString();
78 
83  vtkStdString GetString(vtkStdString string);
84 
86 
90  vtkSetMacro(Precision, int);
91  vtkGetMacro(Precision, int);
93 
94  enum Notations
95  {
96  STANDARD_NOTATION = 0,
98  FIXED_NOTATION
99  };
100 
102 
115  vtkSetMacro(Notation, int);
116  vtkGetMacro(Notation, int);
117  virtual void SetNotationToStandard() { this->SetNotation(STANDARD_NOTATION); }
118  virtual void SetNotationToScientific() { this->SetNotation(SCIENTIFIC_NOTATION); }
119  virtual void SetNotationToFixed() { this->SetNotation(FIXED_NOTATION); }
121 
122 protected:
124  ~vtkDelimitedTextWriter() override;
125 
128 
129  bool OpenStream();
130 
131  bool WriteDataAndReturn() override;
132 
133  // see algorithm for more info.
134  // This writer takes in vtkTable.
135  int FillInputPortInformation(int port, vtkInformation* info) override;
136 
137  char* FileName;
141  int Precision = 6;
142  int Notation = STANDARD_NOTATION;
143 
144  ostream* Stream;
145 
146 private:
148  void operator=(const vtkDelimitedTextWriter&) = delete;
149 
150  bool WriteTable(vtkTable* table);
151 };
152 
153 VTK_ABI_NAMESPACE_END
154 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
Store vtkAlgorithm input/output information.
virtual void SetNotationToScientific()
Sets or gets the notation for writing floating point numbers using std::floatfield.
virtual void SetNotationToStandard()
Sets or gets the notation for writing floating point numbers using std::floatfield.
abstract class to write data to file(s)
Definition: vtkWriter.h:35
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Delimited text writer for vtkTable Writes a vtkTable as a delimited text file (such as CSV)...
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void SetNotationToFixed()
Sets or gets the notation for writing floating point numbers using std::floatfield.
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
static vtkAlgorithm * New()
virtual bool WriteDataAndReturn()