ALib C++ Library
by
Library Version:
2412 R0
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
#pragma once
11
#include "
alib/expressions/compilerplugin.hpp
"
12
13
14
namespace
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
//==================================================================================================
40
struct
AutoCast
:
public
CompilerPlugin
41
{
42
//==============================================================================================
43
/// Constructor.
44
/// @param compiler The compiler we will get attached to.
45
//==============================================================================================
46
ALIB_API
AutoCast
(
Compiler
& compiler );
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
//==============================================================================================
60
ALIB_API
61
virtual
bool
TryCompilation
(
CIAutoCast
& ciAutoCast )
override
;
62
};
63
64
}}}
// namespace [alib::expressions::detail]
65
66
#endif
// HPP_ALIB_EXPRESSIONS_PLUGINS_AUTOCAST
67
alib::expressions::Compiler
Definition
compiler.hpp:69
compilerplugin.hpp
ALIB_API
#define ALIB_API
Definition
alib.hpp:639
alib
Definition
alib.cpp:69
alib::expressions::CompilerPlugin::CIAutoCast
Definition
compilerplugin.hpp:403
alib::expressions::CompilerPlugin
Definition
compilerplugin.hpp:99
alib::expressions::plugins::AutoCast
Definition
autocast.hpp:41
alib::expressions::plugins::AutoCast::~AutoCast
virtual ~AutoCast() override
Virtual destructor.
Definition
autocast.hpp:51
alib::expressions::plugins::AutoCast::TryCompilation
virtual ALIB_API bool TryCompilation(CIAutoCast &ciAutoCast) override
alib::expressions::plugins::AutoCast::AutoCast
ALIB_API AutoCast(Compiler &compiler)