isotree 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/LICENSE.txt +2 -1
- data/README.md +57 -6
- data/ext/isotree/ext.cpp +170 -39
- data/ext/isotree/extconf.rb +3 -3
- data/lib/isotree.rb +2 -0
- data/lib/isotree/dataset.rb +73 -0
- data/lib/isotree/isolation_forest.rb +182 -29
- data/lib/isotree/version.rb +1 -1
- data/vendor/cereal/LICENSE +24 -0
- data/vendor/cereal/README.md +85 -0
- data/vendor/cereal/include/cereal/access.hpp +351 -0
- data/vendor/cereal/include/cereal/archives/adapters.hpp +163 -0
- data/vendor/cereal/include/cereal/archives/binary.hpp +169 -0
- data/vendor/cereal/include/cereal/archives/json.hpp +1019 -0
- data/vendor/cereal/include/cereal/archives/portable_binary.hpp +334 -0
- data/vendor/cereal/include/cereal/archives/xml.hpp +956 -0
- data/vendor/cereal/include/cereal/cereal.hpp +1089 -0
- data/vendor/cereal/include/cereal/details/helpers.hpp +422 -0
- data/vendor/cereal/include/cereal/details/polymorphic_impl.hpp +796 -0
- data/vendor/cereal/include/cereal/details/polymorphic_impl_fwd.hpp +65 -0
- data/vendor/cereal/include/cereal/details/static_object.hpp +127 -0
- data/vendor/cereal/include/cereal/details/traits.hpp +1411 -0
- data/vendor/cereal/include/cereal/details/util.hpp +84 -0
- data/vendor/cereal/include/cereal/external/base64.hpp +134 -0
- data/vendor/cereal/include/cereal/external/rapidjson/allocators.h +284 -0
- data/vendor/cereal/include/cereal/external/rapidjson/cursorstreamwrapper.h +78 -0
- data/vendor/cereal/include/cereal/external/rapidjson/document.h +2652 -0
- data/vendor/cereal/include/cereal/external/rapidjson/encodedstream.h +299 -0
- data/vendor/cereal/include/cereal/external/rapidjson/encodings.h +716 -0
- data/vendor/cereal/include/cereal/external/rapidjson/error/en.h +74 -0
- data/vendor/cereal/include/cereal/external/rapidjson/error/error.h +161 -0
- data/vendor/cereal/include/cereal/external/rapidjson/filereadstream.h +99 -0
- data/vendor/cereal/include/cereal/external/rapidjson/filewritestream.h +104 -0
- data/vendor/cereal/include/cereal/external/rapidjson/fwd.h +151 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/biginteger.h +290 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/diyfp.h +271 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/dtoa.h +245 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/ieee754.h +78 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/itoa.h +308 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/meta.h +186 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/pow10.h +55 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/regex.h +740 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/stack.h +232 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/strfunc.h +69 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/strtod.h +290 -0
- data/vendor/cereal/include/cereal/external/rapidjson/internal/swap.h +46 -0
- data/vendor/cereal/include/cereal/external/rapidjson/istreamwrapper.h +128 -0
- data/vendor/cereal/include/cereal/external/rapidjson/memorybuffer.h +70 -0
- data/vendor/cereal/include/cereal/external/rapidjson/memorystream.h +71 -0
- data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/inttypes.h +316 -0
- data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/stdint.h +300 -0
- data/vendor/cereal/include/cereal/external/rapidjson/ostreamwrapper.h +81 -0
- data/vendor/cereal/include/cereal/external/rapidjson/pointer.h +1414 -0
- data/vendor/cereal/include/cereal/external/rapidjson/prettywriter.h +277 -0
- data/vendor/cereal/include/cereal/external/rapidjson/rapidjson.h +656 -0
- data/vendor/cereal/include/cereal/external/rapidjson/reader.h +2230 -0
- data/vendor/cereal/include/cereal/external/rapidjson/schema.h +2497 -0
- data/vendor/cereal/include/cereal/external/rapidjson/stream.h +223 -0
- data/vendor/cereal/include/cereal/external/rapidjson/stringbuffer.h +121 -0
- data/vendor/cereal/include/cereal/external/rapidjson/writer.h +709 -0
- data/vendor/cereal/include/cereal/external/rapidxml/license.txt +52 -0
- data/vendor/cereal/include/cereal/external/rapidxml/manual.html +406 -0
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml.hpp +2624 -0
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_iterators.hpp +175 -0
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_print.hpp +428 -0
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_utils.hpp +123 -0
- data/vendor/cereal/include/cereal/macros.hpp +154 -0
- data/vendor/cereal/include/cereal/specialize.hpp +139 -0
- data/vendor/cereal/include/cereal/types/array.hpp +79 -0
- data/vendor/cereal/include/cereal/types/atomic.hpp +55 -0
- data/vendor/cereal/include/cereal/types/base_class.hpp +203 -0
- data/vendor/cereal/include/cereal/types/bitset.hpp +176 -0
- data/vendor/cereal/include/cereal/types/boost_variant.hpp +164 -0
- data/vendor/cereal/include/cereal/types/chrono.hpp +72 -0
- data/vendor/cereal/include/cereal/types/common.hpp +129 -0
- data/vendor/cereal/include/cereal/types/complex.hpp +56 -0
- data/vendor/cereal/include/cereal/types/concepts/pair_associative_container.hpp +73 -0
- data/vendor/cereal/include/cereal/types/deque.hpp +62 -0
- data/vendor/cereal/include/cereal/types/forward_list.hpp +68 -0
- data/vendor/cereal/include/cereal/types/functional.hpp +43 -0
- data/vendor/cereal/include/cereal/types/list.hpp +62 -0
- data/vendor/cereal/include/cereal/types/map.hpp +36 -0
- data/vendor/cereal/include/cereal/types/memory.hpp +425 -0
- data/vendor/cereal/include/cereal/types/optional.hpp +66 -0
- data/vendor/cereal/include/cereal/types/polymorphic.hpp +483 -0
- data/vendor/cereal/include/cereal/types/queue.hpp +132 -0
- data/vendor/cereal/include/cereal/types/set.hpp +103 -0
- data/vendor/cereal/include/cereal/types/stack.hpp +76 -0
- data/vendor/cereal/include/cereal/types/string.hpp +61 -0
- data/vendor/cereal/include/cereal/types/tuple.hpp +123 -0
- data/vendor/cereal/include/cereal/types/unordered_map.hpp +36 -0
- data/vendor/cereal/include/cereal/types/unordered_set.hpp +99 -0
- data/vendor/cereal/include/cereal/types/utility.hpp +47 -0
- data/vendor/cereal/include/cereal/types/valarray.hpp +89 -0
- data/vendor/cereal/include/cereal/types/variant.hpp +109 -0
- data/vendor/cereal/include/cereal/types/vector.hpp +112 -0
- data/vendor/cereal/include/cereal/version.hpp +52 -0
- data/vendor/isotree/LICENSE +1 -1
- data/vendor/isotree/README.md +7 -2
- data/vendor/isotree/src/RcppExports.cpp +44 -4
- data/vendor/isotree/src/Rwrapper.cpp +141 -51
- data/vendor/isotree/src/crit.cpp +1 -1
- data/vendor/isotree/src/dealloc.cpp +1 -1
- data/vendor/isotree/src/dist.cpp +6 -6
- data/vendor/isotree/src/extended.cpp +5 -5
- data/vendor/isotree/src/fit_model.cpp +27 -5
- data/vendor/isotree/src/helpers_iforest.cpp +26 -11
- data/vendor/isotree/src/impute.cpp +7 -7
- data/vendor/isotree/src/isoforest.cpp +7 -7
- data/vendor/isotree/src/isotree.hpp +27 -5
- data/vendor/isotree/src/merge_models.cpp +1 -1
- data/vendor/isotree/src/mult.cpp +1 -1
- data/vendor/isotree/src/predict.cpp +20 -16
- data/vendor/isotree/src/serialize.cpp +1 -1
- data/vendor/isotree/src/sql.cpp +545 -0
- data/vendor/isotree/src/utils.cpp +36 -44
- metadata +102 -81
@@ -0,0 +1,132 @@
|
|
1
|
+
/*! \file queue.hpp
|
2
|
+
\brief Support for types found in \<queue\>
|
3
|
+
\ingroup STLSupport */
|
4
|
+
/*
|
5
|
+
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
* Neither the name of cereal nor the
|
16
|
+
names of its contributors may be used to endorse or promote products
|
17
|
+
derived from this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
26
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
#ifndef CEREAL_TYPES_QUEUE_HPP_
|
31
|
+
#define CEREAL_TYPES_QUEUE_HPP_
|
32
|
+
|
33
|
+
#include "cereal/details/helpers.hpp"
|
34
|
+
#include <queue>
|
35
|
+
|
36
|
+
// The default container for queue is deque, so let's include that too
|
37
|
+
#include "cereal/types/deque.hpp"
|
38
|
+
// The default comparator for queue is less
|
39
|
+
#include "cereal/types/functional.hpp"
|
40
|
+
|
41
|
+
namespace cereal
|
42
|
+
{
|
43
|
+
namespace queue_detail
|
44
|
+
{
|
45
|
+
//! Allows access to the protected container in queue
|
46
|
+
/*! @internal */
|
47
|
+
template <class T, class C> inline
|
48
|
+
C const & container( std::queue<T, C> const & queue )
|
49
|
+
{
|
50
|
+
struct H : public std::queue<T, C>
|
51
|
+
{
|
52
|
+
static C const & get( std::queue<T, C> const & q )
|
53
|
+
{
|
54
|
+
return q.*(&H::c);
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
return H::get( queue );
|
59
|
+
}
|
60
|
+
|
61
|
+
//! Allows access to the protected container in priority queue
|
62
|
+
/*! @internal */
|
63
|
+
template <class T, class C, class Comp> inline
|
64
|
+
C const & container( std::priority_queue<T, C, Comp> const & priority_queue )
|
65
|
+
{
|
66
|
+
struct H : public std::priority_queue<T, C, Comp>
|
67
|
+
{
|
68
|
+
static C const & get( std::priority_queue<T, C, Comp> const & pq )
|
69
|
+
{
|
70
|
+
return pq.*(&H::c);
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
return H::get( priority_queue );
|
75
|
+
}
|
76
|
+
|
77
|
+
//! Allows access to the protected comparator in priority queue
|
78
|
+
/*! @internal */
|
79
|
+
template <class T, class C, class Comp> inline
|
80
|
+
Comp const & comparator( std::priority_queue<T, C, Comp> const & priority_queue )
|
81
|
+
{
|
82
|
+
struct H : public std::priority_queue<T, C, Comp>
|
83
|
+
{
|
84
|
+
static Comp const & get( std::priority_queue<T, C, Comp> const & pq )
|
85
|
+
{
|
86
|
+
return pq.*(&H::comp);
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
return H::get( priority_queue );
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
//! Saving for std::queue
|
95
|
+
template <class Archive, class T, class C> inline
|
96
|
+
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::queue<T, C> const & queue )
|
97
|
+
{
|
98
|
+
ar( CEREAL_NVP_("container", queue_detail::container( queue )) );
|
99
|
+
}
|
100
|
+
|
101
|
+
//! Loading for std::queue
|
102
|
+
template <class Archive, class T, class C> inline
|
103
|
+
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::queue<T, C> & queue )
|
104
|
+
{
|
105
|
+
C container;
|
106
|
+
ar( CEREAL_NVP_("container", container) );
|
107
|
+
queue = std::queue<T, C>( std::move( container ) );
|
108
|
+
}
|
109
|
+
|
110
|
+
//! Saving for std::priority_queue
|
111
|
+
template <class Archive, class T, class C, class Comp> inline
|
112
|
+
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::priority_queue<T, C, Comp> const & priority_queue )
|
113
|
+
{
|
114
|
+
ar( CEREAL_NVP_("comparator", queue_detail::comparator( priority_queue )) );
|
115
|
+
ar( CEREAL_NVP_("container", queue_detail::container( priority_queue )) );
|
116
|
+
}
|
117
|
+
|
118
|
+
//! Loading for std::priority_queue
|
119
|
+
template <class Archive, class T, class C, class Comp> inline
|
120
|
+
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::priority_queue<T, C, Comp> & priority_queue )
|
121
|
+
{
|
122
|
+
Comp comparator;
|
123
|
+
ar( CEREAL_NVP_("comparator", comparator) );
|
124
|
+
|
125
|
+
C container;
|
126
|
+
ar( CEREAL_NVP_("container", container) );
|
127
|
+
|
128
|
+
priority_queue = std::priority_queue<T, C, Comp>( comparator, std::move( container ) );
|
129
|
+
}
|
130
|
+
} // namespace cereal
|
131
|
+
|
132
|
+
#endif // CEREAL_TYPES_QUEUE_HPP_
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/*! \file set.hpp
|
2
|
+
\brief Support for types found in \<set\>
|
3
|
+
\ingroup STLSupport */
|
4
|
+
/*
|
5
|
+
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
* Neither the name of cereal nor the
|
16
|
+
names of its contributors may be used to endorse or promote products
|
17
|
+
derived from this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
26
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
#ifndef CEREAL_TYPES_SET_HPP_
|
31
|
+
#define CEREAL_TYPES_SET_HPP_
|
32
|
+
|
33
|
+
#include "cereal/cereal.hpp"
|
34
|
+
#include <set>
|
35
|
+
|
36
|
+
namespace cereal
|
37
|
+
{
|
38
|
+
namespace set_detail
|
39
|
+
{
|
40
|
+
//! @internal
|
41
|
+
template <class Archive, class SetT> inline
|
42
|
+
void save( Archive & ar, SetT const & set )
|
43
|
+
{
|
44
|
+
ar( make_size_tag( static_cast<size_type>(set.size()) ) );
|
45
|
+
|
46
|
+
for( const auto & i : set )
|
47
|
+
ar( i );
|
48
|
+
}
|
49
|
+
|
50
|
+
//! @internal
|
51
|
+
template <class Archive, class SetT> inline
|
52
|
+
void load( Archive & ar, SetT & set )
|
53
|
+
{
|
54
|
+
size_type size;
|
55
|
+
ar( make_size_tag( size ) );
|
56
|
+
|
57
|
+
set.clear();
|
58
|
+
|
59
|
+
auto hint = set.begin();
|
60
|
+
for( size_type i = 0; i < size; ++i )
|
61
|
+
{
|
62
|
+
typename SetT::key_type key;
|
63
|
+
|
64
|
+
ar( key );
|
65
|
+
#ifdef CEREAL_OLDER_GCC
|
66
|
+
hint = set.insert( hint, std::move( key ) );
|
67
|
+
#else // NOT CEREAL_OLDER_GCC
|
68
|
+
hint = set.emplace_hint( hint, std::move( key ) );
|
69
|
+
#endif // NOT CEREAL_OLDER_GCC
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
//! Saving for std::set
|
75
|
+
template <class Archive, class K, class C, class A> inline
|
76
|
+
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::set<K, C, A> const & set )
|
77
|
+
{
|
78
|
+
set_detail::save( ar, set );
|
79
|
+
}
|
80
|
+
|
81
|
+
//! Loading for std::set
|
82
|
+
template <class Archive, class K, class C, class A> inline
|
83
|
+
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::set<K, C, A> & set )
|
84
|
+
{
|
85
|
+
set_detail::load( ar, set );
|
86
|
+
}
|
87
|
+
|
88
|
+
//! Saving for std::multiset
|
89
|
+
template <class Archive, class K, class C, class A> inline
|
90
|
+
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multiset<K, C, A> const & multiset )
|
91
|
+
{
|
92
|
+
set_detail::save( ar, multiset );
|
93
|
+
}
|
94
|
+
|
95
|
+
//! Loading for std::multiset
|
96
|
+
template <class Archive, class K, class C, class A> inline
|
97
|
+
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multiset<K, C, A> & multiset )
|
98
|
+
{
|
99
|
+
set_detail::load( ar, multiset );
|
100
|
+
}
|
101
|
+
} // namespace cereal
|
102
|
+
|
103
|
+
#endif // CEREAL_TYPES_SET_HPP_
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/*! \file stack.hpp
|
2
|
+
\brief Support for types found in \<stack\>
|
3
|
+
\ingroup STLSupport */
|
4
|
+
/*
|
5
|
+
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
* Neither the name of cereal nor the
|
16
|
+
names of its contributors may be used to endorse or promote products
|
17
|
+
derived from this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
26
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
#ifndef CEREAL_TYPES_STACK_HPP_
|
31
|
+
#define CEREAL_TYPES_STACK_HPP_
|
32
|
+
|
33
|
+
#include "cereal/cereal.hpp"
|
34
|
+
#include <stack>
|
35
|
+
|
36
|
+
// The default container for stack is deque, so let's include that too
|
37
|
+
#include "cereal/types/deque.hpp"
|
38
|
+
|
39
|
+
namespace cereal
|
40
|
+
{
|
41
|
+
namespace stack_detail
|
42
|
+
{
|
43
|
+
//! Allows access to the protected container in stack
|
44
|
+
template <class T, class C> inline
|
45
|
+
C const & container( std::stack<T, C> const & stack )
|
46
|
+
{
|
47
|
+
struct H : public std::stack<T, C>
|
48
|
+
{
|
49
|
+
static C const & get( std::stack<T, C> const & s )
|
50
|
+
{
|
51
|
+
return s.*(&H::c);
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
return H::get( stack );
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
//! Saving for std::stack
|
60
|
+
template <class Archive, class T, class C> inline
|
61
|
+
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::stack<T, C> const & stack )
|
62
|
+
{
|
63
|
+
ar( CEREAL_NVP_("container", stack_detail::container( stack )) );
|
64
|
+
}
|
65
|
+
|
66
|
+
//! Loading for std::stack
|
67
|
+
template <class Archive, class T, class C> inline
|
68
|
+
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::stack<T, C> & stack )
|
69
|
+
{
|
70
|
+
C container;
|
71
|
+
ar( CEREAL_NVP_("container", container) );
|
72
|
+
stack = std::stack<T, C>( std::move( container ) );
|
73
|
+
}
|
74
|
+
} // namespace cereal
|
75
|
+
|
76
|
+
#endif // CEREAL_TYPES_STACK_HPP_
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*! \file string.hpp
|
2
|
+
\brief Support for types found in \<string\>
|
3
|
+
\ingroup STLSupport */
|
4
|
+
/*
|
5
|
+
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
* Neither the name of cereal nor the
|
16
|
+
names of its contributors may be used to endorse or promote products
|
17
|
+
derived from this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
26
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
#ifndef CEREAL_TYPES_STRING_HPP_
|
31
|
+
#define CEREAL_TYPES_STRING_HPP_
|
32
|
+
|
33
|
+
#include "cereal/cereal.hpp"
|
34
|
+
#include <string>
|
35
|
+
|
36
|
+
namespace cereal
|
37
|
+
{
|
38
|
+
//! Serialization for basic_string types, if binary data is supported
|
39
|
+
template<class Archive, class CharT, class Traits, class Alloc> inline
|
40
|
+
typename std::enable_if<traits::is_output_serializable<BinaryData<CharT>, Archive>::value, void>::type
|
41
|
+
CEREAL_SAVE_FUNCTION_NAME(Archive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
|
42
|
+
{
|
43
|
+
// Save number of chars + the data
|
44
|
+
ar( make_size_tag( static_cast<size_type>(str.size()) ) );
|
45
|
+
ar( binary_data( str.data(), str.size() * sizeof(CharT) ) );
|
46
|
+
}
|
47
|
+
|
48
|
+
//! Serialization for basic_string types, if binary data is supported
|
49
|
+
template<class Archive, class CharT, class Traits, class Alloc> inline
|
50
|
+
typename std::enable_if<traits::is_input_serializable<BinaryData<CharT>, Archive>::value, void>::type
|
51
|
+
CEREAL_LOAD_FUNCTION_NAME(Archive & ar, std::basic_string<CharT, Traits, Alloc> & str)
|
52
|
+
{
|
53
|
+
size_type size;
|
54
|
+
ar( make_size_tag( size ) );
|
55
|
+
str.resize(static_cast<std::size_t>(size));
|
56
|
+
ar( binary_data( const_cast<CharT *>( str.data() ), static_cast<std::size_t>(size) * sizeof(CharT) ) );
|
57
|
+
}
|
58
|
+
} // namespace cereal
|
59
|
+
|
60
|
+
#endif // CEREAL_TYPES_STRING_HPP_
|
61
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
/*! \file tuple.hpp
|
2
|
+
\brief Support for types found in \<tuple\>
|
3
|
+
\ingroup STLSupport */
|
4
|
+
/*
|
5
|
+
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
* Neither the name of cereal nor the
|
16
|
+
names of its contributors may be used to endorse or promote products
|
17
|
+
derived from this software without specific prior written permission.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
26
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
#ifndef CEREAL_TYPES_TUPLE_HPP_
|
31
|
+
#define CEREAL_TYPES_TUPLE_HPP_
|
32
|
+
|
33
|
+
#include "cereal/cereal.hpp"
|
34
|
+
#include <tuple>
|
35
|
+
|
36
|
+
namespace cereal
|
37
|
+
{
|
38
|
+
namespace tuple_detail
|
39
|
+
{
|
40
|
+
//! Creates a c string from a sequence of characters
|
41
|
+
/*! The c string created will always be prefixed by "tuple_element"
|
42
|
+
Based on code from: http://stackoverflow/a/20973438/710791
|
43
|
+
@internal */
|
44
|
+
template<char...Cs>
|
45
|
+
struct char_seq_to_c_str
|
46
|
+
{
|
47
|
+
static const int size = 14;// Size of array for the word: tuple_element
|
48
|
+
typedef const char (&arr_type)[sizeof...(Cs) + size];
|
49
|
+
static const char str[sizeof...(Cs) + size];
|
50
|
+
};
|
51
|
+
|
52
|
+
// the word tuple_element plus a number
|
53
|
+
//! @internal
|
54
|
+
template<char...Cs>
|
55
|
+
const char char_seq_to_c_str<Cs...>::str[sizeof...(Cs) + size] =
|
56
|
+
{'t','u','p','l','e','_','e','l','e','m','e','n','t', Cs..., '\0'};
|
57
|
+
|
58
|
+
//! Converts a number into a sequence of characters
|
59
|
+
/*! @tparam Q The quotient of dividing the original number by 10
|
60
|
+
@tparam R The remainder of dividing the original number by 10
|
61
|
+
@tparam C The sequence built so far
|
62
|
+
@internal */
|
63
|
+
template <size_t Q, size_t R, char ... C>
|
64
|
+
struct to_string_impl
|
65
|
+
{
|
66
|
+
using type = typename to_string_impl<Q/10, Q%10, static_cast<char>(R+std::size_t{'0'}), C...>::type;
|
67
|
+
};
|
68
|
+
|
69
|
+
//! Base case with no quotient
|
70
|
+
/*! @internal */
|
71
|
+
template <size_t R, char ... C>
|
72
|
+
struct to_string_impl<0, R, C...>
|
73
|
+
{
|
74
|
+
using type = char_seq_to_c_str<static_cast<char>(R+std::size_t{'0'}), C...>;
|
75
|
+
};
|
76
|
+
|
77
|
+
//! Generates a c string for a given index of a tuple
|
78
|
+
/*! Example use:
|
79
|
+
@code{cpp}
|
80
|
+
tuple_element_name<3>::c_str();// returns "tuple_element3"
|
81
|
+
@endcode
|
82
|
+
@internal */
|
83
|
+
template<size_t T>
|
84
|
+
struct tuple_element_name
|
85
|
+
{
|
86
|
+
using type = typename to_string_impl<T/10, T%10>::type;
|
87
|
+
static const typename type::arr_type c_str(){ return type::str; }
|
88
|
+
};
|
89
|
+
|
90
|
+
// unwinds a tuple to save it
|
91
|
+
//! @internal
|
92
|
+
template <size_t Height>
|
93
|
+
struct serialize
|
94
|
+
{
|
95
|
+
template <class Archive, class ... Types> inline
|
96
|
+
static void apply( Archive & ar, std::tuple<Types...> & tuple )
|
97
|
+
{
|
98
|
+
serialize<Height - 1>::template apply( ar, tuple );
|
99
|
+
ar( CEREAL_NVP_(tuple_element_name<Height - 1>::c_str(),
|
100
|
+
std::get<Height - 1>( tuple )) );
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
104
|
+
// Zero height specialization - nothing to do here
|
105
|
+
//! @internal
|
106
|
+
template <>
|
107
|
+
struct serialize<0>
|
108
|
+
{
|
109
|
+
template <class Archive, class ... Types> inline
|
110
|
+
static void apply( Archive &, std::tuple<Types...> & )
|
111
|
+
{ }
|
112
|
+
};
|
113
|
+
}
|
114
|
+
|
115
|
+
//! Serializing for std::tuple
|
116
|
+
template <class Archive, class ... Types> inline
|
117
|
+
void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::tuple<Types...> & tuple )
|
118
|
+
{
|
119
|
+
tuple_detail::serialize<std::tuple_size<std::tuple<Types...>>::value>::template apply( ar, tuple );
|
120
|
+
}
|
121
|
+
} // namespace cereal
|
122
|
+
|
123
|
+
#endif // CEREAL_TYPES_TUPLE_HPP_
|