Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef MOZILLA_GFX_RECORDINGTYPES_H_
7 : #define MOZILLA_GFX_RECORDINGTYPES_H_
8 :
9 : #include <ostream>
10 :
11 : namespace mozilla {
12 : namespace gfx {
13 :
14 : template<class S, class T>
15 : struct ElementStreamFormat
16 : {
17 0 : static void Write(S &aStream, const T &aElement)
18 : {
19 0 : aStream.write(reinterpret_cast<const char*>(&aElement), sizeof(T));
20 0 : }
21 0 : static void Read(S &aStream, T &aElement)
22 : {
23 0 : aStream.read(reinterpret_cast<char *>(&aElement), sizeof(T));
24 0 : }
25 : };
26 :
27 : template<class S, class T>
28 0 : void WriteElement(S &aStream, const T &aElement)
29 : {
30 0 : ElementStreamFormat<S, T>::Write(aStream, aElement);
31 0 : }
32 : template<class S, class T>
33 0 : void ReadElement(S &aStream, T &aElement)
34 : {
35 0 : ElementStreamFormat<S, T>::Read(aStream, aElement);
36 0 : }
37 :
38 : } // namespace gfx
39 : } // namespace mozilla
40 :
41 : #endif /* MOZILLA_GFX_RECORDINGTYPES_H_ */
|