summaryrefslogtreecommitdiffstats
path: root/public/sdk/inc/serialz.h
blob: 51702ba99ddba1f9851c57962991c91dd49b7aeb (plain) (blame)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//+---------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1992.
//
//  File:	serialz.h
//
//  Contents:	Standard serialisation/deserialisation functions, designed
//		as helpers for implementators of IPersistStream.
//
//  Functions:	SerializeToStream
//		DeserializeFromStream
//		SerializeSizeMax
//
//  History:	19-May-93       MikeSe  Created
//
//  WARNING! The format in which the serialised data is written is highly
//	     likely to change before ship.
//
//----------------------------------------------------------------------------

#ifndef __SERIALZ_H__
#define __SERIALZ_H__

// BUGBUG: coming soon in COMPOBJ?
# ifndef STDAPIV
#  define STDAPIV EXTERN_C HRESULT __export _cdecl
# endif

//+-------------------------------------------------------------------------
//
//  Function:   SerializeToStream
//
//  Synopsis:   printf-style serialisation function.
//
//  Effects:    Writes a set of arguments to a stream in serialised form.
//
//  Arguments:  [pstm]		-- stream to write to
//		[pszFormat]	-- format control string
//		...		-- arguments to serialise.
//
//  Returns:    storage errors (often STG_E_MEDIUMFULL)
//		E_INVALIDARG if the format string contains illegal characters
//
//  Modifies:   the stream pointer is advanced to exactly beyond the
//		last byte written.
//
//  Notes:      The format control string consists of a series of single
//		characters specifying the type of the corresponding argument
//		in the variable part of the argument list, as indicated in
//		the following table:
//
//		control character		argument type
//
//			1			char/unsigned char
//			2			short/unsigned short
//			4			long/unsigned long
//			8			huge(LARGE_INTEGER/LONGLONG)
//			t			FILETIME
//			f			float
//			d			double
//			w			WCHAR * (null terminated)
//			s			char * (null terminated)
//			g			GUID *
//			b			BLOB *
//
// 	Please note that FILETIME should not be treated as a 64 bit integer
//	(control "8") because of differing alignment requirements on
//	RISC platforms.
//
//--------------------------------------------------------------------------

STDAPIV SerializeToStream ( IStream * pstm, const char * pszFormat, ... );

//+-------------------------------------------------------------------------
//
//  Function:   DeserializeFromStream
//
//  Synopsis:   scanf-style deserialisation function.
//
//  Effects:    Reads a set of arguments from a stream.
//
//  Arguments:  [pstm]		-- stream to read from
//		[pszFormat]	-- format control string
//		...		-- outputs.
//
//  Returns:    storage errors
//		E_FAIL to indicate end of file
//		E_INVALIDARG if the format string contains illegal characters
//
//  Modifies:   the stream pointer is advanced to exactly beyond the
//		last byte read.
//
//  Notes:      The format control string consists of a series of single
//		characters specifying the type of the corresponding argument
//		in the variable part of the argument list, as indicated in
//		the following table:
//
//		control character		argument type
//
//			1			char*/unsigned char*
//			2			short*/unsigned short*
//			4			long*/unsigned long*
//			8			huge*/FILETIME*
//			f			float*
//			d			double*
//			w			WCHAR** (null terminated)
//			s			char** (null terminated)
//			g			GUID *
//			b			BLOB *
//
//		String arguments are callee-allocated via IMalloc.
//
//		When deserialising BLOBs the BLOB structure is allocated
//		by the caller, and the callee allocates the memory
//		pointed to by the the BLOB::pBlobData field, unless the
//		byte count for the BLOB is zero, in which case pBlobData
//		is set to NULL.
//
//--------------------------------------------------------------------------

STDAPIV DeserializeFromStream ( IStream * pstm, const char * pszFormat, ... );

//+-------------------------------------------------------------------------
//
//  Function:   SerializeSizeMax
//
//  Synopsis:   returns an upper bound on the amount of space required
//		to serialise a set of data.
//
//  Arguments:	[pszFormat]	-- format control string
//		[pcbSize]	-- returned size
//		...		-- arguments to serialise.
//
//  Returns:	E_INVALIDARG if the format string contains illegal characters
//
//  Notes:      The format control string and variable arguments are exactly
//		as passed to SerializeToStream.
//
//--------------------------------------------------------------------------

STDAPIV SerializeSizeMax ( const char * pszFormat, ULARGE_INTEGER *pcbSize, ... );

#endif	// of ifndef __SERIALZ_H__