ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
autocast.hpp
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-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_EXPRESSIONS_PLUGINS_AUTOCAST
9#define HPP_ALIB_EXPRESSIONS_PLUGINS_AUTOCAST
10#pragma once
12
13
14namespace alib { namespace expressions { namespace plugins {
15
16//==================================================================================================
17/// This built-in compiler plug-in of \alib_expressions_nl, performs auto-casts only if two
18/// different types are given. In this case, the following casts are performed:
19///
20/// 1. If one argument is of type \alib{expressions;Types::String}, the other is converted to
21/// string. The expression function returned for (optional) de-compilation is \b "String()".
22///
23/// 2. If one argument is of type \alib{expressions;Types::Float} and the other of type
24/// \alib{expressions;Types::Integer}, the integral value is cast to floating point.
25/// The expression function returned for (optional) de-compilation is \b "Float()".
26///
27/// 3. If one argument is of type \alib{expressions;Types::Float} and the other of type
28/// \alib{expressions;Types::Boolean}, the boolean value is cast to floating point.
29/// The expression function returned for (optional) de-compilation is \b "Float()".
30///
31/// 4. If one argument is of type \alib{expressions;Types::Integer} and the other of type
32/// \alib{expressions;Types::Boolean}, the boolean value is cast to integer.
33/// The expression function returned for (optional) de-compilation is \b "Integer()".
34///
35/// 5. If one argument is of type \alib{expressions;Types::Boolean}, the other is converted to
36/// boolean using an internal callback function that simply invokes box-function
37/// \alib{boxing;FIsTrue}.
38/// The expression function returned for (optional) de-compilation is \b "Boolean()".
39//==================================================================================================
40struct AutoCast : public CompilerPlugin
41{
42 //==============================================================================================
43 /// Constructor.
44 /// @param compiler The compiler we will get attached to.
45 //==============================================================================================
47
48 //==============================================================================================
49 /// Virtual destructor.
50 //==============================================================================================
51 virtual ~AutoCast() override
52 {}
53
54 //==============================================================================================
55 /// Offers auto-cast functions for built-in types.
56 ///
57 /// @param[out] ciAutoCast The compilation result.
58 /// @return \c true if an entry was found. \c false otherwise.
59 //==============================================================================================
61 virtual bool TryCompilation( CIAutoCast& ciAutoCast ) override;
62};
63
64}}} // namespace [alib::expressions::detail]
65
66#endif // HPP_ALIB_EXPRESSIONS_PLUGINS_AUTOCAST
67
#define ALIB_API
Definition alib.hpp:639
Definition alib.cpp:69
virtual ~AutoCast() override
Virtual destructor.
Definition autocast.hpp:51
virtual ALIB_API bool TryCompilation(CIAutoCast &ciAutoCast) override
ALIB_API AutoCast(Compiler &compiler)