Fixed the SVACE issue in ExceptionFlinger.
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / utils.h
index 09c30e1..1aace35 100644 (file)
@@ -41,10 +41,7 @@ namespace SceneLoader
 class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf<char>
 {
 public:
-  StreamBuffer(char* buffer, size_t size)
-  {
-    setp(buffer, buffer + size);
-  }
+  StreamBuffer(char* buffer, size_t size) noexcept(true);
 };
 
 /*
@@ -57,29 +54,30 @@ class DALI_SCENE_LOADER_API ExceptionFlinger
 public:
   enum { MESSAGE_BUFFER_SIZE = 512 };
 
-  ExceptionFlinger(const char* location)
-  : mLocation(location),
-    mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1),
-    mStream(&mStreamBuffer)
-  {}
+  ExceptionFlinger(const char* location) noexcept(true);
 
-  ~ExceptionFlinger() noexcept(false)
-  {
-    operator<<('\0');
-    throw DaliException(mLocation, GetMessageBuffer());
-  }
+  [[noreturn]]
+  ~ExceptionFlinger() noexcept(false);
 
   template <typename T>
-  ExceptionFlinger& operator<<(const T& rhs)
+  ExceptionFlinger& operator<<(const T& rhs) noexcept(true)
   {
     mStream << rhs;
     return *this;
   }
 
 private:
-  static char* GetMessageBuffer();
+  struct Impl
+  {
+    const char* mLocation;
+
+    [[noreturn]]
+    ~Impl() noexcept(false);
+  };
+
+  static char* GetMessageBuffer() noexcept(true);
 
-  const char* mLocation;
+  Impl mImpl;
   StreamBuffer mStreamBuffer;
   std::ostream mStream;
 };