ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
autocast.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_expressions of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace expressions { namespace plugins {
9
10//==================================================================================================
11/// This built-in compiler plug-in of \alib_expressions_nl, performs auto-casts only if two
12/// different types are given. In this case, the following casts are performed:
13///
14/// 1. If one argument is of type \alib{expressions;Types::String}, the other is converted to
15/// string. The expression function returned for (optional) de-compilation is \b "String()".
16///
17/// 2. If one argument is of type \alib{expressions;Types::Float} and the other of type
18/// \alib{expressions;Types::Integer}, the integral value is cast to floating point.
19/// The expression function returned for (optional) de-compilation is \b "Float()".
20///
21/// 3. If one argument is of type \alib{expressions;Types::Float} and the other of type
22/// \alib{expressions;Types::Boolean}, the boolean value is cast to floating point.
23/// The expression function returned for (optional) de-compilation is \b "Float()".
24///
25/// 4. If one argument is of type \alib{expressions;Types::Integer} and the other of type
26/// \alib{expressions;Types::Boolean}, the boolean value is cast to integer.
27/// The expression function returned for (optional) de-compilation is \b "Integer()".
28///
29/// 5. If one argument is of type \alib{expressions;Types::Boolean}, the other is converted to
30/// boolean using an internal callback function that simply invokes box-function
31/// \alib{boxing;FIsTrue}.
32/// The expression function returned for (optional) de-compilation is \b "Boolean()".
33//==================================================================================================
34struct AutoCast : public CompilerPlugin
35{
36 //==============================================================================================
37 /// Constructor.
38 /// @param compiler The compiler we will get attached to.
39 //==============================================================================================
41
42 //==============================================================================================
43 /// Virtual destructor.
44 //==============================================================================================
45 virtual ~AutoCast() override
46 {}
47
48 //==============================================================================================
49 /// Offers auto-cast functions for built-in types.
50 ///
51 /// @param[out] ciAutoCast The compilation result.
52 /// @return \c true if an entry was found. \c false otherwise.
53 //==============================================================================================
55 virtual bool TryCompilation( CIAutoCast& ciAutoCast ) override;
56};
57
58}}} // namespace [alib::expressions::detail]
59
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_EXPORT
Definition alib.inl:488
CompilerPlugin(const NString &name, Compiler &compiler, CompilePriorities pPriority)
virtual ~AutoCast() override
Virtual destructor.
Definition autocast.inl:45
virtual ALIB_DLL bool TryCompilation(CIAutoCast &ciAutoCast) override
ALIB_DLL AutoCast(Compiler &compiler)