VTK  9.4.20241226
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
17VTK_ABI_NAMESPACE_BEGIN
18
99class VTKIOCORE_EXPORT vtkURILoader : public vtkObject
100{
101 struct vtkInternals;
102
103public:
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
136
140 bool HasBaseURI() const { return this->GetBaseURI() != nullptr; }
141
152 bool SetBaseFileName(VTK_FILEPATH const std::string& filepath);
153
164 bool SetBaseDirectory(VTK_FILEPATH const std::string& dirpath);
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
218protected:
225 ~vtkURILoader() override;
226 vtkURILoader(const vtkURILoader&) = delete;
228
244
256
271
272private:
273 std::unique_ptr<vtkInternals> Impl;
274};
275
276VTK_ABI_NAMESPACE_END
277
278#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
Helper class for readers and importer that need to load more than one resource.
vtkSmartPointer< vtkURI > Resolve(const vtkURI *uri)
Resolve URI from base URI.
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.
static vtkURILoader * New()
vtkURILoader()
Constructor.
vtkSmartPointer< vtkResourceStream > Load(const vtkURI *uri)
Try to resolve given URI from base URI, using vtkURI::Resolve.
vtkSmartPointer< vtkResourceStream > Load(const char *uri, std::size_t size)
Load a resource referenced by an URI.
vtkURILoader & operator=(const vtkURILoader &)=delete
bool SetBaseFileName(VTK_FILEPATH const std::string &filepath)
Higher level way to set the base URI to an existing file.
vtkSmartPointer< vtkResourceStream > LoadData(const vtkURI &uri)
Load a resource from a data URI.
vtkURI * GetBaseURI() const
Get base URI.
vtkSmartPointer< vtkResourceStream > Load(const std::string &uri)
Load a resource referenced by an URI.
bool HasBaseURI() const
Check if loader as a base URI.
bool SetBaseDirectory(VTK_FILEPATH const std::string &dirpath)
Higher level way to set the base URI to an existing directory.
vtkURILoader(const vtkURILoader &)=delete
virtual vtkSmartPointer< vtkResourceStream > DoLoad(const vtkURI &uri)
Load a resource from a full URI.
bool SetBaseURI(vtkURI *uri)
Set base URI to use.
vtkSmartPointer< vtkResourceStream > LoadResolved(const vtkURI *uri)
Load a resource from a full URI.
~vtkURILoader() override
vtkSmartPointer< vtkResourceStream > LoadFile(const vtkURI &uri)
Load a resource from a file URI.
URI representation.
Definition vtkURI.h:122
#define VTK_FILEPATH