Ice 3.7 C++11 API Reference
ExceptionHelpers.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_EXCEPTION_HELPERS_H
6 #define ICE_EXCEPTION_HELPERS_H
7 
8 #ifdef ICE_CPP11_MAPPING // C++11 mapping
9 
10 #include <Ice/InputStream.h>
11 #include <Ice/OutputStream.h>
12 
13 namespace Ice
14 {
15 
16 class LocalException;
17 
22 template<typename T, typename B> class LocalExceptionHelper : public IceUtil::ExceptionHelper<T, B>
23 {
24 public:
25 
27 
28  virtual std::string ice_id() const override
29  {
30  return T::ice_staticId();
31  }
32 };
33 
38 template<typename T, typename B> class UserExceptionHelper : public IceUtil::ExceptionHelper<T, B>
39 {
40 public:
41 
43 
44  virtual std::string ice_id() const override
45  {
46  return T::ice_staticId();
47  }
48 
49 protected:
50 
52  virtual void _writeImpl(Ice::OutputStream* os) const override
53  {
54  os->startSlice(T::ice_staticId(), -1, std::is_same<B, Ice::LocalException>::value ? true : false);
55  Ice::StreamWriter<T, Ice::OutputStream>::write(os, static_cast<const T&>(*this));
56  os->endSlice();
57  B::_writeImpl(os);
58  }
59 
60  virtual void _readImpl(Ice::InputStream* is) override
61  {
62  is->startSlice();
63  Ice::StreamReader<T, ::Ice::InputStream>::read(is, static_cast<T&>(*this));
64  is->endSlice();
65  B::_readImpl(is);
66  }
68 };
69 
70 }
71 
72 #endif // C++11 mapping end
73 
74 #endif
Ice::InputStream::startSlice
std::string startSlice()
Reads the start of a value or exception slice.
Definition: InputStream.h:547
Ice::InputStream
Interface for input streams used to extract Slice types from a sequence of bytes.
Definition: InputStream.h:50
Ice::OutputStream::endSlice
void endSlice()
Marks the end of a value or exception slice.
Definition: OutputStream.h:294
Ice::LocalExceptionHelper
Helper template for the implementation of Ice::LocalException.
Definition: ExceptionHelpers.h:23
OutputStream.h
Ice::InputStream::endSlice
void endSlice()
Indicates that the end of a value or exception slice has been reached.
Definition: InputStream.h:556
Ice::UserExceptionHelper
Helper template for the implementation of Ice::UserException.
Definition: ExceptionHelpers.h:39
Ice::UserExceptionHelper::ice_id
virtual std::string ice_id() const override
Definition: ExceptionHelpers.h:44
Ice::OutputStream
Interface for output streams used to create a sequence of bytes from Slice types.
Definition: OutputStream.h:28
Ice::OutputStream::startSlice
void startSlice(const std::string &typeId, int compactId, bool last)
Writes the start of a value or exception slice.
Definition: OutputStream.h:285
Ice
Definition: BuiltinSequences.h:56
InputStream.h
IceUtil::ExceptionHelper
Helper template for the implementation of Ice::Exception.
Definition: Exception.h:128
Ice::LocalExceptionHelper::ice_id
virtual std::string ice_id() const override
Definition: ExceptionHelpers.h:28