HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_MIME.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT library (C++)
7
*
8
* COMMENTS: MIME packetting for I/O
9
*
10
*/
11
12
#ifndef __UT_MIME_h__
13
#define __UT_MIME_h__
14
15
#include "
UT_API.h
"
16
#include "
UT_StringHolder.h
"
17
#include "
UT_StringMap.h
"
18
#include "
UT_WorkBuffer.h
"
19
#include <
SYS/SYS_Types.h
>
20
#include <iosfwd>
21
22
class
UT_IStream
;
23
class
UT_String
;
24
class
UT_StringArray
;
25
26
enum
UT_MIME_Status
{
27
UT_MIME_ERROR
= -1,
28
UT_MIME_OK
= 0,
29
UT_MIME_EOF_OK
,
// End of file reached
30
UT_MIME_EXTERNAL_OK
,
31
UT_MIME_BINARY
,
// Binary MIME format not supported yet
32
UT_MIME_BAD_EOF
,
// Unexpected EOF
33
UT_MIME_BAD_HEADER
,
// Bad header
34
UT_MIME_BAD_CONTENTS
,
// Bad contents in MIME packet
35
UT_MIME_BAD_STREAM
,
// Bad stream (i.e. bad calling sequence)
36
UT_MIME_USER_ABORT
// User cancelled reading the stream
37
};
38
39
class
UT_API
UT_MIME
40
{
41
public
:
42
43
// --------------------------------------------------------
44
// Reading
45
46
UT_MIME_Status
open
(
UT_IStream
&is);
47
48
/// Read the next part of the MIME file.
49
/// 'external_src' is optionally the directory the external files are
50
/// stored in. If this is not specified then UT_MIME_EXTERNAL_OK is
51
/// returned for parts that are stored externally. If the external can
52
/// be read its contents will be placed in 'data'.
53
UT_MIME_Status
readPart(
UT_IStream
&is,
54
UT_String
&
path
,
55
UT_WorkBuffer
&
data
,
56
exint
*modtime =
nullptr
,
57
const
char
*ext_src =
nullptr
);
58
void
close
(
UT_IStream
&is) {};
59
60
// --------------------------------------------------------
61
// Writing
62
63
void
open
(std::ostream &os,
64
const
char
*boundaryText =
nullptr
);
65
66
/// Create a new MIME part in the file with the data specified.
67
void
writePart(std::ostream &os,
68
const
UT_StringHolder
&path,
69
const
UT_WorkBuffer
&data,
70
const
exint
modtime = -1);
71
72
/// Create a new MIME part in the file to indicate externally stored data.
73
void
writeExternalReference(std::ostream &os,
74
const
UT_StringHolder
&path,
75
const
exint
modtime = -1);
76
void
close
(std::ostream &os);
77
78
// --------------------------------------------------------
79
// Filtering
80
81
/// Function signature for functions used to process MIME sections. This
82
/// does all processing in-memory.
83
/// @param in_data Arbitrary input data.
84
/// @param out_data Post processed data output stream which will be MIME data.
85
/// @param filter_data opaque pointer to data used by the filter func.
86
/// @returns False if there was a problem with the filtering.
87
typedef
bool(*TextFilterFunc)(
const
UT_WorkBuffer
&in_data,
88
UT_WorkBuffer
&out_data,
89
void
*filter_data);
90
91
struct
TextFilter
92
{
93
TextFilterFunc
myFilter
;
94
void
*
myFilterData
;
95
96
TextFilter
(TextFilterFunc
filter
,
void
*filterData)
97
: myFilter(filter),
98
myFilterData(filterData)
99
{}
100
};
101
/// Map of section name pattern to a text filter.
102
typedef
UT_StringMap<TextFilter>
TextFilterList
;
103
104
/// Runs through a MIME archive and apply the TextFilterList filters to the
105
/// sections as appropriate. The complete input mime file `is` is read.
106
/// Packets matching `inclusions` but not matching `exclusions` are written
107
/// to the output stream `os` as MIME data.
108
///
109
/// All patterns follow UT_String::multiMatch() except as noted.
110
///
111
/// @param is input text stream of MIME data.
112
/// @param os output stream which will be MIME data.
113
/// @param inclusions Only include these sections. `nullptr` to include all sections.
114
/// @param exclusions Exclude these sections from sections that pass `inclusions`.
115
/// @param filters Filters to apply.
116
/// @returns False if there was a problem with the stream or parameters.
117
static
bool
filter
(
UT_IStream
&is,
118
std::ostream &os,
119
const
char
* inclusions,
120
const
char
* exclusions,
121
const
TextFilterList
* filters =
nullptr
);
122
123
124
// --------------------------------------------------------
125
// Info
126
127
/// Given a UT_MIME_Status, return 'true' if the status is not an error
128
/// condition.
129
static
bool
StatusOK(
UT_MIME_Status
status);
130
131
const
UT_WorkBuffer
&
getBoundaryText
()
const
{
return
myBoundaryText; }
132
133
/// Return a list of all the files stored externally from this MIME file.
134
/// 'external_src' is optionally the directory the files are stored in.
135
static
UT_MIME_Status
getAllExternalRefs(
UT_IStream
&is,
136
UT_StringArray
&external_files,
137
const
char
*ext_src =
nullptr
);
138
/// Return a list of all the files stored externally from this MIME file.
139
/// 'external_src' is optionally the directory the files are stored in.
140
static
UT_MIME_Status
getAllExternalRefs(
const
UT_StringHolder
&
filename
,
141
UT_StringArray
&external_files,
142
const
char
*ext_src =
nullptr
);
143
144
static
const
char
*
const
theDefaultBoundaryString
;
145
146
147
private
:
148
UT_WorkBuffer
myBoundaryText;
149
};
150
151
#endif
UT_MIME_EXTERNAL_OK
Definition:
UT_MIME.h:30
GT_Names::filename
GT_API const UT_StringHolder filename
UT_MIME::getBoundaryText
const UT_WorkBuffer & getBoundaryText() const
Definition:
UT_MIME.h:131
UT_StringMap
Definition:
GEO_Detail.h:53
UT_WorkBuffer
Definition:
UT_WorkBuffer.h:74
UT_MIME::TextFilter::myFilter
TextFilterFunc myFilter
Definition:
UT_MIME.h:93
UT_IStream
Definition:
UT_IStream.h:56
path
GLsizei const GLchar *const * path
Definition:
glcorearb.h:3341
exint
int64 exint
Definition:
SYS_Types.h:125
UT_MIME_USER_ABORT
Definition:
UT_MIME.h:36
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
UT_MIME::TextFilterList
UT_StringMap< TextFilter > TextFilterList
Map of section name pattern to a text filter.
Definition:
UT_MIME.h:102
close
void close() override
UT_MIME::TextFilter::myFilterData
void * myFilterData
Definition:
UT_MIME.h:94
UT_MIME::close
void close(UT_IStream &is)
Definition:
UT_MIME.h:58
UT_MIME_BINARY
Definition:
UT_MIME.h:31
UT_StringHolder
Definition:
UT_StringHolder.h:999
UT_MIME_Status
UT_MIME_Status
Definition:
UT_MIME.h:26
UT_MIME::TextFilter::TextFilter
TextFilter(TextFilterFunc filter, void *filterData)
Definition:
UT_MIME.h:96
UT_StringArray
Definition:
UT_StringArray.h:24
SYS_Types.h
UT_MIME_OK
Definition:
UT_MIME.h:28
open
int open(float queuesize) override
UT_WorkBuffer.h
UT_MIME
Definition:
UT_MIME.h:39
UT_MIME_BAD_EOF
Definition:
UT_MIME.h:32
UT_MIME::TextFilter
Definition:
UT_MIME.h:91
UT_MIME_BAD_CONTENTS
Definition:
UT_MIME.h:34
UT_MIME_EOF_OK
Definition:
UT_MIME.h:29
UT_StringHolder.h
UT_MIME_ERROR
Definition:
UT_MIME.h:27
UT_MIME_BAD_HEADER
Definition:
UT_MIME.h:33
UT_String
Definition:
UT_String.h:73
UT_MIME_BAD_STREAM
Definition:
UT_MIME.h:35
UT_MIME::theDefaultBoundaryString
static const char *const theDefaultBoundaryString
Definition:
UT_MIME.h:144
UT_StringMap.h
data
Definition:
format.h:895
filter
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition:
glcorearb.h:1297
UT
UT_MIME.h
Generated on Tue Dec 17 2024 03:42:14 for HDK by
1.8.6