Skip to content

Commit 6ef4f79

Browse files
authored
add jsoncons (#29)
* add jsoncons * update
1 parent 36d9779 commit 6ef4f79

File tree

154 files changed

+88707
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+88707
-1
lines changed

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import setup, find_packages
77
88
name = "cubao_headers"
9-
version = "0.0.7"
9+
version = "0.0.8"
1010
1111
pattern = ["*"]
1212

include/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- https://github.com/Tessil/ordered-map
77
- https://github.com/Tessil/robin-map
88
- https://github.com/cubao/nano-fmm/blob/master/3rdparty/packedrtree.h
9+
- https://github.com/danielaparker/jsoncons/tree/master/include
910
- https://github.com/district10/geojson-cpp/tree/fef5888142373cc07561987b8c8ba4bd64e2380b
1011
- https://github.com/district10/geometry.hpp/tree/8949904a2b6e0295df2db09b06a643f573e714d0
1112
- https://github.com/doctest/doctest/tree/4d8716f1efc1d14aa736ef52ee727bd4204f4c40
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2013-2025 Daniel Parker
2+
// Distributed under the Boost license, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
5+
// See https://github.com/danielaparker/jsoncons for latest version
6+
7+
#ifndef JSONCONS_ALLOCATOR_HOLDER_HPP
8+
#define JSONCONS_ALLOCATOR_HOLDER_HPP
9+
10+
namespace jsoncons {
11+
12+
template <typename Allocator>
13+
class allocator_holder
14+
{
15+
public:
16+
using allocator_type = Allocator;
17+
private:
18+
allocator_type alloc_;
19+
public:
20+
allocator_holder() = default;
21+
allocator_holder(const allocator_holder&) = default;
22+
allocator_holder(allocator_holder&&) = default;
23+
allocator_holder& operator=(const allocator_holder&) = delete;
24+
allocator_holder(const allocator_type& alloc)
25+
: alloc_(alloc)
26+
{}
27+
~allocator_holder() = default;
28+
29+
allocator_type get_allocator() const
30+
{
31+
return alloc_;
32+
}
33+
};
34+
35+
} // namespace jsoncons
36+
37+
#endif // JSONCONS_ALLOCATOR_HOLDER_HPP

include/jsoncons/allocator_set.hpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2013-2025 Daniel Parker
2+
// Distributed under the Boost license, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
5+
// See https://github.com/danielaparker/jsoncons for latest version
6+
7+
#ifndef JSONCONS_ALLOCATOR_SET_HPP
8+
#define JSONCONS_ALLOCATOR_SET_HPP
9+
10+
#include <memory>
11+
12+
#include <jsoncons/json_type.hpp>
13+
14+
namespace jsoncons {
15+
16+
template <typename Allocator,typename TempAllocator >
17+
class allocator_set
18+
{
19+
Allocator result_alloc_;
20+
TempAllocator temp_alloc_;
21+
public:
22+
using allocator_type = Allocator;
23+
using temp_allocator_type = TempAllocator;
24+
25+
allocator_set(const Allocator& alloc=Allocator(),
26+
const TempAllocator& temp_alloc=TempAllocator())
27+
: result_alloc_(alloc), temp_alloc_(temp_alloc)
28+
{
29+
}
30+
31+
allocator_set(const allocator_set&) = default;
32+
allocator_set(allocator_set&&) = default;
33+
allocator_set& operator=(const allocator_set&) = delete;
34+
allocator_set& operator=(allocator_set&&) = delete;
35+
~allocator_set() = default;
36+
37+
Allocator get_allocator() const {return result_alloc_;}
38+
TempAllocator get_temp_allocator() const {return temp_alloc_;}
39+
};
40+
41+
inline
42+
allocator_set<std::allocator<char>,std::allocator<char>> combine_allocators()
43+
{
44+
return allocator_set<std::allocator<char>,std::allocator<char>>(std::allocator<char>(), std::allocator<char>());
45+
}
46+
47+
template <typename Allocator>
48+
allocator_set<Allocator,std::allocator<char>> combine_allocators(const Allocator& alloc)
49+
{
50+
return allocator_set<Allocator,std::allocator<char>>(alloc, std::allocator<char>());
51+
}
52+
53+
template <typename Allocator,typename TempAllocator >
54+
allocator_set<Allocator,TempAllocator> combine_allocators(const Allocator& alloc, const TempAllocator& temp_alloc)
55+
{
56+
return allocator_set<Allocator,TempAllocator>(alloc, temp_alloc);
57+
}
58+
59+
template <typename TempAllocator >
60+
allocator_set<std::allocator<char>,TempAllocator> temp_allocator_only(const TempAllocator& temp_alloc)
61+
{
62+
return allocator_set<std::allocator<char>,TempAllocator>(std::allocator<char>(), temp_alloc);
63+
}
64+
65+
} // namespace jsoncons
66+
67+
#endif // JSONCONS_ALLOCATOR_SET_HPP

0 commit comments

Comments
 (0)