isotree 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/LICENSE.txt +2 -2
- data/README.md +32 -14
- data/ext/isotree/ext.cpp +144 -31
- data/ext/isotree/extconf.rb +7 -7
- data/lib/isotree/isolation_forest.rb +110 -30
- data/lib/isotree/version.rb +1 -1
- data/vendor/isotree/LICENSE +1 -1
- data/vendor/isotree/README.md +165 -27
- data/vendor/isotree/include/isotree.hpp +2111 -0
- data/vendor/isotree/include/isotree_oop.hpp +394 -0
- data/vendor/isotree/inst/COPYRIGHTS +62 -0
- data/vendor/isotree/src/RcppExports.cpp +525 -52
- data/vendor/isotree/src/Rwrapper.cpp +1931 -268
- data/vendor/isotree/src/c_interface.cpp +953 -0
- data/vendor/isotree/src/crit.hpp +4232 -0
- data/vendor/isotree/src/dist.hpp +1886 -0
- data/vendor/isotree/src/exp_depth_table.hpp +134 -0
- data/vendor/isotree/src/extended.hpp +1444 -0
- data/vendor/isotree/src/external_facing_generic.hpp +399 -0
- data/vendor/isotree/src/fit_model.hpp +2401 -0
- data/vendor/isotree/src/{dealloc.cpp → headers_joined.hpp} +38 -22
- data/vendor/isotree/src/helpers_iforest.hpp +813 -0
- data/vendor/isotree/src/{impute.cpp → impute.hpp} +353 -122
- data/vendor/isotree/src/indexer.cpp +515 -0
- data/vendor/isotree/src/instantiate_template_headers.cpp +118 -0
- data/vendor/isotree/src/instantiate_template_headers.hpp +240 -0
- data/vendor/isotree/src/isoforest.hpp +1659 -0
- data/vendor/isotree/src/isotree.hpp +1804 -392
- data/vendor/isotree/src/isotree_exportable.hpp +99 -0
- data/vendor/isotree/src/merge_models.cpp +159 -16
- data/vendor/isotree/src/mult.hpp +1321 -0
- data/vendor/isotree/src/oop_interface.cpp +842 -0
- data/vendor/isotree/src/oop_interface.hpp +278 -0
- data/vendor/isotree/src/other_helpers.hpp +219 -0
- data/vendor/isotree/src/predict.hpp +1932 -0
- data/vendor/isotree/src/python_helpers.hpp +134 -0
- data/vendor/isotree/src/ref_indexer.hpp +154 -0
- data/vendor/isotree/src/robinmap/LICENSE +21 -0
- data/vendor/isotree/src/robinmap/README.md +483 -0
- data/vendor/isotree/src/robinmap/include/tsl/robin_growth_policy.h +406 -0
- data/vendor/isotree/src/robinmap/include/tsl/robin_hash.h +1620 -0
- data/vendor/isotree/src/robinmap/include/tsl/robin_map.h +807 -0
- data/vendor/isotree/src/robinmap/include/tsl/robin_set.h +660 -0
- data/vendor/isotree/src/serialize.cpp +4300 -139
- data/vendor/isotree/src/sql.cpp +141 -59
- data/vendor/isotree/src/subset_models.cpp +174 -0
- data/vendor/isotree/src/utils.hpp +3808 -0
- data/vendor/isotree/src/xoshiro.hpp +467 -0
- data/vendor/isotree/src/ziggurat.hpp +405 -0
- metadata +38 -104
- data/vendor/cereal/LICENSE +0 -24
- data/vendor/cereal/README.md +0 -85
- data/vendor/cereal/include/cereal/access.hpp +0 -351
- data/vendor/cereal/include/cereal/archives/adapters.hpp +0 -163
- data/vendor/cereal/include/cereal/archives/binary.hpp +0 -169
- data/vendor/cereal/include/cereal/archives/json.hpp +0 -1019
- data/vendor/cereal/include/cereal/archives/portable_binary.hpp +0 -334
- data/vendor/cereal/include/cereal/archives/xml.hpp +0 -956
- data/vendor/cereal/include/cereal/cereal.hpp +0 -1089
- data/vendor/cereal/include/cereal/details/helpers.hpp +0 -422
- data/vendor/cereal/include/cereal/details/polymorphic_impl.hpp +0 -796
- data/vendor/cereal/include/cereal/details/polymorphic_impl_fwd.hpp +0 -65
- data/vendor/cereal/include/cereal/details/static_object.hpp +0 -127
- data/vendor/cereal/include/cereal/details/traits.hpp +0 -1411
- data/vendor/cereal/include/cereal/details/util.hpp +0 -84
- data/vendor/cereal/include/cereal/external/base64.hpp +0 -134
- data/vendor/cereal/include/cereal/external/rapidjson/allocators.h +0 -284
- data/vendor/cereal/include/cereal/external/rapidjson/cursorstreamwrapper.h +0 -78
- data/vendor/cereal/include/cereal/external/rapidjson/document.h +0 -2652
- data/vendor/cereal/include/cereal/external/rapidjson/encodedstream.h +0 -299
- data/vendor/cereal/include/cereal/external/rapidjson/encodings.h +0 -716
- data/vendor/cereal/include/cereal/external/rapidjson/error/en.h +0 -74
- data/vendor/cereal/include/cereal/external/rapidjson/error/error.h +0 -161
- data/vendor/cereal/include/cereal/external/rapidjson/filereadstream.h +0 -99
- data/vendor/cereal/include/cereal/external/rapidjson/filewritestream.h +0 -104
- data/vendor/cereal/include/cereal/external/rapidjson/fwd.h +0 -151
- data/vendor/cereal/include/cereal/external/rapidjson/internal/biginteger.h +0 -290
- data/vendor/cereal/include/cereal/external/rapidjson/internal/diyfp.h +0 -271
- data/vendor/cereal/include/cereal/external/rapidjson/internal/dtoa.h +0 -245
- data/vendor/cereal/include/cereal/external/rapidjson/internal/ieee754.h +0 -78
- data/vendor/cereal/include/cereal/external/rapidjson/internal/itoa.h +0 -308
- data/vendor/cereal/include/cereal/external/rapidjson/internal/meta.h +0 -186
- data/vendor/cereal/include/cereal/external/rapidjson/internal/pow10.h +0 -55
- data/vendor/cereal/include/cereal/external/rapidjson/internal/regex.h +0 -740
- data/vendor/cereal/include/cereal/external/rapidjson/internal/stack.h +0 -232
- data/vendor/cereal/include/cereal/external/rapidjson/internal/strfunc.h +0 -69
- data/vendor/cereal/include/cereal/external/rapidjson/internal/strtod.h +0 -290
- data/vendor/cereal/include/cereal/external/rapidjson/internal/swap.h +0 -46
- data/vendor/cereal/include/cereal/external/rapidjson/istreamwrapper.h +0 -128
- data/vendor/cereal/include/cereal/external/rapidjson/memorybuffer.h +0 -70
- data/vendor/cereal/include/cereal/external/rapidjson/memorystream.h +0 -71
- data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/inttypes.h +0 -316
- data/vendor/cereal/include/cereal/external/rapidjson/msinttypes/stdint.h +0 -300
- data/vendor/cereal/include/cereal/external/rapidjson/ostreamwrapper.h +0 -81
- data/vendor/cereal/include/cereal/external/rapidjson/pointer.h +0 -1414
- data/vendor/cereal/include/cereal/external/rapidjson/prettywriter.h +0 -277
- data/vendor/cereal/include/cereal/external/rapidjson/rapidjson.h +0 -656
- data/vendor/cereal/include/cereal/external/rapidjson/reader.h +0 -2230
- data/vendor/cereal/include/cereal/external/rapidjson/schema.h +0 -2497
- data/vendor/cereal/include/cereal/external/rapidjson/stream.h +0 -223
- data/vendor/cereal/include/cereal/external/rapidjson/stringbuffer.h +0 -121
- data/vendor/cereal/include/cereal/external/rapidjson/writer.h +0 -709
- data/vendor/cereal/include/cereal/external/rapidxml/license.txt +0 -52
- data/vendor/cereal/include/cereal/external/rapidxml/manual.html +0 -406
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml.hpp +0 -2624
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_iterators.hpp +0 -175
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_print.hpp +0 -428
- data/vendor/cereal/include/cereal/external/rapidxml/rapidxml_utils.hpp +0 -123
- data/vendor/cereal/include/cereal/macros.hpp +0 -154
- data/vendor/cereal/include/cereal/specialize.hpp +0 -139
- data/vendor/cereal/include/cereal/types/array.hpp +0 -79
- data/vendor/cereal/include/cereal/types/atomic.hpp +0 -55
- data/vendor/cereal/include/cereal/types/base_class.hpp +0 -203
- data/vendor/cereal/include/cereal/types/bitset.hpp +0 -176
- data/vendor/cereal/include/cereal/types/boost_variant.hpp +0 -164
- data/vendor/cereal/include/cereal/types/chrono.hpp +0 -72
- data/vendor/cereal/include/cereal/types/common.hpp +0 -129
- data/vendor/cereal/include/cereal/types/complex.hpp +0 -56
- data/vendor/cereal/include/cereal/types/concepts/pair_associative_container.hpp +0 -73
- data/vendor/cereal/include/cereal/types/deque.hpp +0 -62
- data/vendor/cereal/include/cereal/types/forward_list.hpp +0 -68
- data/vendor/cereal/include/cereal/types/functional.hpp +0 -43
- data/vendor/cereal/include/cereal/types/list.hpp +0 -62
- data/vendor/cereal/include/cereal/types/map.hpp +0 -36
- data/vendor/cereal/include/cereal/types/memory.hpp +0 -425
- data/vendor/cereal/include/cereal/types/optional.hpp +0 -66
- data/vendor/cereal/include/cereal/types/polymorphic.hpp +0 -483
- data/vendor/cereal/include/cereal/types/queue.hpp +0 -132
- data/vendor/cereal/include/cereal/types/set.hpp +0 -103
- data/vendor/cereal/include/cereal/types/stack.hpp +0 -76
- data/vendor/cereal/include/cereal/types/string.hpp +0 -61
- data/vendor/cereal/include/cereal/types/tuple.hpp +0 -123
- data/vendor/cereal/include/cereal/types/unordered_map.hpp +0 -36
- data/vendor/cereal/include/cereal/types/unordered_set.hpp +0 -99
- data/vendor/cereal/include/cereal/types/utility.hpp +0 -47
- data/vendor/cereal/include/cereal/types/valarray.hpp +0 -89
- data/vendor/cereal/include/cereal/types/variant.hpp +0 -109
- data/vendor/cereal/include/cereal/types/vector.hpp +0 -112
- data/vendor/cereal/include/cereal/version.hpp +0 -52
- data/vendor/isotree/src/Makevars +0 -4
- data/vendor/isotree/src/crit.cpp +0 -912
- data/vendor/isotree/src/dist.cpp +0 -749
- data/vendor/isotree/src/extended.cpp +0 -790
- data/vendor/isotree/src/fit_model.cpp +0 -1090
- data/vendor/isotree/src/helpers_iforest.cpp +0 -324
- data/vendor/isotree/src/isoforest.cpp +0 -771
- data/vendor/isotree/src/mult.cpp +0 -607
- data/vendor/isotree/src/predict.cpp +0 -853
- data/vendor/isotree/src/utils.cpp +0 -1566
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
#ifndef CEREAL_RAPIDXML_UTILS_HPP_INCLUDED
|
|
2
|
-
#define CEREAL_RAPIDXML_UTILS_HPP_INCLUDED
|
|
3
|
-
|
|
4
|
-
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
|
5
|
-
// Version 1.13
|
|
6
|
-
// Revision $DateTime: 2009/05/13 01:46:17 $
|
|
7
|
-
//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.
|
|
8
|
-
|
|
9
|
-
#include "rapidxml.hpp"
|
|
10
|
-
#include <vector>
|
|
11
|
-
#include <string>
|
|
12
|
-
#include <fstream>
|
|
13
|
-
#include <stdexcept>
|
|
14
|
-
|
|
15
|
-
namespace cereal {
|
|
16
|
-
namespace rapidxml
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
//! Represents data loaded from a file
|
|
20
|
-
template<class Ch = char>
|
|
21
|
-
class file
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
public:
|
|
25
|
-
|
|
26
|
-
//! Loads file into the memory. Data will be automatically destroyed by the destructor.
|
|
27
|
-
//! \param filename Filename to load.
|
|
28
|
-
file(const char *filename)
|
|
29
|
-
{
|
|
30
|
-
using namespace std;
|
|
31
|
-
|
|
32
|
-
// Open stream
|
|
33
|
-
basic_ifstream<Ch> stream(filename, ios::binary);
|
|
34
|
-
if (!stream)
|
|
35
|
-
throw runtime_error(string("cannot open file ") + filename);
|
|
36
|
-
stream.unsetf(ios::skipws);
|
|
37
|
-
|
|
38
|
-
// Determine stream size
|
|
39
|
-
stream.seekg(0, ios::end);
|
|
40
|
-
size_t size = stream.tellg();
|
|
41
|
-
stream.seekg(0);
|
|
42
|
-
|
|
43
|
-
// Load data and add terminating 0
|
|
44
|
-
m_data.resize(size + 1);
|
|
45
|
-
stream.read(&m_data.front(), static_cast<streamsize>(size));
|
|
46
|
-
m_data[size] = 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//! Loads file into the memory. Data will be automatically destroyed by the destructor
|
|
50
|
-
//! \param stream Stream to load from
|
|
51
|
-
file(std::basic_istream<Ch> &stream)
|
|
52
|
-
{
|
|
53
|
-
using namespace std;
|
|
54
|
-
|
|
55
|
-
// Load data and add terminating 0
|
|
56
|
-
stream.unsetf(ios::skipws);
|
|
57
|
-
m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
|
|
58
|
-
if (stream.fail() || stream.bad())
|
|
59
|
-
throw runtime_error("error reading stream");
|
|
60
|
-
m_data.push_back(0);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//! Gets file data.
|
|
64
|
-
//! \return Pointer to data of file.
|
|
65
|
-
Ch *data()
|
|
66
|
-
{
|
|
67
|
-
return &m_data.front();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
//! Gets file data.
|
|
71
|
-
//! \return Pointer to data of file.
|
|
72
|
-
const Ch *data() const
|
|
73
|
-
{
|
|
74
|
-
return &m_data.front();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//! Gets file data size.
|
|
78
|
-
//! \return Size of file data, in characters.
|
|
79
|
-
std::size_t size() const
|
|
80
|
-
{
|
|
81
|
-
return m_data.size();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private:
|
|
85
|
-
|
|
86
|
-
std::vector<Ch> m_data; // File data
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
//! Counts children of node. Time complexity is O(n).
|
|
91
|
-
//! \return Number of children of node
|
|
92
|
-
template<class Ch>
|
|
93
|
-
inline std::size_t count_children(xml_node<Ch> *node)
|
|
94
|
-
{
|
|
95
|
-
xml_node<Ch> *child = node->first_node();
|
|
96
|
-
std::size_t count = 0;
|
|
97
|
-
while (child)
|
|
98
|
-
{
|
|
99
|
-
++count;
|
|
100
|
-
child = child->next_sibling();
|
|
101
|
-
}
|
|
102
|
-
return count;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//! Counts attributes of node. Time complexity is O(n).
|
|
106
|
-
//! \return Number of attributes of node
|
|
107
|
-
template<class Ch>
|
|
108
|
-
inline std::size_t count_attributes(xml_node<Ch> *node)
|
|
109
|
-
{
|
|
110
|
-
xml_attribute<Ch> *attr = node->first_attribute();
|
|
111
|
-
std::size_t count = 0;
|
|
112
|
-
while (attr)
|
|
113
|
-
{
|
|
114
|
-
++count;
|
|
115
|
-
attr = attr->next_attribute();
|
|
116
|
-
}
|
|
117
|
-
return count;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
} // namespace cereal
|
|
122
|
-
|
|
123
|
-
#endif
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/*! \file macros.hpp
|
|
2
|
-
\brief Preprocessor macros that can customise the cereal library
|
|
3
|
-
|
|
4
|
-
By default, cereal looks for serialization functions with very
|
|
5
|
-
specific names, that is: serialize, load, save, load_minimal,
|
|
6
|
-
or save_minimal.
|
|
7
|
-
|
|
8
|
-
This file allows an advanced user to change these names to conform
|
|
9
|
-
to some other style or preference. This is implemented using
|
|
10
|
-
preprocessor macros.
|
|
11
|
-
|
|
12
|
-
As a result of this, in internal cereal code you will see macros
|
|
13
|
-
used for these function names. In user code, you should name
|
|
14
|
-
the functions like you normally would and not use the macros
|
|
15
|
-
to improve readability.
|
|
16
|
-
\ingroup utility */
|
|
17
|
-
/*
|
|
18
|
-
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
|
19
|
-
All rights reserved.
|
|
20
|
-
|
|
21
|
-
Redistribution and use in source and binary forms, with or without
|
|
22
|
-
modification, are permitted provided that the following conditions are met:
|
|
23
|
-
* Redistributions of source code must retain the above copyright
|
|
24
|
-
notice, this list of conditions and the following disclaimer.
|
|
25
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
26
|
-
notice, this list of conditions and the following disclaimer in the
|
|
27
|
-
documentation and/or other materials provided with the distribution.
|
|
28
|
-
* Neither the name of cereal nor the
|
|
29
|
-
names of its contributors may be used to endorse or promote products
|
|
30
|
-
derived from this software without specific prior written permission.
|
|
31
|
-
|
|
32
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
33
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
34
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
35
|
-
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
|
36
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
37
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
38
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
39
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
40
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
41
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
#ifndef CEREAL_MACROS_HPP_
|
|
45
|
-
#define CEREAL_MACROS_HPP_
|
|
46
|
-
|
|
47
|
-
#ifndef CEREAL_THREAD_SAFE
|
|
48
|
-
//! Whether cereal should be compiled for a threaded environment
|
|
49
|
-
/*! This macro causes cereal to use mutexes to control access to
|
|
50
|
-
global internal state in a thread safe manner.
|
|
51
|
-
|
|
52
|
-
Note that even with this enabled you must still ensure that
|
|
53
|
-
archives are accessed by only one thread at a time; it is safe
|
|
54
|
-
to use multiple archives in paralel, but not to access one archive
|
|
55
|
-
from many places simultaneously. */
|
|
56
|
-
#define CEREAL_THREAD_SAFE 0
|
|
57
|
-
#endif // CEREAL_THREAD_SAFE
|
|
58
|
-
|
|
59
|
-
#ifndef CEREAL_SIZE_TYPE
|
|
60
|
-
//! Determines the data type used for size_type
|
|
61
|
-
/*! cereal uses size_type to ensure that the serialized size of
|
|
62
|
-
dynamic containers is compatible across different architectures
|
|
63
|
-
(e.g. 32 vs 64 bit), which may use different underlying types for
|
|
64
|
-
std::size_t.
|
|
65
|
-
|
|
66
|
-
More information can be found in cereal/details/helpers.hpp.
|
|
67
|
-
|
|
68
|
-
If you choose to modify this type, ensure that you use a fixed
|
|
69
|
-
size type (e.g. uint32_t). */
|
|
70
|
-
#define CEREAL_SIZE_TYPE uint64_t
|
|
71
|
-
#endif // CEREAL_SIZE_TYPE
|
|
72
|
-
|
|
73
|
-
// ######################################################################
|
|
74
|
-
#ifndef CEREAL_SERIALIZE_FUNCTION_NAME
|
|
75
|
-
//! The serialization/deserialization function name to search for.
|
|
76
|
-
/*! You can define @c CEREAL_SERIALIZE_FUNCTION_NAME to be different assuming
|
|
77
|
-
you do so before this file is included. */
|
|
78
|
-
#define CEREAL_SERIALIZE_FUNCTION_NAME serialize
|
|
79
|
-
#endif // CEREAL_SERIALIZE_FUNCTION_NAME
|
|
80
|
-
|
|
81
|
-
#ifndef CEREAL_LOAD_FUNCTION_NAME
|
|
82
|
-
//! The deserialization (load) function name to search for.
|
|
83
|
-
/*! You can define @c CEREAL_LOAD_FUNCTION_NAME to be different assuming you do so
|
|
84
|
-
before this file is included. */
|
|
85
|
-
#define CEREAL_LOAD_FUNCTION_NAME load
|
|
86
|
-
#endif // CEREAL_LOAD_FUNCTION_NAME
|
|
87
|
-
|
|
88
|
-
#ifndef CEREAL_SAVE_FUNCTION_NAME
|
|
89
|
-
//! The serialization (save) function name to search for.
|
|
90
|
-
/*! You can define @c CEREAL_SAVE_FUNCTION_NAME to be different assuming you do so
|
|
91
|
-
before this file is included. */
|
|
92
|
-
#define CEREAL_SAVE_FUNCTION_NAME save
|
|
93
|
-
#endif // CEREAL_SAVE_FUNCTION_NAME
|
|
94
|
-
|
|
95
|
-
#ifndef CEREAL_LOAD_MINIMAL_FUNCTION_NAME
|
|
96
|
-
//! The deserialization (load_minimal) function name to search for.
|
|
97
|
-
/*! You can define @c CEREAL_LOAD_MINIMAL_FUNCTION_NAME to be different assuming you do so
|
|
98
|
-
before this file is included. */
|
|
99
|
-
#define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
|
|
100
|
-
#endif // CEREAL_LOAD_MINIMAL_FUNCTION_NAME
|
|
101
|
-
|
|
102
|
-
#ifndef CEREAL_SAVE_MINIMAL_FUNCTION_NAME
|
|
103
|
-
//! The serialization (save_minimal) function name to search for.
|
|
104
|
-
/*! You can define @c CEREAL_SAVE_MINIMAL_FUNCTION_NAME to be different assuming you do so
|
|
105
|
-
before this file is included. */
|
|
106
|
-
#define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
|
|
107
|
-
#endif // CEREAL_SAVE_MINIMAL_FUNCTION_NAME
|
|
108
|
-
|
|
109
|
-
// ######################################################################
|
|
110
|
-
//! Defines the CEREAL_NOEXCEPT macro to use instead of noexcept
|
|
111
|
-
/*! If a compiler we support does not support noexcept, this macro
|
|
112
|
-
will detect this and define CEREAL_NOEXCEPT as a no-op
|
|
113
|
-
@internal */
|
|
114
|
-
#if !defined(CEREAL_HAS_NOEXCEPT)
|
|
115
|
-
#if defined(__clang__)
|
|
116
|
-
#if __has_feature(cxx_noexcept)
|
|
117
|
-
#define CEREAL_HAS_NOEXCEPT
|
|
118
|
-
#endif
|
|
119
|
-
#else // NOT clang
|
|
120
|
-
#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
|
|
121
|
-
defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
|
|
122
|
-
#define CEREAL_HAS_NOEXCEPT
|
|
123
|
-
#endif // end GCC/MSVC check
|
|
124
|
-
#endif // end NOT clang block
|
|
125
|
-
|
|
126
|
-
#ifndef CEREAL_NOEXCEPT
|
|
127
|
-
#ifdef CEREAL_HAS_NOEXCEPT
|
|
128
|
-
#define CEREAL_NOEXCEPT noexcept
|
|
129
|
-
#else
|
|
130
|
-
#define CEREAL_NOEXCEPT
|
|
131
|
-
#endif // end CEREAL_HAS_NOEXCEPT
|
|
132
|
-
#endif // end !defined(CEREAL_HAS_NOEXCEPT)
|
|
133
|
-
#endif // ifndef CEREAL_NOEXCEPT
|
|
134
|
-
|
|
135
|
-
// ######################################################################
|
|
136
|
-
//! Checks if C++17 is available
|
|
137
|
-
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
|
138
|
-
#define CEREAL_HAS_CPP17
|
|
139
|
-
#endif
|
|
140
|
-
|
|
141
|
-
//! Checks if C++14 is available
|
|
142
|
-
#if __cplusplus >= 201402L
|
|
143
|
-
#define CEREAL_HAS_CPP14
|
|
144
|
-
#endif
|
|
145
|
-
|
|
146
|
-
// ######################################################################
|
|
147
|
-
//! Defines the CEREAL_ALIGNOF macro to use instead of alignof
|
|
148
|
-
#if defined(_MSC_VER) && _MSC_VER < 1900
|
|
149
|
-
#define CEREAL_ALIGNOF __alignof
|
|
150
|
-
#else // not MSVC 2013 or older
|
|
151
|
-
#define CEREAL_ALIGNOF alignof
|
|
152
|
-
#endif // end MSVC check
|
|
153
|
-
|
|
154
|
-
#endif // CEREAL_MACROS_HPP_
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*! \file specialize.hpp
|
|
2
|
-
\brief Serialization disambiguation */
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2014, Randolph Voorhies, Shane Grant
|
|
5
|
-
All rights reserved.
|
|
6
|
-
|
|
7
|
-
Redistribution and use in source and binary forms, with or without
|
|
8
|
-
modification, are permitted provided that the following conditions are met:
|
|
9
|
-
* Redistributions of source code must retain the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer.
|
|
11
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
documentation and/or other materials provided with the distribution.
|
|
14
|
-
* Neither the name of cereal nor the
|
|
15
|
-
names of its contributors may be used to endorse or promote products
|
|
16
|
-
derived from this software without specific prior written permission.
|
|
17
|
-
|
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
|
|
22
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef CEREAL_SPECIALIZE_HPP_
|
|
31
|
-
#define CEREAL_SPECIALIZE_HPP_
|
|
32
|
-
|
|
33
|
-
namespace cereal
|
|
34
|
-
{
|
|
35
|
-
// Forward declaration of access class that users can become friends with
|
|
36
|
-
class access;
|
|
37
|
-
|
|
38
|
-
// ######################################################################
|
|
39
|
-
//! A specifier used in conjunction with cereal::specialize to disambiguate
|
|
40
|
-
//! serialization in special cases
|
|
41
|
-
/*! @relates specialize
|
|
42
|
-
@ingroup Access */
|
|
43
|
-
enum class specialization
|
|
44
|
-
{
|
|
45
|
-
member_serialize, //!< Force the use of a member serialize function
|
|
46
|
-
member_load_save, //!< Force the use of a member load/save pair
|
|
47
|
-
member_load_save_minimal, //!< Force the use of a member minimal load/save pair
|
|
48
|
-
non_member_serialize, //!< Force the use of a non-member serialize function
|
|
49
|
-
non_member_load_save, //!< Force the use of a non-member load/save pair
|
|
50
|
-
non_member_load_save_minimal //!< Force the use of a non-member minimal load/save pair
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
//! A class used to disambiguate cases where cereal cannot detect a unique way of serializing a class
|
|
54
|
-
/*! cereal attempts to figure out which method of serialization (member vs. non-member serialize
|
|
55
|
-
or load/save pair) at compile time. If for some reason cereal cannot find a non-ambiguous way
|
|
56
|
-
of serializing a type, it will produce a static assertion complaining about this.
|
|
57
|
-
|
|
58
|
-
This can happen because you have both a serialize and load/save pair, or even because a base
|
|
59
|
-
class has a serialize (public or private with friend access) and a derived class does not
|
|
60
|
-
overwrite this due to choosing some other serialization type.
|
|
61
|
-
|
|
62
|
-
Specializing this class will tell cereal to explicitly use the serialization type you specify
|
|
63
|
-
and it will not complain about ambiguity in its compile time selection. However, if cereal detects
|
|
64
|
-
an ambiguity in specializations, it will continue to issue a static assertion.
|
|
65
|
-
|
|
66
|
-
@code{.cpp}
|
|
67
|
-
class MyParent
|
|
68
|
-
{
|
|
69
|
-
friend class cereal::access;
|
|
70
|
-
template <class Archive>
|
|
71
|
-
void serialize( Archive & ar ) {}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// Although serialize is private in MyParent, to cereal::access it will look public,
|
|
75
|
-
// even through MyDerived
|
|
76
|
-
class MyDerived : public MyParent
|
|
77
|
-
{
|
|
78
|
-
public:
|
|
79
|
-
template <class Archive>
|
|
80
|
-
void load( Archive & ar ) {}
|
|
81
|
-
|
|
82
|
-
template <class Archive>
|
|
83
|
-
void save( Archive & ar ) {}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// The load/save pair in MyDerived is ambiguous because serialize in MyParent can
|
|
87
|
-
// be accessed from cereal::access. This looks the same as making serialize public
|
|
88
|
-
// in MyParent, making it seem as though MyDerived has both a serialize and a load/save pair.
|
|
89
|
-
// cereal will complain about this at compile time unless we disambiguate:
|
|
90
|
-
|
|
91
|
-
namespace cereal
|
|
92
|
-
{
|
|
93
|
-
// This struct specialization will tell cereal which is the right way to serialize the ambiguity
|
|
94
|
-
template <class Archive> struct specialize<Archive, MyDerived, cereal::specialization::member_load_save> {};
|
|
95
|
-
|
|
96
|
-
// If we only had a disambiguation for a specific archive type, it would look something like this
|
|
97
|
-
template <> struct specialize<cereal::BinaryOutputArchive, MyDerived, cereal::specialization::member_load_save> {};
|
|
98
|
-
}
|
|
99
|
-
@endcode
|
|
100
|
-
|
|
101
|
-
You can also choose to use the macros CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES or
|
|
102
|
-
CEREAL_SPECIALIZE_FOR_ARCHIVE if you want to type a little bit less.
|
|
103
|
-
|
|
104
|
-
@tparam T The type to specialize the serialization for
|
|
105
|
-
@tparam S The specialization type to use for T
|
|
106
|
-
@ingroup Access */
|
|
107
|
-
template <class Archive, class T, specialization S>
|
|
108
|
-
struct specialize : public std::false_type {};
|
|
109
|
-
|
|
110
|
-
//! Convenient macro for performing specialization for all archive types
|
|
111
|
-
/*! This performs specialization for the specific type for all types of archives.
|
|
112
|
-
This macro should be placed at the global namespace.
|
|
113
|
-
|
|
114
|
-
@code{cpp}
|
|
115
|
-
struct MyType {};
|
|
116
|
-
CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( MyType, cereal::specialization::member_load_save );
|
|
117
|
-
@endcode
|
|
118
|
-
|
|
119
|
-
@relates specialize
|
|
120
|
-
@ingroup Access */
|
|
121
|
-
#define CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( Type, Specialization ) \
|
|
122
|
-
namespace cereal { template <class Archive> struct specialize<Archive, Type, Specialization> {}; }
|
|
123
|
-
|
|
124
|
-
//! Convenient macro for performing specialization for a single archive type
|
|
125
|
-
/*! This performs specialization for the specific type for a single type of archive.
|
|
126
|
-
This macro should be placed at the global namespace.
|
|
127
|
-
|
|
128
|
-
@code{cpp}
|
|
129
|
-
struct MyType {};
|
|
130
|
-
CEREAL_SPECIALIZE_FOR_ARCHIVE( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save );
|
|
131
|
-
@endcode
|
|
132
|
-
|
|
133
|
-
@relates specialize
|
|
134
|
-
@ingroup Access */
|
|
135
|
-
#define CEREAL_SPECIALIZE_FOR_ARCHIVE( Archive, Type, Specialization ) \
|
|
136
|
-
namespace cereal { template <> struct specialize<Archive, Type, Specialization> {}; }
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
#endif
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*! \file array.hpp
|
|
2
|
-
\brief Support for types found in \<array\>
|
|
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_ARRAY_HPP_
|
|
31
|
-
#define CEREAL_TYPES_ARRAY_HPP_
|
|
32
|
-
|
|
33
|
-
#include "cereal/cereal.hpp"
|
|
34
|
-
#include <array>
|
|
35
|
-
|
|
36
|
-
namespace cereal
|
|
37
|
-
{
|
|
38
|
-
//! Saving for std::array primitive types
|
|
39
|
-
//! using binary serialization, if supported
|
|
40
|
-
template <class Archive, class T, size_t N> inline
|
|
41
|
-
typename std::enable_if<traits::is_output_serializable<BinaryData<T>, Archive>::value
|
|
42
|
-
&& std::is_arithmetic<T>::value, void>::type
|
|
43
|
-
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array<T, N> const & array )
|
|
44
|
-
{
|
|
45
|
-
ar( binary_data( array.data(), sizeof(array) ) );
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//! Loading for std::array primitive types
|
|
49
|
-
//! using binary serialization, if supported
|
|
50
|
-
template <class Archive, class T, size_t N> inline
|
|
51
|
-
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>::value
|
|
52
|
-
&& std::is_arithmetic<T>::value, void>::type
|
|
53
|
-
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array<T, N> & array )
|
|
54
|
-
{
|
|
55
|
-
ar( binary_data( array.data(), sizeof(array) ) );
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//! Saving for std::array all other types
|
|
59
|
-
template <class Archive, class T, size_t N> inline
|
|
60
|
-
typename std::enable_if<!traits::is_output_serializable<BinaryData<T>, Archive>::value
|
|
61
|
-
|| !std::is_arithmetic<T>::value, void>::type
|
|
62
|
-
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array<T, N> const & array )
|
|
63
|
-
{
|
|
64
|
-
for( auto const & i : array )
|
|
65
|
-
ar( i );
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//! Loading for std::array all other types
|
|
69
|
-
template <class Archive, class T, size_t N> inline
|
|
70
|
-
typename std::enable_if<!traits::is_input_serializable<BinaryData<T>, Archive>::value
|
|
71
|
-
|| !std::is_arithmetic<T>::value, void>::type
|
|
72
|
-
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array<T, N> & array )
|
|
73
|
-
{
|
|
74
|
-
for( auto & i : array )
|
|
75
|
-
ar( i );
|
|
76
|
-
}
|
|
77
|
-
} // namespace cereal
|
|
78
|
-
|
|
79
|
-
#endif // CEREAL_TYPES_ARRAY_HPP_
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*! \file atomic.hpp
|
|
2
|
-
\brief Support for types found in \<atomic\>
|
|
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_ATOMIC_HPP_
|
|
31
|
-
#define CEREAL_TYPES_ATOMIC_HPP_
|
|
32
|
-
|
|
33
|
-
#include <cereal/cereal.hpp>
|
|
34
|
-
#include <atomic>
|
|
35
|
-
|
|
36
|
-
namespace cereal
|
|
37
|
-
{
|
|
38
|
-
//! Serializing (save) for std::atomic
|
|
39
|
-
template <class Archive, class T> inline
|
|
40
|
-
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::atomic<T> const & a )
|
|
41
|
-
{
|
|
42
|
-
ar( CEREAL_NVP_("atomic_data", a.load()) );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//! Serializing (load) for std::atomic
|
|
46
|
-
template <class Archive, class T> inline
|
|
47
|
-
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::atomic<T> & a )
|
|
48
|
-
{
|
|
49
|
-
T tmp;
|
|
50
|
-
ar( CEREAL_NVP_("atomic_data", tmp) );
|
|
51
|
-
a.store( tmp );
|
|
52
|
-
}
|
|
53
|
-
} // namespace cereal
|
|
54
|
-
|
|
55
|
-
#endif // CEREAL_TYPES_ATOMIC_HPP_
|