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