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  auto formatedString = vtk::format(format, std::forward<T>(args)...);
43  this->AddString(formatedString.c_str());
44  }
45 
49  void RemoveAllItems();
50 
54  void SetString(int idx, const char* str);
55 
59  int GetLength() { return this->GetNumberOfStrings(); }
60 
64  int GetIndex(const char* str);
65 
69  const char* GetString(int idx);
70 
74  int GetNumberOfStrings();
75 
76 protected:
77  vtkStringList();
78  ~vtkStringList() override;
79 
80 private:
81  class vtkInternals;
82  std::unique_ptr<vtkInternals> Internals;
83 
84  vtkStringList(const vtkStringList&) = delete;
85  void operator=(const vtkStringList&) = delete;
86 };
87 
88 #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:59
void operator=(const vtkObjectBase &)
Manages allocation and freeing for a string list.
Definition: vtkStringList.h:20