/* $Revision: 14 $ $Date: 10/02/04 16:34 $ Copyright © 1999-2004, FSL Technologies Limited. Contact "http://fost3.fsltech.com". */ #include "stdafx.h" namespace { const FSLib::Revision c_revision( L"$Archive: /FOST.3/F3Util/nullable.cpp $", __DATE__, L"$Revision: 14 $", L"$Date: 10/02/04 16:34 $" ); const wchar_t c_nullMsg[]=L"Attempt to de-reference null value."; const wchar_t c_notNullMsg[]=L"This value can only be initialised once."; } /* Functions */ inline FSLib::Nullable< FSLib::wstring > FSLib::concat( const FSLib::Nullable< FSLib::wstring > &left, const FSLib::wstring &mid, const FSLib::Nullable< FSLib::wstring > &right ) { if ( left.isnull() && right.isnull() ) { return FSLib::Nullable< FSLib::wstring >(); } if ( left.isnull() && !right.isnull() ) { return right; } if ( !left.isnull() && right.isnull() ) { return left; } else { return left.value() + mid + right.value(); } } inline FSLib::Nullable< FSLib::wstring > FSLib::concat( const FSLib::wstring &left, const FSLib::wstring &mid, const FSLib::Nullable< FSLib::wstring > &right ) { if ( right.isnull() ) { return left; } else { return left + mid + right.value(); } } inline FSLib::Nullable< FSLib::wstring > FSLib::concat( const FSLib::Nullable< FSLib::wstring > &left, const FSLib::wstring &mid, const FSLib::wstring &right ) { if ( left.isnull() ) { return right; } else { return left.value() + mid + right; } } inline FSLib::Nullable< FSLib::wstring > FSLib::concat( const FSLib::wstring &left, const FSLib::wstring &mid, const FSLib::wstring &right ) { return left + mid + right; } /* FSLib::Exceptions::Null */ inline FSLib::Exceptions::Null::Null() { } inline FSLib::Exceptions::Null::Null( const FSLib::wstring &mes ) : FSLib::Exceptions::Exception( mes ) { } inline const wchar_t * const FSLib::Exceptions::Null::message() const { return c_nullMsg; } /* FSLib::Exceptions::NotNull */ inline FSLib::Exceptions::NotNull::NotNull() { } inline FSLib::Exceptions::NotNull::NotNull( const FSLib::wstring &mes ) : FSLib::Exceptions::Exception( mes ) { } inline FSLib::Exceptions::NotNull::NotNull( const FSLib::wstring &mes, const FSLib::wstring &inf ) : FSLib::Exceptions::Exception( mes ) { info() << inf << std::endl; } inline const wchar_t * const FSLib::Exceptions::NotNull::message() const { return c_notNullMsg; } /* $History: nullable.cpp $ * * ***************** Version 14 ***************** * User: Kirit Date: 10/02/04 Time: 16:34 * Updated in $/FOST.3/F3Util * Added new constructor for NotNull exception so that it can take an * informational parameter. * * ***************** Version 13 ***************** * User: Kirit Date: 9/10/03 Time: 15:44 * Updated in $/FOST.3/F3Util * Headers re-arranged to give a proper SDK feel and to make determination * of required headers simpler. * * ***************** Version 11 ***************** * User: Kirit Date: 3/10/03 Time: 16:09 * Updated in $/FOST/Cpp/FSCppUtil * Added stdafx.h and stdafx.cpp pre-compiled header support. * * ***************** Version 10 ***************** * User: Kirit Date: 10/05/03 Time: 13:55 * Updated in $/FOST/Cpp/FSCppUtil * Added a NotNull exception to handle double initialisation etc. * * ***************** Version 9 ***************** * User: Kirit Date: 9/03/03 Time: 15:54 * Updated in $/FOST/Cpp/FSCppUtil * FSLib::Exceptions::Null can now take an error message. * * ***************** Version 8 ***************** * User: Kirit Date: 8/03/03 Time: 17:18 * Updated in $/FOST/Cpp/FSCppUtil * Extended FSLib::concat to better handle string literals. * * ***************** Version 7 ***************** * User: Kirit Date: 16/06/02 Time: 20:57 * Updated in $/FOST/Cpp/FSCppUtil * Added concatenation function for nullable strings. * * ***************** Version 6 ***************** * User: Kirit Date: 19/03/02 Time: 20:54 * Updated in $/FOST/Cpp/FSCppUtil * Corrected history from last check-in. * Updated TestAX.IDL to remove registry entries from removed classes. * * ***************** Version 5 ***************** * User: Kirit Date: 19/03/02 Time: 19:48 * Updated in $/FOST/Cpp/FSCppUtil * Debug compiles now all end in '_d'. * The C++ implementation names (Type.cppName) have been changed to also * include the DLL that the implementation is in as per the documentation. * In all source files the following have been done: * * Ensured that every header file has a revision object. * * Ensured that every translation unit has a revision object. * * Ensured that every source file (which understands comments) * has a history section. * * Changed all copyright notices to be for Obsideon Ltd. * * Changed copyright notices to use the longest possible timeframe. * * ***************** Version 4 ***************** * User: Kirit Date: 20/02/02 Time: 0:40 * Updated in $/FOST/Cpp/FSCppUtil * Added revision reporting to nullable.hpp. * Added throw specifiers to some Nullable< T > constructors. * * ***************** Version 3 ***************** * User: Kirit Date: 5/07/01 Time: 17:41 * Updated in $/FOST/FSCppUtil * First Unicode only version of FOST. * * ***************** Version 2 ***************** * User: Kirit Date: 26/06/01 Time: 16:32 * Updated in $/FOST/FSCppUtil * Nullable<> added and working. * * ***************** Version 1 ***************** * User: Kirit Date: 26/06/01 Time: 16:14 * Created in $/FOST/FSCppUtil */