FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
libdiffpy/src/diffpy/serialization.ipp at develop · cfarrow/libdiffpy · GitHub
cfarrow
libdiffpy
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
libdiffpy
/
src
/
diffpy
/
serialization.ipp
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (64 loc) · 2.34 KB
Breadcrumbs
libdiffpy
/
src
/
diffpy
/
serialization.ipp
Copy path
File metadata and controls
78 lines (64 loc) · 2.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
****************************************************************************
*
* diffpy.srreal Complex Modeling Initiative
* Pavol Juhas
* (c) 2013 Brookhaven National Laboratory,
* Upton, New York. All rights reserved.
*
* File coded by: Pavol Juhas
*
* See AUTHORS.txt for a list of people who contributed.
* See LICENSE.txt for license information.
*
******************************************************************************
*
* Implementation of template functions declared in diffpy/serialization.hpp:
*
* diffpy::serialization_tostring
* diffpy::serialization_fromstring
*
* Definition of macros for explicit instantiation of serialization_tostring
* and serialization_fromstring for type C or type boost::shared_ptr<C>.
*
* DIFFPY_INSTANTIATE_SERIALIZATION(C)
* DIFFPY_INSTANTIATE_PTR_SERIALIZATION(C)
*
****************************************************************************
*/
#
ifndef
SERIALIZATION_IPP_INCLUDED
#
define
SERIALIZATION_IPP_INCLUDED
#
include
<
sstream
>
#
include
<
boost/shared_ptr.hpp
>
#
include
<
diffpy/serialization.hpp
>
namespace
diffpy
{
//
Template functions --------------------------------------------------------
template
<
class
T
>
std::string
serialization_tostring
(
const
T& tobj)
{
std::ostringstream
storage
(std::ios::binary);
serialization::oarchive
oa
(storage, std::ios::binary);
oa << tobj;
return
storage.
str
();
}
template
<
class
T
>
void
serialization_fromstring
(T& tobj,
const
std::string& s)
{
std::istringstream
storage
(s, std::ios::binary);
serialization::iarchive
ia
(storage, std::ios::binary);
ia >> tobj;
}
}
//
namespace diffpy
//
Macros --------------------------------------------------------------------
//
/ Insert explicit instantiations for serialization_tostring and
//
/ serialization_fromstring for class C.
#
define
DIFFPY_INSTANTIATE_SERIALIZATION
(
C
) \
template
\
std::string \
diffpy::serialization_tostring<C>(
const
C&); \
template
\
void
\
diffpy::serialization_fromstring<C>(C&,
const
std::string&); \
//
/ Insert explicit instantiations for serialization_tostring and
//
/ serialization_fromstring for type boost::shared_ptr<C>.
#
define
DIFFPY_INSTANTIATE_PTR_SERIALIZATION
(
C
) \
DIFFPY_INSTANTIATE_SERIALIZATION
(boost::shared_ptr<C>)
#
endif
//
SERIALIZATION_IPP_INCLUDED
Back
|
FazBrowse Home
|
New Git URL