forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvtkMimeTypes.h
114 lines (97 loc) · 4.46 KB
/
vtkMimeTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMimeTypes.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
// .NAME vtkMimeTypes - Determines the MIME type of a resource.
//
// .SECTION Description
// vtkMimeTypes is a helper class for determining the MIME type of a resource at runtime.
// To use it, create an instance of vtkMimeTypes, then call the Lookup() method to
// determine the MIME type of each resource of-interest.
//
// vtkMimeTypes relies on a set of strategy objects to perform the actual lookups.
// These strategy objects may determine the MIME type based on arbitrary methods,
// including looking at file extensions, examining the contents of the resource, or
// some combination thereof.
//
// By default, vtkMimeTypes is configured with a simple cross-platform strategy
// that identifies resources based on a hard-coded list of filename extensions, but
// you can supplement this process with your own strategies. The list of strategies
// is executed in-order to determine the MIME type of a resource, so earlier strategies
// "override" later strategies.
//
// .SECTION See Also
// vtkMimeTypeStrategy, vtkFileExtensionMimeTypeStrategy.
//
// .SECTION Thanks
// Developed by Timothy M. Shead ([email protected]) at Sandia National Laboratories.
#ifndef _vtkMimeTypes_h
#define _vtkMimeTypes_h
#include <vtkObject.h>
#include <vtkStdString.h> //Needed for lookup
class vtkMimeTypeStrategy;
class VTK_TEXT_ANALYSIS_EXPORT vtkMimeTypes :
public vtkObject
{
public:
static vtkMimeTypes* New();
vtkTypeMacro(vtkMimeTypes, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Clear the list of strategies.
void ClearStrategies();
// Description:
// Prepend a strategy to the list of strategies. vtkMimeTypes assumes ownership
// of the supplied object.
void PrependStrategy(vtkMimeTypeStrategy* strategy);
// Description:
// Append a strategy to the list of strategies. vtkMimeTypes assumes ownership
// of the supplied object.
void AppendStrategy(vtkMimeTypeStrategy* strategy);
// Description:
// Given a resource URI, returns the MIME-type of the resource, or empty-string
// if the type cannot be identified.
vtkStdString Lookup(const vtkStdString& uri);
// Description:
// Given the contents of a resource, returns the MIME-type of the resource, or
// empty-string if the type cannot be identified.
vtkStdString Lookup(const char* begin, const char* end);
// Description:
// Given the contents of a resource, returns the MIME-type of the resource, or
// empty-string if the type cannot be identified.
vtkStdString Lookup(const vtkTypeUInt8* begin, const vtkTypeUInt8* end);
// Description:
// Given a resource URI and its contents, returns the MIME-type of the resource,
// or empty-string if the type cannot be identified.
vtkStdString Lookup(const vtkStdString& uri, const char* begin, const char* end);
// Description:
// Given a resource URI and its contents, returns the MIME-type of the resource,
// or empty-string if the type cannot be identified.
vtkStdString Lookup(const vtkStdString& uri, const vtkTypeUInt8* begin, const vtkTypeUInt8* end);
// Description:
// Returns true iff a Mime pattern matches the given type. Handles wildcards
// so the pattern "*/*" will match any type (including empty type), and "text/*"
// will match "text/plain", "text/html", "text/xml", etc.
static bool Match(const vtkStdString& pattern, const vtkStdString& type);
//BTX
private:
vtkMimeTypes();
~vtkMimeTypes();
vtkMimeTypes(const vtkMimeTypes&); //Not implemented.
void operator=(const vtkMimeTypes&); //Not implemented.
class Implementation;
Implementation* const Internal;
//ETX
};
#endif // !_vtkMimeTypes_h