ALib C++ Library
by
Library Version:
2510 R0
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
expressions
plugins
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
//==================================================================================================
8
ALIB_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
//==================================================================================================
34
struct
AutoCast
:
public
CompilerPlugin
35
{
36
//==============================================================================================
37
/// Constructor.
38
/// @param compiler The compiler we will get attached to.
39
//==============================================================================================
40
ALIB_DLL
AutoCast
(
Compiler
& compiler );
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
//==============================================================================================
54
ALIB_DLL
55
virtual
bool
TryCompilation
(
CIAutoCast
& ciAutoCast )
override
;
56
};
57
58
}}}
// namespace [alib::expressions::detail]
59
alib::expressions::Compiler
Definition
compiler.inl:56
ALIB_DLL
#define ALIB_DLL
Definition
alib.inl:496
ALIB_EXPORT
#define ALIB_EXPORT
Definition
alib.inl:488
alib::expressions::plugins
Definition
arithmetics.inl:8
alib::expressions
Definition
compiler.cpp:32
alib
Definition
ALib.Boxing.StdFunctors.H:18
alib::expressions::CompilerPlugin::CIAutoCast
Definition
compilerplugin.inl:394
alib::expressions::CompilerPlugin::CompilerPlugin
CompilerPlugin(const NString &name, Compiler &compiler, CompilePriorities pPriority)
Definition
compilerplugin.inl:464
alib::expressions::plugins::AutoCast::~AutoCast
virtual ~AutoCast() override
Virtual destructor.
Definition
autocast.inl:45
alib::expressions::plugins::AutoCast::TryCompilation
virtual ALIB_DLL bool TryCompilation(CIAutoCast &ciAutoCast) override
alib::expressions::plugins::AutoCast::AutoCast
ALIB_DLL AutoCast(Compiler &compiler)