VTK  9.3.0
vtkURILoader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkURILoader_h
4 #define vtkURILoader_h
5 
6 #include "vtkIOCoreModule.h" // For export macro
7 #include "vtkObject.h"
8 #include "vtkResourceStream.h" // For vtkResourceStream
9 #include "vtkSmartPointer.h" // For vtkSmartPointer
10 #include "vtkURI.h" // For vtkURI
11 
12 #include <cstdint> // for std::int32_t
13 #include <cstdlib> // for std::size_t
14 #include <memory> // for std::unique_ptr
15 #include <string> // for std::string
16 
17 VTK_ABI_NAMESPACE_BEGIN
18 
99 class VTKIOCORE_EXPORT vtkURILoader : public vtkObject
100 {
101  struct vtkInternals;
102 
103 public:
104  vtkTypeMacro(vtkURILoader, vtkObject);
105  void PrintSelf(ostream& os, vtkIndent indent) override;
106  static vtkURILoader* New();
107 
109 
127  bool SetBaseURI(const std::string& uri);
128  bool SetBaseURI(vtkURI* uri);
130 
135  vtkURI* GetBaseURI() const;
136 
140  bool HasBaseURI() const { return this->GetBaseURI() != nullptr; }
141 
152  bool SetBaseFileName(VTK_FILEPATH const std::string& filepath);
153 
165 
171 
181  {
182  return this->Load(uri.data(), uri.size());
183  }
184 
196  vtkSmartPointer<vtkResourceStream> Load(const char* uri, std::size_t size);
197 
207 
217 
218 protected:
225  ~vtkURILoader() override;
226  vtkURILoader(const vtkURILoader&) = delete;
228 
244 
256 
271 
272 private:
273  std::unique_ptr<vtkInternals> Impl;
274 };
275 
276 VTK_ABI_NAMESPACE_END
277 
278 #endif
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
Hold a reference to a vtkObjectBase instance.
Helper class for readers and importer that need to load more than one resource.
Definition: vtkURILoader.h:100
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool SetBaseURI(const std::string &uri)
Set base URI to use.
vtkSmartPointer< vtkResourceStream > Load(const char *uri, std::size_t size)
Load a resource referenced by an URI.
vtkURILoader()
Constructor.
vtkSmartPointer< vtkResourceStream > LoadResolved(const vtkURI *uri)
Load a resource from a full URI.
vtkURI * GetBaseURI() const
Get base URI.
static vtkURILoader * New()
bool SetBaseFileName(VTK_FILEPATH const std::string &filepath)
Higher level way to set the base URI to an existing file.
vtkSmartPointer< vtkURI > Resolve(const vtkURI *uri)
Resolve URI from base URI.
virtual vtkSmartPointer< vtkResourceStream > DoLoad(const vtkURI &uri)
Load a resource from a full URI.
vtkURILoader & operator=(const vtkURILoader &)=delete
bool HasBaseURI() const
Check if loader as a base URI.
Definition: vtkURILoader.h:140
vtkSmartPointer< vtkResourceStream > Load(const vtkURI *uri)
Try to resolve given URI from base URI, using vtkURI::Resolve.
vtkSmartPointer< vtkResourceStream > LoadFile(const vtkURI &uri)
Load a resource from a file URI.
bool SetBaseDirectory(VTK_FILEPATH const std::string &dirpath)
Higher level way to set the base URI to an existing directory.
vtkSmartPointer< vtkResourceStream > Load(const std::string &uri)
Load a resource referenced by an URI.
Definition: vtkURILoader.h:180
vtkURILoader(const vtkURILoader &)=delete
bool SetBaseURI(vtkURI *uri)
Set base URI to use.
~vtkURILoader() override
vtkSmartPointer< vtkResourceStream > LoadData(const vtkURI &uri)
Load a resource from a data URI.
URI representation.
Definition: vtkURI.h:122
@ size
Definition: vtkX3D.h:253
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH