From 0651ea28e0662c45ccfd9a1dab49bb22ec5c4c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 27 Dec 2017 19:00:56 +0100 Subject: [PATCH] Streams - Added optional path to errors --- include/ebcl/BinaryStreams.hh | 13 +++++++++++-- include/ebcl/SRDBinary.hh | 1 + include/ebcl/SRDIO.hh | 1 + include/ebcl/Streams.hh | 19 ++++++++++++------- include/ebcl/Strings.hh | 7 +------ include/ebcl/inline/Streams.hh | 17 +++++++++++------ src/SRDText.cc | 1 + src/Strings.cc | 1 + 8 files changed, 39 insertions(+), 21 deletions(-) diff --git a/include/ebcl/BinaryStreams.hh b/include/ebcl/BinaryStreams.hh index 4f2b8bb..edb8c0e 100644 --- a/include/ebcl/BinaryStreams.hh +++ b/include/ebcl/BinaryStreams.hh @@ -166,6 +166,15 @@ struct T_BinaryWriter }; -} -#include +/*= STREAM INTERFACES FOR OBJECTS THAT ARE NEEDED BY STREAMS =================*/ + +M_DECLARE_OBJECT_READER( T_Character ); +M_DECLARE_OBJECT_WRITER( T_Character ); +M_DECLARE_OBJECT_READER( T_String ); +M_DECLARE_OBJECT_WRITER( T_String ); +M_DECLARE_OBJECT_WRITER( T_StringBuilder ); + + +} // namespace ebcl #endif // _H_EBCL_BINARYSTREAMS +#include diff --git a/include/ebcl/SRDBinary.hh b/include/ebcl/SRDBinary.hh index 7185723..fb1b042 100644 --- a/include/ebcl/SRDBinary.hh +++ b/include/ebcl/SRDBinary.hh @@ -6,6 +6,7 @@ #define _H_EBCL_SRDBINARY #include #include +#include namespace ebcl { diff --git a/include/ebcl/SRDIO.hh b/include/ebcl/SRDIO.hh index fca7b04..add11cf 100644 --- a/include/ebcl/SRDIO.hh +++ b/include/ebcl/SRDIO.hh @@ -5,6 +5,7 @@ #ifndef _H_EBCL_SRDIO #define _H_EBCL_SRDIO #include +#include namespace ebcl { diff --git a/include/ebcl/Streams.hh b/include/ebcl/Streams.hh index 5e60e33..75f9a4d 100644 --- a/include/ebcl/Streams.hh +++ b/include/ebcl/Streams.hh @@ -8,6 +8,8 @@ #include #include #include +#include +#include namespace ebcl { @@ -28,21 +30,24 @@ class X_StreamError : public std::exception private: E_StreamError error_; int sysError_; + T_Optional< T_FSPath > path_; public: - explicit X_StreamError( E_StreamError e ); - explicit X_StreamError( int error ); + explicit X_StreamError( E_StreamError e , + T_Optional< T_FSPath > p = {} ) noexcept; + explicit X_StreamError( int error , + T_Optional< T_FSPath > p = {} ) noexcept; X_StreamError( ) = delete; X_StreamError( X_StreamError const& ) = default; X_StreamError( X_StreamError&& ) noexcept = default; virtual X_StreamError& operator= ( X_StreamError const& ) = default; - virtual X_StreamError& operator= ( X_StreamError&& ) = default; + virtual X_StreamError& operator= ( X_StreamError&& ) noexcept = default; - E_StreamError code( ) const; - int systemError( ) const; + E_StreamError code( ) const noexcept; + int systemError( ) const noexcept; - char const * what( ) const noexcept; + char const* what( ) const noexcept; }; @@ -107,6 +112,6 @@ class A_OutputStream : public A_Stream M_ABSTRACT_POINTERS( OutputStream ); -} // namespace +} // namespace ebcl #include #endif // _H_EBCL_STREAMS diff --git a/include/ebcl/Strings.hh b/include/ebcl/Strings.hh index 0c6ddc7..83f32da 100644 --- a/include/ebcl/Strings.hh +++ b/include/ebcl/Strings.hh @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace ebcl { @@ -113,8 +113,6 @@ struct T_Character M_CLASS_POINTERS( Character ); -M_DECLARE_OBJECT_READER( T_Character ); -M_DECLARE_OBJECT_WRITER( T_Character ); /*= IMMUTABLE UTF8 STRINGS ===================================================*/ @@ -293,8 +291,6 @@ class T_String M_CLASS_POINTERS( String ); M_DECLARE_HASH( T_String ); M_DECLARE_COMPARATOR( T_String ); -M_DECLARE_OBJECT_READER( T_String ); -M_DECLARE_OBJECT_WRITER( T_String ); void swap( T_String& lhs , T_String& rhs ) noexcept; @@ -433,7 +429,6 @@ class T_StringBuilder M_CLASS_POINTERS( StringBuilder ); -M_DECLARE_OBJECT_WRITER( T_StringBuilder ); void swap( T_StringBuilder& lhs , T_StringBuilder& rhs ); // Operator << diff --git a/include/ebcl/inline/Streams.hh b/include/ebcl/inline/Streams.hh index 13c3cbc..e264b0c 100644 --- a/include/ebcl/inline/Streams.hh +++ b/include/ebcl/inline/Streams.hh @@ -10,22 +10,27 @@ namespace ebcl { /*= X_StreamError ============================================================*/ -inline X_StreamError::X_StreamError( E_StreamError e ) - : std::exception( ) , error_( e ) , sysError_( -1 ) +inline X_StreamError::X_StreamError( + const E_StreamError e , + T_Optional< T_FSPath > p ) noexcept + : std::exception( ) , error_( e ) , sysError_( -1 ) , + path_{ std::move( p ) } { } -inline X_StreamError::X_StreamError( int error ) - : std::exception( ) , error_( E_StreamError::SYSTEM_ERROR ) , sysError_( error ) +inline X_StreamError::X_StreamError( const int error , + T_Optional< T_FSPath > p ) noexcept + : std::exception( ) , error_( E_StreamError::SYSTEM_ERROR ) , + sysError_( error ) , path_{ std::move( p ) } { } /*----------------------------------------------------------------------------*/ -inline E_StreamError X_StreamError::code( ) const +inline E_StreamError X_StreamError::code( ) const noexcept { return error_; } -inline int X_StreamError::systemError( ) const +inline int X_StreamError::systemError( ) const noexcept { return sysError_; } diff --git a/src/SRDText.cc b/src/SRDText.cc index e8ac8bb..efd6b23 100644 --- a/src/SRDText.cc +++ b/src/SRDText.cc @@ -4,6 +4,7 @@ #include +#include using namespace ebcl; diff --git a/src/Strings.cc b/src/Strings.cc index f18c998..905cfc0 100644 --- a/src/Strings.cc +++ b/src/Strings.cc @@ -9,6 +9,7 @@ #include #include #include +#include using namespace ebcl;