Skip to content

Commit 9b141fa

Browse files
committed
Separated parse and unpack on v2.
1 parent 6a1fa2e commit 9b141fa

File tree

7 files changed

+1531
-1382
lines changed

7 files changed

+1531
-1382
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// MessagePack for C++ deserializing routine
3+
//
4+
// Copyright (C) 2017 KONDO Takatoshi
5+
//
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
//
10+
#ifndef MSGPACK_UNPACK_EXCEPTION_HPP
11+
#define MSGPACK_UNPACK_EXCEPTION_HPP
12+
13+
#include "msgpack/v1/unpack_exception.hpp"
14+
15+
#endif // MSGPACK_UNPACK_EXCEPTION_HPP

include/msgpack/v1/unpack.hpp

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
#include "msgpack/unpack_decl.hpp"
1515
#include "msgpack/object.hpp"
1616
#include "msgpack/zone.hpp"
17+
#include "msgpack/unpack_exception.hpp"
1718
#include "msgpack/unpack_define.h"
1819
#include "msgpack/cpp_config.hpp"
1920
#include "msgpack/sysdep.h"
2021

2122
#include <memory>
22-
#include <stdexcept>
2323

2424
#if !defined(MSGPACK_USE_CPP03)
2525
#include <atomic>
@@ -39,96 +39,6 @@ namespace msgpack {
3939
MSGPACK_API_VERSION_NAMESPACE(v1) {
4040
/// @endcond
4141

42-
struct unpack_error : public std::runtime_error {
43-
explicit unpack_error(const std::string& msg)
44-
:std::runtime_error(msg) {}
45-
#if !defined(MSGPACK_USE_CPP03)
46-
explicit unpack_error(const char* msg):
47-
std::runtime_error(msg) {}
48-
#endif // !defined(MSGPACK_USE_CPP03)
49-
};
50-
51-
struct parse_error : public unpack_error {
52-
explicit parse_error(const std::string& msg)
53-
:unpack_error(msg) {}
54-
#if !defined(MSGPACK_USE_CPP03)
55-
explicit parse_error(const char* msg)
56-
:unpack_error(msg) {}
57-
#endif // !defined(MSGPACK_USE_CPP03)
58-
};
59-
60-
struct insufficient_bytes : public unpack_error {
61-
explicit insufficient_bytes(const std::string& msg)
62-
:unpack_error(msg) {}
63-
#if !defined(MSGPACK_USE_CPP03)
64-
explicit insufficient_bytes(const char* msg)
65-
:unpack_error(msg) {}
66-
#endif // !defined(MSGPACK_USE_CPP03)
67-
};
68-
69-
struct size_overflow : public unpack_error {
70-
explicit size_overflow(const std::string& msg)
71-
:unpack_error(msg) {}
72-
#if !defined(MSGPACK_USE_CPP03)
73-
explicit size_overflow(const char* msg)
74-
:unpack_error(msg) {}
75-
#endif
76-
};
77-
78-
struct array_size_overflow : public size_overflow {
79-
array_size_overflow(const std::string& msg)
80-
:size_overflow(msg) {}
81-
#if !defined(MSGPACK_USE_CPP03)
82-
array_size_overflow(const char* msg)
83-
:size_overflow(msg) {}
84-
#endif
85-
};
86-
87-
struct map_size_overflow : public size_overflow {
88-
map_size_overflow(const std::string& msg)
89-
:size_overflow(msg) {}
90-
#if !defined(MSGPACK_USE_CPP03)
91-
map_size_overflow(const char* msg)
92-
:size_overflow(msg) {}
93-
#endif
94-
};
95-
96-
struct str_size_overflow : public size_overflow {
97-
str_size_overflow(const std::string& msg)
98-
:size_overflow(msg) {}
99-
#if !defined(MSGPACK_USE_CPP03)
100-
str_size_overflow(const char* msg)
101-
:size_overflow(msg) {}
102-
#endif
103-
};
104-
105-
struct bin_size_overflow : public size_overflow {
106-
bin_size_overflow(const std::string& msg)
107-
:size_overflow(msg) {}
108-
#if !defined(MSGPACK_USE_CPP03)
109-
bin_size_overflow(const char* msg)
110-
:size_overflow(msg) {}
111-
#endif
112-
};
113-
114-
struct ext_size_overflow : public size_overflow {
115-
ext_size_overflow(const std::string& msg)
116-
:size_overflow(msg) {}
117-
#if !defined(MSGPACK_USE_CPP03)
118-
ext_size_overflow(const char* msg)
119-
:size_overflow(msg) {}
120-
#endif
121-
};
122-
123-
struct depth_size_overflow : public size_overflow {
124-
depth_size_overflow(const std::string& msg)
125-
:size_overflow(msg) {}
126-
#if !defined(MSGPACK_USE_CPP03)
127-
depth_size_overflow(const char* msg)
128-
:size_overflow(msg) {}
129-
#endif
130-
};
131-
13242
namespace detail {
13343

13444
class unpack_user {
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
//
2+
// MessagePack for C++ deserializing routine
3+
//
4+
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
5+
//
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
//
10+
#ifndef MSGPACK_V1_UNPACK_EXCEPTION_HPP
11+
#define MSGPACK_V1_UNPACK_EXCEPTION_HPP
12+
13+
#include "msgpack/versioning.hpp"
14+
15+
#include <string>
16+
#include <stdexcept>
17+
18+
19+
namespace msgpack {
20+
21+
/// @cond
22+
MSGPACK_API_VERSION_NAMESPACE(v1) {
23+
/// @endcond
24+
25+
struct unpack_error : public std::runtime_error {
26+
explicit unpack_error(const std::string& msg)
27+
:std::runtime_error(msg) {}
28+
#if !defined(MSGPACK_USE_CPP03)
29+
explicit unpack_error(const char* msg):
30+
std::runtime_error(msg) {}
31+
#endif // !defined(MSGPACK_USE_CPP03)
32+
};
33+
34+
struct parse_error : public unpack_error {
35+
explicit parse_error(const std::string& msg)
36+
:unpack_error(msg) {}
37+
#if !defined(MSGPACK_USE_CPP03)
38+
explicit parse_error(const char* msg)
39+
:unpack_error(msg) {}
40+
#endif // !defined(MSGPACK_USE_CPP03)
41+
};
42+
43+
struct insufficient_bytes : public unpack_error {
44+
explicit insufficient_bytes(const std::string& msg)
45+
:unpack_error(msg) {}
46+
#if !defined(MSGPACK_USE_CPP03)
47+
explicit insufficient_bytes(const char* msg)
48+
:unpack_error(msg) {}
49+
#endif // !defined(MSGPACK_USE_CPP03)
50+
};
51+
52+
struct size_overflow : public unpack_error {
53+
explicit size_overflow(const std::string& msg)
54+
:unpack_error(msg) {}
55+
#if !defined(MSGPACK_USE_CPP03)
56+
explicit size_overflow(const char* msg)
57+
:unpack_error(msg) {}
58+
#endif
59+
};
60+
61+
struct array_size_overflow : public size_overflow {
62+
array_size_overflow(const std::string& msg)
63+
:size_overflow(msg) {}
64+
#if !defined(MSGPACK_USE_CPP03)
65+
array_size_overflow(const char* msg)
66+
:size_overflow(msg) {}
67+
#endif
68+
};
69+
70+
struct map_size_overflow : public size_overflow {
71+
map_size_overflow(const std::string& msg)
72+
:size_overflow(msg) {}
73+
#if !defined(MSGPACK_USE_CPP03)
74+
map_size_overflow(const char* msg)
75+
:size_overflow(msg) {}
76+
#endif
77+
};
78+
79+
struct str_size_overflow : public size_overflow {
80+
str_size_overflow(const std::string& msg)
81+
:size_overflow(msg) {}
82+
#if !defined(MSGPACK_USE_CPP03)
83+
str_size_overflow(const char* msg)
84+
:size_overflow(msg) {}
85+
#endif
86+
};
87+
88+
struct bin_size_overflow : public size_overflow {
89+
bin_size_overflow(const std::string& msg)
90+
:size_overflow(msg) {}
91+
#if !defined(MSGPACK_USE_CPP03)
92+
bin_size_overflow(const char* msg)
93+
:size_overflow(msg) {}
94+
#endif
95+
};
96+
97+
struct ext_size_overflow : public size_overflow {
98+
ext_size_overflow(const std::string& msg)
99+
:size_overflow(msg) {}
100+
#if !defined(MSGPACK_USE_CPP03)
101+
ext_size_overflow(const char* msg)
102+
:size_overflow(msg) {}
103+
#endif
104+
};
105+
106+
struct depth_size_overflow : public size_overflow {
107+
depth_size_overflow(const std::string& msg)
108+
:size_overflow(msg) {}
109+
#if !defined(MSGPACK_USE_CPP03)
110+
depth_size_overflow(const char* msg)
111+
:size_overflow(msg) {}
112+
#endif
113+
};
114+
115+
/// @cond
116+
} // MSGPACK_API_VERSION_NAMESPACE(v1)
117+
/// @endcond
118+
119+
} // namespace msgpack
120+
121+
122+
#endif // MSGPACK_V1_UNPACK_EXCEPTION_HPP

0 commit comments

Comments
 (0)