vtkStringList.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkStringList_h
12 #define vtkStringList_h
13 
14 #include "vtkObject.h"
15 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
16 #include "vtkStringFormatter.h" // for vtk::printf_to_std_format
17 
18 #include <memory> // for std::unique_ptr
19 
21 {
22 public:
23  static vtkStringList* New();
24  vtkTypeMacro(vtkStringList, vtkObject);
25  void PrintSelf(ostream& os, vtkIndent indent) override;
26 
28 
31  void AddString(const char* str);
32  void AddUniqueString(const char* str);
34 
38  template <typename... T>
39  void AddFormattedString(const char* EventString, T&&... args)
40  {
41  std::string format = EventString ? EventString : "";
42  if (vtk::is_printf_format(format))
43  {
44  // PARAVIEW_DEPRECATED_IN_6_1_0
45  vtkWarningMacro(<< "The given format " << format << " is a printf format. The format will be "
46  << "converted to std::format. This conversion has been deprecated in 6.1.0");
47  format = vtk::printf_to_std_format(format);
48  }
49  auto formatedString = vtk::format(format, std::forward<T>(args)...);
50  this->AddString(formatedString.c_str());
51  }
52 
56  void RemoveAllItems();
57 
61  void SetString(int idx, const char* str);
62 
66  int GetLength() { return this->GetNumberOfStrings(); }
67 
71  int GetIndex(const char* str);
72 
76  const char* GetString(int idx);
77 
81  int GetNumberOfStrings();
82 
83 protected:
84  vtkStringList();
85  ~vtkStringList() override;
86 
87 private:
88  class vtkInternals;
89  std::unique_ptr<vtkInternals> Internals;
90 
91  vtkStringList(const vtkStringList&) = delete;
92  void operator=(const vtkStringList&) = delete;
93 };
94 
95 #endif
#define VTKPVVTKEXTENSIONSCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
void AddFormattedString(const char *EventString, T &&... args)
Add a command and format it any way you like.
Definition: vtkStringList.h:39
static vtkObject * New()
int GetLength()
Get the length of the list.
Definition: vtkStringList.h:66
void operator=(const vtkObjectBase &)
Manages allocation and freeing for a string list.
Definition: vtkStringList.h:20