Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
UserExceptionFactory.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_USER_EXCEPTION_FACTORY_H
6#define ICE_USER_EXCEPTION_FACTORY_H
7
8#include <IceUtil/Shared.h>
9#include <IceUtil/Handle.h>
10#include <Ice/Config.h>
11
12#ifdef ICE_CPP11_MAPPING
13
14#include <functional>
15
16namespace Ice
17{
18
20using UserExceptionFactory = std::function<void(const std::string&)>;
21
22}
23
24namespace IceInternal
25{
26
27template<class E>
28void
29#ifdef NDEBUG
30defaultUserExceptionFactory(const std::string&)
31#else
32defaultUserExceptionFactory(const std::string& typeId)
33#endif
34{
35 assert(typeId == E::ice_staticId());
36 throw E();
37}
38
39}
40#else
41
42namespace Ice
43{
44
50{
51public:
52
53 virtual void createAndThrow(const ::std::string&) = 0;
55};
56typedef ::IceUtil::Handle<UserExceptionFactory> UserExceptionFactoryPtr;
57
58}
59
60namespace IceInternal
61{
62
63template<class E>
64class DefaultUserExceptionFactory : public Ice::UserExceptionFactory
65{
66public:
67
68 DefaultUserExceptionFactory(const ::std::string& typeId) :
69 _typeId(typeId)
70 {
71 }
72
73#ifdef NDEBUG
74 virtual void createAndThrow(const ::std::string&)
75#else
76 virtual void createAndThrow(const ::std::string& typeId)
77#endif
78 {
79 assert(typeId == _typeId);
80 throw E();
81 }
82
83private:
84 const ::std::string _typeId;
85};
86
87}
88
89#endif
90#endif
#define ICE_API
Definition Config.h:197
Definition Shared.h:78
Creates and throws a user exception.
Definition UserExceptionFactory.h:50
virtual void createAndThrow(const ::std::string &)=0
Definition BuiltinSequences.h:113
::IceUtil::Handle< UserExceptionFactory > UserExceptionFactoryPtr
Definition UserExceptionFactory.h:56