OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::client::expr Struct Reference
Collaboration diagram for Slic3r::client::expr:

Classes

union  Data

Public Types

enum  Type {
  TYPE_EMPTY = 0 , TYPE_BOOL , TYPE_INT , TYPE_DOUBLE ,
  TYPE_STRING
}
enum class  Deferred : unsigned char { None , Value , Text }
enum  Function2ParamsType { FUNCTION_MIN , FUNCTION_MAX }

Public Member Functions

 expr ()
 expr (const expr &rhs)
 expr (expr &&rhs)
 expr (bool b)
 expr (bool b, const Iterator &it_begin, const Iterator &it_end)
 expr (int i)
 expr (int i, const Iterator &it_begin, const Iterator &it_end)
 expr (double d)
 expr (double d, const Iterator &it_begin, const Iterator &it_end)
 expr (const char *s)
 expr (const std::string &s)
 expr (std::string &&s)
 expr (const std::string &s, const Iterator &it_begin, const Iterator &it_end)
 expr (expr &&rhs, const Iterator &it_begin, const Iterator &it_end)
expr & operator= (const expr &rhs)
expr & operator= (expr &&rhs)
void reset ()
 ~expr ()
Type type () const
bool numeric_type () const
bool deferred () const
void set_deferred (Deferred deferred)
bool & b ()
bool b () const
void set_b (bool v)
void set_b_lite (bool v)
int & i ()
int i () const
void set_i (int v)
void set_i_lite (int v)
int as_i () const
int as_i_rounded () const
double & d ()
double d () const
void set_d (double v)
void set_d_lite (double v)
double as_d () const
std::string & s ()
const std::string & s () const
void set_s (const std::string &s)
void set_s (std::string &&s)
void set_s (const char *s)
std::string to_string () const
expr unary_minus (const Iterator start_pos) const
expr unary_integer (const Iterator start_pos) const
expr round (const Iterator start_pos) const
expr floor (const Iterator start_pos) const
expr ceil (const Iterator start_pos) const
expr unary_not (const Iterator start_pos) const
expr & operator+= (const expr &rhs)
expr & operator-= (const expr &rhs)
expr & operator*= (const expr &rhs)
expr & operator/= (const expr &rhs)
expr & operator%= (const expr &rhs)
void throw_exception (const char *message) const
void throw_if_not_numeric (const char *message) const
void throw_if_deferred () const

Static Public Member Functions

static void to_string2 (expr &self, std::string &out)
static void evaluate_boolean (expr &self, bool &out)
static void evaluate_boolean_to_string (expr &self, std::string &out)
static void compare_op (expr &lhs, expr &rhs, char op, bool invert)
static void equal (expr &lhs, expr &rhs)
static void not_equal (expr &lhs, expr &rhs)
static void lower (expr &lhs, expr &rhs)
static void greater (expr &lhs, expr &rhs)
static void leq (expr &lhs, expr &rhs)
static void geq (expr &lhs, expr &rhs)
static void throw_if_not_numeric (const expr &param)
static void function_2params (expr &param1, expr &param2, Function2ParamsType fun)
static void min (expr &param1, expr &param2)
static void max (expr &param1, expr &param2)
static void random (expr &param1, expr &param2, std::mt19937 &rng)
template<bool leading_zeros>
static void digits (expr &param1, expr &param2, expr &param3)
static void regex_op (const expr &lhs, IteratorRange &rhs, char op, expr &out)
static void regex_matches (expr &lhs, IteratorRange &rhs)
static void regex_doesnt_match (expr &lhs, IteratorRange &rhs)
static void regex_replace (expr &subject, IteratorRange &pattern, expr &replacement)
static void one_of_test_init (expr &out)
template<bool RegEx>
static void one_of_test (const expr &match, const expr &pattern, expr &out)
static void one_of_test_regex (const expr &match, IteratorRange &pattern, expr &out)
static void logical_op (expr &lhs, expr &rhs, char op)
static void logical_or (expr &lhs, expr &rhs)
static void logical_and (expr &lhs, expr &rhs)
static const char * deferred_message ()

Public Attributes

IteratorRange it_range

Private Member Functions

void set_s_take_ownership (std::string *s)

Private Attributes

Type m_type = TYPE_EMPTY
Deferred m_deferred = Deferred::None
union Slic3r::client::expr::Data m_data

Detailed Description

Member Enumeration Documentation

◆ Deferred

enum class Slic3r::client::expr::Deferred : unsigned char
strong
Enumerator
None 
Value 
Text 
315: unsigned char { None, Value, Text };
@ None
Definition SketchEngine.hpp:180

◆ Function2ParamsType

Enumerator
FUNCTION_MIN 
FUNCTION_MAX 
679 {
682 };
@ FUNCTION_MAX
Definition PlaceholderParser.cpp:681
@ FUNCTION_MIN
Definition PlaceholderParser.cpp:680

◆ Type

Enumerator
TYPE_EMPTY 
TYPE_BOOL 
TYPE_INT 
TYPE_DOUBLE 
TYPE_STRING 
305 {
306 TYPE_EMPTY = 0,
307 TYPE_BOOL,
308 TYPE_INT,
311 };
@ TYPE_INT
Definition PlaceholderParser.cpp:308
@ TYPE_BOOL
Definition PlaceholderParser.cpp:307
@ TYPE_STRING
Definition PlaceholderParser.cpp:310
@ TYPE_DOUBLE
Definition PlaceholderParser.cpp:309
@ TYPE_EMPTY
Definition PlaceholderParser.cpp:306

Constructor & Destructor Documentation

◆ expr() [1/14]

◆ expr() [2/14]

Slic3r::client::expr::expr ( const expr & rhs)
inline
246 : m_type(rhs.type()), it_range(rhs.it_range), m_deferred(rhs.m_deferred)
247 { if (rhs.type() == TYPE_STRING) m_data.s = new std::string(*rhs.m_data.s); else m_data.set(rhs.m_data); }
union Slic3r::client::expr::Data m_data
IteratorRange it_range
Definition PlaceholderParser.cpp:389
Type m_type
Definition PlaceholderParser.cpp:894
Deferred m_deferred
Definition PlaceholderParser.cpp:895

References expr(), it_range, m_data, m_deferred, m_type, Slic3r::client::expr::Data::s, type(), and TYPE_STRING.

Here is the call graph for this function:

◆ expr() [3/14]

Slic3r::client::expr::expr ( expr && rhs)
inline
248: expr(std::move(rhs), rhs.it_range.begin(), rhs.it_range.end()) {}
expr()
Definition PlaceholderParser.cpp:245

References expr(), and it_range.

Here is the call graph for this function:

◆ expr() [4/14]

Slic3r::client::expr::expr ( bool b)
inlineexplicit
250: m_type(TYPE_BOOL) { m_data.b = b; }
bool & b()
Definition PlaceholderParser.cpp:319

References b(), m_data, m_type, and TYPE_BOOL.

Here is the call graph for this function:

◆ expr() [5/14]

Slic3r::client::expr::expr ( bool b,
const Iterator & it_begin,
const Iterator & it_end )
inlineexplicit
251: m_type(TYPE_BOOL), it_range(it_begin, it_end) { m_data.b = b; }

References b(), it_range, m_data, m_type, and TYPE_BOOL.

Here is the call graph for this function:

◆ expr() [6/14]

Slic3r::client::expr::expr ( int i)
inlineexplicit
252: m_type(TYPE_INT) { m_data.i = i; }
int & i()
Definition PlaceholderParser.cpp:323

References i(), m_data, m_type, and TYPE_INT.

Here is the call graph for this function:

◆ expr() [7/14]

Slic3r::client::expr::expr ( int i,
const Iterator & it_begin,
const Iterator & it_end )
inlineexplicit
253: m_type(TYPE_INT), it_range(it_begin, it_end) { m_data.i = i; }

References i(), it_range, m_data, m_type, and TYPE_INT.

Here is the call graph for this function:

◆ expr() [8/14]

Slic3r::client::expr::expr ( double d)
inlineexplicit
254: m_type(TYPE_DOUBLE) { m_data.d = d; }
double & d()
Definition PlaceholderParser.cpp:329

References d(), m_data, m_type, and TYPE_DOUBLE.

Here is the call graph for this function:

◆ expr() [9/14]

Slic3r::client::expr::expr ( double d,
const Iterator & it_begin,
const Iterator & it_end )
inlineexplicit
255: m_type(TYPE_DOUBLE), it_range(it_begin, it_end) { m_data.d = d; }

References d(), it_range, m_data, m_type, and TYPE_DOUBLE.

Here is the call graph for this function:

◆ expr() [10/14]

Slic3r::client::expr::expr ( const char * s)
inlineexplicit
256: m_type(TYPE_STRING) { m_data.s = new std::string(s); }
std::string & s()
Definition PlaceholderParser.cpp:334

References m_data, m_type, s(), and TYPE_STRING.

Here is the call graph for this function:

◆ expr() [11/14]

Slic3r::client::expr::expr ( const std::string & s)
inlineexplicit
257: m_type(TYPE_STRING) { m_data.s = new std::string(s); }

References m_data, m_type, s(), and TYPE_STRING.

Here is the call graph for this function:

◆ expr() [12/14]

Slic3r::client::expr::expr ( std::string && s)
inlineexplicit
258: m_type(TYPE_STRING) { m_data.s = new std::string(std::move(s)); }

References m_data, m_type, s(), and TYPE_STRING.

Here is the call graph for this function:

◆ expr() [13/14]

Slic3r::client::expr::expr ( const std::string & s,
const Iterator & it_begin,
const Iterator & it_end )
inlineexplicit
259 :
260 m_type(TYPE_STRING), it_range(it_begin, it_end) { m_data.s = new std::string(s); }

References it_range, m_data, m_type, s(), and TYPE_STRING.

Here is the call graph for this function:

◆ expr() [14/14]

Slic3r::client::expr::expr ( expr && rhs,
const Iterator & it_begin,
const Iterator & it_end )
inlineexplicit
261 : m_type(rhs.type()), it_range{ it_begin, it_end }, m_deferred(rhs.m_deferred)
262 {
263 m_data.set(rhs.m_data);
264 rhs.m_type = TYPE_EMPTY;
265 rhs.m_deferred = Deferred::None;
266 }
@ None
Definition PlaceholderParser.cpp:315

References expr(), it_range, m_data, m_deferred, m_type, None, type(), and TYPE_EMPTY.

Here is the call graph for this function:

◆ ~expr()

Slic3r::client::expr::~expr ( )
inline
303{ reset(); }
void reset()
Definition PlaceholderParser.cpp:296

References reset().

Here is the call graph for this function:

Member Function Documentation

◆ as_d()

double Slic3r::client::expr::as_d ( ) const
inline
333{ return this->type() == TYPE_DOUBLE ? this->d() : double(this->i()); }
Type type() const
Definition PlaceholderParser.cpp:312

References d(), i(), type(), and TYPE_DOUBLE.

Referenced by Slic3r::client::InterpolateTableContext::add_pair(), compare_op(), digits(), Slic3r::client::InterpolateTableContext::evaluate(), function_2params(), operator%=(), operator*=(), operator+=(), operator-=(), operator/=(), random(), Slic3r::client::MyContext::scalar_variable_assign_scalar(), Slic3r::client::MyContext::vector_variable_assign_expr_with_count(), and Slic3r::client::MyContext::vector_variable_element_assign_scalar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ as_i()

int Slic3r::client::expr::as_i ( ) const
inline
327{ return this->type() == TYPE_INT ? this->i() : int(this->d()); }

References d(), i(), type(), and TYPE_INT.

Referenced by digits(), Slic3r::client::MyContext::filament_change(), function_2params(), random(), Slic3r::client::MyContext::scalar_variable_assign_scalar(), Slic3r::client::MyContext::vector_variable_assign_expr_with_count(), and Slic3r::client::MyContext::vector_variable_element_assign_scalar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ as_i_rounded()

int Slic3r::client::expr::as_i_rounded ( ) const
inline
328{ return this->type() == TYPE_INT ? this->i() : int(std::round(this->d())); }
expr round(const Iterator start_pos) const
Definition PlaceholderParser.cpp:427

References d(), i(), type(), and TYPE_INT.

Referenced by digits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ b() [1/2]

◆ b() [2/2]

bool Slic3r::client::expr::b ( ) const
inline
320{ return m_data.b; }

References m_data.

◆ ceil()

expr Slic3r::client::expr::ceil ( const Iterator start_pos) const
inline
461 {
462 switch (this->type()) {
463 case TYPE_INT:
464 return expr(this->i(), start_pos, this->it_range.end());
465 case TYPE_DOUBLE:
466 return expr(static_cast<int>(std::ceil(this->d())), start_pos, this->it_range.end());
467 default:
468 this->throw_exception(L("Cannot ceil a non-numeric value."));
469 }
470 assert(false);
471 // Suppress compiler warnings.
472 return expr();
473 }
#define L(s)
Definition ExtrusionEntity.cpp:25
void throw_exception(const char *message) const
Definition PlaceholderParser.cpp:870

References expr(), d(), i(), L, throw_exception(), type(), TYPE_DOUBLE, and TYPE_INT.

Referenced by Slic3r::client::FactorActions::ceil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_op()

void Slic3r::client::expr::compare_op ( expr & lhs,
expr & rhs,
char op,
bool invert )
inlinestatic
624 {
625 if (lhs.type() == TYPE_EMPTY)
626 // Inside an if / else block to be skipped
627 return;
628 lhs.throw_if_deferred();
629 rhs.throw_if_deferred();
630 bool value = false;
631 if (lhs.numeric_type() && rhs.numeric_type()) {
632 // Both types are numeric.
633 switch (op) {
634 case '=':
635 value = (lhs.type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE) ?
636 (std::abs(lhs.as_d() - rhs.as_d()) < 1e-8) : (lhs.i() == rhs.i());
637 break;
638 case '<':
639 value = (lhs.type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE) ?
640 (lhs.as_d() < rhs.as_d()) : (lhs.i() < rhs.i());
641 break;
642 case '>':
643 default:
644 value = (lhs.type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE) ?
645 (lhs.as_d() > rhs.as_d()) : (lhs.i() > rhs.i());
646 break;
647 }
648 } else if (lhs.type() == TYPE_BOOL && rhs.type() == TYPE_BOOL) {
649 // Both type are bool.
650 if (op != '=')
651 boost::throw_exception(qi::expectation_failure<Iterator>(
652 lhs.it_range.begin(), rhs.it_range.end(), spirit::info(std::string("*") + L("Cannot compare the types."))));
653 value = lhs.b() == rhs.b();
654 } else if (lhs.type() == TYPE_STRING || rhs.type() == TYPE_STRING) {
655 // One type is string, the other could be converted to string.
656 value = (op == '=') ? (lhs.to_string() == rhs.to_string()) :
657 (op == '<') ? (lhs.to_string() < rhs.to_string()) : (lhs.to_string() > rhs.to_string());
658 } else {
659 boost::throw_exception(qi::expectation_failure<Iterator>(
660 lhs.it_range.begin(), rhs.it_range.end(), spirit::info(std::string("*") + L("Cannot compare the types."))));
661 }
662 lhs.reset();
663 lhs.set_b_lite(invert ? ! value : value);
664 }

References expr(), as_d(), b(), i(), it_range, L, numeric_type(), reset(), set_b_lite(), throw_if_deferred(), to_string(), type(), TYPE_BOOL, TYPE_DOUBLE, TYPE_EMPTY, and TYPE_STRING.

Referenced by equal(), geq(), greater(), leq(), lower(), and not_equal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ d() [1/2]

double & Slic3r::client::expr::d ( )
inline
329{ return m_data.d; }

References m_data.

Referenced by expr(), expr(), as_d(), as_i(), as_i_rounded(), ceil(), floor(), function_2params(), operator%=(), operator/=(), Slic3r::client::operator<<(), round(), Slic3r::client::MyContext::scalar_variable_new_from_scalar_expression(), to_string(), unary_integer(), unary_minus(), and Slic3r::client::MyContext::vector_variable_new_from_array().

Here is the caller graph for this function:

◆ d() [2/2]

double Slic3r::client::expr::d ( ) const
inline
330{ return m_data.d; }

References m_data.

◆ deferred()

bool Slic3r::client::expr::deferred ( ) const
inline
316{ return m_deferred != Deferred::None; }

References m_deferred, and None.

Referenced by operator+=(), operator=(), set_deferred(), throw_exception(), and throw_if_deferred().

Here is the caller graph for this function:

◆ deferred_message()

const char * Slic3r::client::expr::deferred_message ( )
inlinestatic
865 {
866 return L("This value is known only after the G-code is generated. It can be printed, but not used in a calculation or a comparison.");
867 }

References L.

Referenced by throw_exception(), and throw_if_deferred().

Here is the caller graph for this function:

◆ digits()

template<bool leading_zeros>
void Slic3r::client::expr::digits ( expr & param1,
expr & param2,
expr & param3 )
inlinestatic
731 {
732 if (param1.type() == TYPE_EMPTY)
733 // Inside an if / else block to be skipped
734 return;
735 throw_if_not_numeric(param1);
736 if (param2.type() != TYPE_INT)
737 param2.throw_exception(L("digits: second parameter must be integer"));
738 bool has_decimals = param3.type() != TYPE_EMPTY;
739 if (has_decimals && param3.type() != TYPE_INT)
740 param3.throw_exception(L("digits: third parameter must be integer"));
741
742 char buf[256];
743 int ndigits = std::clamp(param2.as_i(), 0, 64);
744 if (has_decimals) {
745 // Format as double.
746 int decimals = std::clamp(param3.as_i(), 0, 64);
747 sprintf(buf, leading_zeros ? "%0*.*lf" : "%*.*lf", ndigits, decimals, param1.as_d());
748 } else
749 // Format as int.
750 sprintf(buf, leading_zeros ? "%0*d" : "%*d", ndigits, param1.as_i_rounded());
751 param1.set_s(buf);
752 }
static void throw_if_not_numeric(const expr &param)
Definition PlaceholderParser.cpp:673

References expr(), as_d(), as_i(), as_i_rounded(), L, set_s(), throw_exception(), throw_if_not_numeric(), type(), TYPE_EMPTY, and TYPE_INT.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equal()

void Slic3r::client::expr::equal ( expr & lhs,
expr & rhs )
inlinestatic
666{ compare_op(lhs, rhs, '=', false); }
static void compare_op(expr &lhs, expr &rhs, char op, bool invert)
Definition PlaceholderParser.cpp:623

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluate_boolean()

void Slic3r::client::expr::evaluate_boolean ( expr & self,
bool & out )
inlinestatic
605 {
606 if (self.type() != TYPE_EMPTY) {
607 // Not inside an if / else block to be skipped
608 if (self.type() != TYPE_BOOL)
609 self.throw_exception(L("Not a boolean expression"));
610 out = self.b();
611 }
612 }

References expr(), b(), L, throw_exception(), type(), TYPE_BOOL, and TYPE_EMPTY.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluate_boolean_to_string()

void Slic3r::client::expr::evaluate_boolean_to_string ( expr & self,
std::string & out )
inlinestatic
615 {
616 assert(self.type() != TYPE_EMPTY);
617 if (self.type() != TYPE_BOOL)
618 self.throw_exception(L("Not a boolean expression"));
619 out = self.b() ? "true" : "false";
620 }

References expr(), b(), L, throw_exception(), type(), TYPE_BOOL, and TYPE_EMPTY.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ floor()

expr Slic3r::client::expr::floor ( const Iterator start_pos) const
inline
446 {
447 switch (this->type()) {
448 case TYPE_INT:
449 return expr(this->i(), start_pos, this->it_range.end());
450 case TYPE_DOUBLE:
451 return expr(static_cast<int>(std::floor(this->d())), start_pos, this->it_range.end());
452 default:
453 this->throw_exception(L("Cannot floor a non-numeric value."));
454 }
455 assert(false);
456 // Suppress compiler warnings.
457 return expr();
458 }

References expr(), d(), i(), L, throw_exception(), type(), TYPE_DOUBLE, and TYPE_INT.

Referenced by Slic3r::client::FactorActions::floor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ function_2params()

void Slic3r::client::expr::function_2params ( expr & param1,
expr & param2,
Function2ParamsType fun )
inlinestatic
685 {
686 if (param1.type() == TYPE_EMPTY)
687 // Inside an if / else block to be skipped
688 return;
689 throw_if_not_numeric(param1);
690 throw_if_not_numeric(param2);
691 if (param1.type() == TYPE_DOUBLE || param2.type() == TYPE_DOUBLE) {
692 double d = 0.;
693 switch (fun) {
694 case FUNCTION_MIN: d = std::min(param1.as_d(), param2.as_d()); break;
695 case FUNCTION_MAX: d = std::max(param1.as_d(), param2.as_d()); break;
696 default: param1.throw_exception("Internal error: invalid function");
697 }
698 param1.set_d_lite(d);
699 } else {
700 int i = 0;
701 switch (fun) {
702 case FUNCTION_MIN: i = std::min(param1.as_i(), param2.as_i()); break;
703 case FUNCTION_MAX: i = std::max(param1.as_i(), param2.as_i()); break;
704 default: param1.throw_exception("Internal error: invalid function");
705 }
706 param1.set_i_lite(i);
707 }
708 }

References expr(), as_d(), as_i(), d(), FUNCTION_MAX, FUNCTION_MIN, i(), set_d_lite(), set_i_lite(), throw_exception(), throw_if_not_numeric(), type(), TYPE_DOUBLE, and TYPE_EMPTY.

Referenced by max(), and min().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ geq()

void Slic3r::client::expr::geq ( expr & lhs,
expr & rhs )
inlinestatic
671{ compare_op(lhs, rhs, '<', true ); }

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ greater()

void Slic3r::client::expr::greater ( expr & lhs,
expr & rhs )
inlinestatic
669{ compare_op(lhs, rhs, '>', false); }

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ i() [1/2]

◆ i() [2/2]

int Slic3r::client::expr::i ( ) const
inline
324{ return m_data.i; }

References m_data.

◆ leq()

void Slic3r::client::expr::leq ( expr & lhs,
expr & rhs )
inlinestatic
670{ compare_op(lhs, rhs, '>', true ); }

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logical_and()

void Slic3r::client::expr::logical_and ( expr & lhs,
expr & rhs )
inlinestatic
862{ logical_op(lhs, rhs, '&'); }
static void logical_op(expr &lhs, expr &rhs, char op)
Definition PlaceholderParser.cpp:845

References expr(), and logical_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logical_op()

void Slic3r::client::expr::logical_op ( expr & lhs,
expr & rhs,
char op )
inlinestatic
846 {
847 if (lhs.type() == TYPE_EMPTY)
848 // Inside an if / else block to be skipped
849 return;
850 lhs.throw_if_deferred();
851 rhs.throw_if_deferred();
852 bool value = false;
853 if (lhs.type() == TYPE_BOOL && rhs.type() == TYPE_BOOL) {
854 value = (op == '|') ? (lhs.b() || rhs.b()) : (lhs.b() && rhs.b());
855 } else {
856 boost::throw_exception(qi::expectation_failure<Iterator>(
857 lhs.it_range.begin(), rhs.it_range.end(), spirit::info(std::string("*") + L("Cannot apply logical operation to non-boolean operands."))));
858 }
859 lhs.set_b_lite(value);
860 }

References expr(), b(), it_range, L, set_b_lite(), throw_if_deferred(), type(), TYPE_BOOL, and TYPE_EMPTY.

Referenced by logical_and(), and logical_or().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logical_or()

void Slic3r::client::expr::logical_or ( expr & lhs,
expr & rhs )
inlinestatic
861{ logical_op(lhs, rhs, '|'); }

References expr(), and logical_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lower()

void Slic3r::client::expr::lower ( expr & lhs,
expr & rhs )
inlinestatic
668{ compare_op(lhs, rhs, '<', false); }

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max()

void Slic3r::client::expr::max ( expr & param1,
expr & param2 )
inlinestatic
711{ function_2params(param1, param2, FUNCTION_MAX); }
static void function_2params(expr &param1, expr &param2, Function2ParamsType fun)
Definition PlaceholderParser.cpp:684

References expr(), function_2params(), and FUNCTION_MAX.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ min()

void Slic3r::client::expr::min ( expr & param1,
expr & param2 )
inlinestatic
710{ function_2params(param1, param2, FUNCTION_MIN); }

References expr(), function_2params(), and FUNCTION_MIN.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ not_equal()

void Slic3r::client::expr::not_equal ( expr & lhs,
expr & rhs )
inlinestatic
667{ compare_op(lhs, rhs, '=', true ); }

References expr(), and compare_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numeric_type()

bool Slic3r::client::expr::numeric_type ( ) const
inline
313{ return m_type == TYPE_INT || m_type == TYPE_DOUBLE; }

References m_type, TYPE_DOUBLE, and TYPE_INT.

Referenced by Slic3r::client::InterpolateTableContext::add_pair(), Slic3r::client::MyContext::check_numeric(), compare_op(), Slic3r::client::InterpolateTableContext::init(), and throw_if_not_numeric().

Here is the caller graph for this function:

◆ one_of_test()

template<bool RegEx>
void Slic3r::client::expr::one_of_test ( const expr & match,
const expr & pattern,
expr & out )
inlinestatic
808 {
809 if (match.type() == TYPE_EMPTY) {
810 // Inside an if / else block to be skipped
811 out.reset();
812 return;
813 }
814 if (! out.b()) {
815 match.throw_if_deferred();
816 pattern.throw_if_deferred();
817 if (match.type() != TYPE_STRING)
818 match.throw_exception(L("one_of(): First parameter (the string to match against) has to be a string value"));
819 if (pattern.type() != TYPE_STRING)
820 match.throw_exception(L("one_of(): Pattern has to be a string value"));
821 if (RegEx) {
822 try {
823 out.set_b(SLIC3R_REGEX_NAMESPACE::regex_match(match.s(), SLIC3R_REGEX_NAMESPACE::regex(pattern.s())));
824 } catch (SLIC3R_REGEX_NAMESPACE::regex_error &) {
825 // Syntax error in the regular expression
826 pattern.throw_exception(L("Regular expression compilation failed"));
827 }
828 } else
829 out.set_b(match.s() == pattern.s());
830 }
831 }

References expr(), b(), L, reset(), s(), set_b(), throw_exception(), throw_if_deferred(), type(), TYPE_EMPTY, and TYPE_STRING.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ one_of_test_init()

void Slic3r::client::expr::one_of_test_init ( expr & out)
inlinestatic
804 {
805 out.set_b(false);
806 }

References expr(), and set_b().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ one_of_test_regex()

void Slic3r::client::expr::one_of_test_regex ( const expr & match,
IteratorRange & pattern,
expr & out )
inlinestatic
832 {
833 if (match.type() == TYPE_EMPTY) {
834 // Inside an if / else block to be skipped
835 out.reset();
836 return;
837 }
838 if (! out.b()) {
839 if (match.type() != TYPE_STRING)
840 match.throw_exception(L("one_of(): First parameter (the string to match against) has to be a string value"));
841 regex_op(match, pattern, '=', out);
842 }
843 }
static void regex_op(const expr &lhs, IteratorRange &rhs, char op, expr &out)
Definition PlaceholderParser.cpp:754

References expr(), b(), L, regex_op(), reset(), throw_exception(), type(), TYPE_EMPTY, and TYPE_STRING.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator%=()

expr & Slic3r::client::expr::operator%= ( const expr & rhs)
inline
579 {
580 if (this->type() == TYPE_EMPTY) {
581 // Inside an if / else block to be skipped.
582 this->reset();
583 } else {
584 this->throw_if_not_numeric(L("Cannot divide a non-numeric type."));
585 rhs.throw_if_not_numeric(L("Cannot divide with a non-numeric type."));
586 if (rhs.type() == TYPE_INT ? (rhs.i() == 0) : (rhs.d() == 0.))
587 rhs.throw_exception(L("Division by zero"));
588 if (this->type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE)
589 this->set_d_lite(std::fmod(this->as_d(), rhs.as_d()));
590 else
591 m_data.i %= rhs.i();
592 this->it_range = IteratorRange(this->it_range.begin(), rhs.it_range.end());
593 }
594 return *this;
595 }
boost::iterator_range< Iterator > IteratorRange
Definition PlaceholderParser.cpp:222
double as_d() const
Definition PlaceholderParser.cpp:333
void set_d_lite(double v)
Definition PlaceholderParser.cpp:332

References expr(), as_d(), d(), i(), it_range, L, m_data, reset(), set_d_lite(), throw_exception(), throw_if_not_numeric(), type(), TYPE_DOUBLE, TYPE_EMPTY, and TYPE_INT.

Here is the call graph for this function:

◆ operator*=()

expr & Slic3r::client::expr::operator*= ( const expr & rhs)
inline
542 {
543 if (this->type() == TYPE_EMPTY) {
544 // Inside an if / else block to be skipped.
545 this->reset();
546 } else {
547 const char *err_msg = L("Cannot multiply with non-numeric type.");
548 this->throw_if_not_numeric(err_msg);
549 rhs.throw_if_not_numeric(err_msg);
550 if (this->type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE)
551 this->set_d_lite(this->as_d() * rhs.as_d());
552 else
553 m_data.i *= rhs.i();
554 this->it_range = IteratorRange(this->it_range.begin(), rhs.it_range.end());
555 }
556 return *this;
557 }

References expr(), as_d(), i(), it_range, L, m_data, reset(), set_d_lite(), throw_if_not_numeric(), type(), TYPE_DOUBLE, and TYPE_EMPTY.

Here is the call graph for this function:

◆ operator+=()

expr & Slic3r::client::expr::operator+= ( const expr & rhs)
inline
492 {
493 if (this->type() == TYPE_EMPTY) {
494 // Inside an if / else block to be skipped.
495 } else if (m_deferred == Deferred::Value && (rhs.type() != TYPE_STRING || rhs.m_deferred == Deferred::Value)) {
496 // A deferred value added to a number or to another deferred value is meant as a sum.
497 this->throw_if_deferred();
498 } else if (rhs.m_deferred == Deferred::Value && this->type() != TYPE_STRING) {
499 rhs.throw_if_deferred();
500 } else if (this->type() == TYPE_STRING) {
501 // Convert the right hand side to string and append.
502 *m_data.s += rhs.to_string();
503 if (this->deferred() || rhs.deferred())
505 } else if (rhs.type() == TYPE_STRING) {
506 // Conver the left hand side to string, append rhs.
507 this->set_s(this->to_string() + rhs.s());
508 if (rhs.deferred())
510 } else {
511 const char *err_msg = L("Cannot add non-numeric types.");
512 this->throw_if_not_numeric(err_msg);
513 rhs.throw_if_not_numeric(err_msg);
514 if (this->type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE)
515 this->set_d_lite(this->as_d() + rhs.as_d());
516 else
517 m_data.i += rhs.i();
518 }
519 this->it_range = IteratorRange(this->it_range.begin(), rhs.it_range.end());
520 return *this;
521 }
bool deferred() const
Definition PlaceholderParser.cpp:316
void set_s(const std::string &s)
Definition PlaceholderParser.cpp:336
@ Value
Definition PlaceholderParser.cpp:315
@ Text
Definition PlaceholderParser.cpp:315
void throw_if_deferred() const
Definition PlaceholderParser.cpp:884
std::string to_string() const
Definition PlaceholderParser.cpp:358

References expr(), as_d(), deferred(), i(), it_range, L, m_data, m_deferred, s(), set_d_lite(), set_s(), Text, throw_if_deferred(), throw_if_not_numeric(), to_string(), type(), TYPE_DOUBLE, TYPE_EMPTY, TYPE_STRING, and Value.

Here is the call graph for this function:

◆ operator-=()

expr & Slic3r::client::expr::operator-= ( const expr & rhs)
inline
524 {
525 if (this->type() == TYPE_EMPTY) {
526 // Inside an if / else block to be skipped.
527 this->reset();
528 } else {
529 const char *err_msg = L("Cannot subtract non-numeric types.");
530 this->throw_if_not_numeric(err_msg);
531 rhs.throw_if_not_numeric(err_msg);
532 if (this->type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE)
533 this->set_d_lite(this->as_d() - rhs.as_d());
534 else
535 m_data.i -= rhs.i();
536 this->it_range = IteratorRange(this->it_range.begin(), rhs.it_range.end());
537 }
538 return *this;
539 }

References expr(), as_d(), i(), it_range, L, m_data, reset(), set_d_lite(), throw_if_not_numeric(), type(), TYPE_DOUBLE, and TYPE_EMPTY.

Here is the call graph for this function:

◆ operator/=()

expr & Slic3r::client::expr::operator/= ( const expr & rhs)
inline
560 {
561 if (this->type() == TYPE_EMPTY) {
562 // Inside an if / else block to be skipped.
563 this->reset();
564 } else {
565 this->throw_if_not_numeric(L("Cannot divide a non-numeric type."));
566 rhs.throw_if_not_numeric(L("Cannot divide with a non-numeric type."));
567 if (rhs.type() == TYPE_INT ? (rhs.i() == 0) : (rhs.d() == 0.))
568 rhs.throw_exception(L("Division by zero"));
569 if (this->type() == TYPE_DOUBLE || rhs.type() == TYPE_DOUBLE)
570 this->set_d_lite(this->as_d() / rhs.as_d());
571 else
572 m_data.i /= rhs.i();
573 this->it_range = IteratorRange(this->it_range.begin(), rhs.it_range.end());
574 }
575 return *this;
576 }

References expr(), as_d(), d(), i(), it_range, L, m_data, reset(), set_d_lite(), throw_exception(), throw_if_not_numeric(), type(), TYPE_DOUBLE, TYPE_EMPTY, and TYPE_INT.

Here is the call graph for this function:

◆ operator=() [1/2]

expr & Slic3r::client::expr::operator= ( const expr & rhs)
inline
268 {
269 // set_s() clears m_deferred, which is also rhs.m_deferred on a self-assignment.
270 const Deferred deferred = rhs.m_deferred;
271 if (rhs.type() == TYPE_STRING) {
272 this->set_s(rhs.s());
273 } else {
274 m_type = rhs.type();
275 m_data.set(rhs.m_data);
276 }
277 this->it_range = rhs.it_range;
279 return *this;
280 }
Deferred
Definition PlaceholderParser.cpp:315

References expr(), deferred(), it_range, m_data, m_deferred, m_type, s(), set_s(), type(), and TYPE_STRING.

Here is the call graph for this function:

◆ operator=() [2/2]

expr & Slic3r::client::expr::operator= ( expr && rhs)
inline
283 {
284 if (this != &rhs) {
285 this->reset();
286 m_type = rhs.type();
287 this->it_range = rhs.it_range;
288 m_deferred = rhs.m_deferred;
289 m_data.set(rhs.m_data);
290 rhs.m_type = TYPE_EMPTY;
291 rhs.m_deferred = Deferred::None;
292 }
293 return *this;
294 }

References expr(), it_range, m_data, m_deferred, m_type, None, reset(), and TYPE_EMPTY.

Here is the call graph for this function:

◆ random()

void Slic3r::client::expr::random ( expr & param1,
expr & param2,
std::mt19937 & rng )
inlinestatic
715 {
716 if (param1.type() == TYPE_EMPTY)
717 // Inside an if / else block to be skipped
718 return;
719 throw_if_not_numeric(param1);
720 throw_if_not_numeric(param2);
721 if (param1.type() == TYPE_DOUBLE || param2.type() == TYPE_DOUBLE)
722 param1.set_d_lite(std::uniform_real_distribution<>(param1.as_d(), param2.as_d())(rng));
723 else
724 param1.set_i_lite(std::uniform_int_distribution<>(param1.as_i(), param2.as_i())(rng));
725 }

References expr(), as_d(), as_i(), set_d_lite(), set_i_lite(), throw_if_not_numeric(), type(), TYPE_DOUBLE, and TYPE_EMPTY.

Referenced by Slic3r::client::MyContext::random().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regex_doesnt_match()

void Slic3r::client::expr::regex_doesnt_match ( expr & lhs,
IteratorRange & rhs )
inlinestatic
781{ return regex_op(lhs, rhs, '!', lhs); }

References expr(), and regex_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regex_matches()

void Slic3r::client::expr::regex_matches ( expr & lhs,
IteratorRange & rhs )
inlinestatic
780{ return regex_op(lhs, rhs, '=', lhs); }

References expr(), and regex_op().

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regex_op()

void Slic3r::client::expr::regex_op ( const expr & lhs,
IteratorRange & rhs,
char op,
expr & out )
inlinestatic
755 {
756 if (lhs.type() == TYPE_EMPTY)
757 // Inside an if / else block to be skipped
758 return;
759 lhs.throw_if_deferred();
760 const std::string *subject = nullptr;
761 if (lhs.type() == TYPE_STRING) {
762 // One type is string, the other could be converted to string.
763 subject = &lhs.s();
764 } else {
765 lhs.throw_exception(L("Left hand side of a regex match must be a string."));
766 }
767 try {
768 std::string pattern(++ rhs.begin(), -- rhs.end());
769 bool result = SLIC3R_REGEX_NAMESPACE::regex_match(*subject, SLIC3R_REGEX_NAMESPACE::regex(pattern));
770 if (op == '!')
771 result = ! result;
772 out.set_b(result);
773 } catch (SLIC3R_REGEX_NAMESPACE::regex_error &ex) {
774 // Syntax error in the regular expression
775 boost::throw_exception(qi::expectation_failure<Iterator>(
776 rhs.begin(), rhs.end(), spirit::info("*" + Slic3r::format(_u8L("Regular expression compilation failed: %1%"), ex.what()))));
777 }
778 }
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
#define _u8L(s)
Definition I18N.hpp:11

References expr(), _u8L, Slic3r::format(), L, s(), set_b(), throw_exception(), throw_if_deferred(), type(), TYPE_EMPTY, and TYPE_STRING.

Referenced by one_of_test_regex(), regex_doesnt_match(), and regex_matches().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regex_replace()

void Slic3r::client::expr::regex_replace ( expr & subject,
IteratorRange & pattern,
expr & replacement )
inlinestatic
786 {
787 if (subject.type() == TYPE_EMPTY)
788 // Inside an if / else block to be skipped
789 return;
790 subject.throw_if_deferred();
791 if (subject.type() != TYPE_STRING)
792 subject.throw_exception(L("regex_replace() first parameter must be a string."));
793 try {
794 std::string re(++ pattern.begin(), -- pattern.end());
795 std::string result = SLIC3R_REGEX_NAMESPACE::regex_replace(subject.s(), SLIC3R_REGEX_NAMESPACE::regex(re), replacement.to_string());
796 subject.set_s(std::move(result));
797 } catch (SLIC3R_REGEX_NAMESPACE::regex_error &ex) {
798 // Syntax error in the regular expression
799 boost::throw_exception(qi::expectation_failure<Iterator>(
800 pattern.begin(), pattern.end(), spirit::info("*" + Slic3r::format(_u8L("Regular expression compilation failed: %1%"), ex.what()))));
801 }
802 }

References expr(), _u8L, Slic3r::format(), L, s(), set_s(), throw_exception(), throw_if_deferred(), to_string(), type(), TYPE_EMPTY, and TYPE_STRING.

Referenced by Slic3r::client::MyContext::regex_replace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void Slic3r::client::expr::reset ( )
inline
297 {
298 if (this->type() == TYPE_STRING)
299 delete m_data.s;
302 }

References m_data, m_deferred, m_type, None, type(), TYPE_EMPTY, and TYPE_STRING.

Referenced by ~expr(), Slic3r::client::FactorActions::bool_(), compare_op(), Slic3r::client::FactorActions::double_(), Slic3r::client::FactorActions::int_(), Slic3r::client::FactorActions::noexpr(), one_of_test(), one_of_test_regex(), operator%=(), operator*=(), operator-=(), operator/=(), operator=(), set_b(), set_d(), set_i(), and Slic3r::client::FactorActions::string_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ round()

expr Slic3r::client::expr::round ( const Iterator start_pos) const
inline
428 {
429 switch (this->type()) {
430 case TYPE_EMPTY:
431 // Inside an if / else block to be skipped.
432 return expr();
433 case TYPE_INT:
434 return expr(this->i(), start_pos, this->it_range.end());
435 case TYPE_DOUBLE:
436 return expr(static_cast<int>(std::round(this->d())), start_pos, this->it_range.end());
437 default:
438 this->throw_exception(L("Cannot round a non-numeric value."));
439 }
440 assert(false);
441 // Suppress compiler warnings.
442 return expr();
443 }

References expr(), d(), i(), L, throw_exception(), type(), TYPE_DOUBLE, TYPE_EMPTY, and TYPE_INT.

Referenced by Slic3r::client::FactorActions::round().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ s() [1/2]

std::string & Slic3r::client::expr::s ( )
inline

◆ s() [2/2]

const std::string & Slic3r::client::expr::s ( ) const
inline
335{ return *m_data.s; }

References m_data.

◆ set_b()

void Slic3r::client::expr::set_b ( bool v)
inline
321{ this->reset(); this->set_b_lite(v); }
void set_b_lite(bool v)
Definition PlaceholderParser.cpp:322

References reset(), and set_b_lite().

Referenced by Slic3r::client::MyContext::is_nil_test(), Slic3r::client::MyContext::is_vector_empty(), one_of_test(), one_of_test_init(), regex_op(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::client::MyContext::vector_element_to_expr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_b_lite()

void Slic3r::client::expr::set_b_lite ( bool v)
inline
322{ assert(this->type() != TYPE_STRING); Data tmp; tmp.b = v; m_data.set(tmp); m_type = TYPE_BOOL; }
Definition PlaceholderParser.cpp:897
bool b
Definition PlaceholderParser.cpp:898

References Slic3r::client::expr::Data::b, m_data, m_type, type(), TYPE_BOOL, and TYPE_STRING.

Referenced by compare_op(), logical_op(), and set_b().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_d()

void Slic3r::client::expr::set_d ( double v)
inline
331{ this->reset(); this->set_d_lite(v); }

References reset(), and set_d_lite().

Referenced by Slic3r::client::InterpolateTableContext::evaluate(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::client::MyContext::vector_element_to_expr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_d_lite()

void Slic3r::client::expr::set_d_lite ( double v)
inline
332{ assert(this->type() != TYPE_STRING); Data tmp; tmp.d = v; m_data.set(tmp); m_type = TYPE_DOUBLE; }
double d
Definition PlaceholderParser.cpp:900

References Slic3r::client::expr::Data::d, m_data, m_type, type(), TYPE_DOUBLE, and TYPE_STRING.

Referenced by function_2params(), operator%=(), operator*=(), operator+=(), operator-=(), operator/=(), random(), and set_d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_deferred()

void Slic3r::client::expr::set_deferred ( Deferred deferred)
inline
317{ m_deferred = deferred; }

References deferred(), and m_deferred.

Referenced by Slic3r::client::MyContext::mark_deferred().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_i()

void Slic3r::client::expr::set_i ( int v)
inline
325{ this->reset(); set_i_lite(v); }
void set_i_lite(int v)
Definition PlaceholderParser.cpp:326

References reset(), and set_i_lite().

Referenced by Slic3r::client::MyContext::scalar_variable_to_expr(), Slic3r::client::MyContext::vector_element_to_expr(), and Slic3r::client::MyContext::vector_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_i_lite()

void Slic3r::client::expr::set_i_lite ( int v)
inline
326{ assert(this->type() != TYPE_STRING); Data tmp; tmp.i = v; m_data.set(tmp); m_type = TYPE_INT; }
int i
Definition PlaceholderParser.cpp:899

References Slic3r::client::expr::Data::i, m_data, m_type, type(), TYPE_INT, and TYPE_STRING.

Referenced by function_2params(), random(), and set_i().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_s() [1/3]

void Slic3r::client::expr::set_s ( const char * s)
inline
350 {
352 if (this->type() == TYPE_STRING)
353 *m_data.s = s;
354 else
355 this->set_s_take_ownership(new std::string(s));
356 }
void set_s_take_ownership(std::string *s)
Definition PlaceholderParser.cpp:892

References m_data, m_deferred, None, s(), set_s_take_ownership(), type(), and TYPE_STRING.

Here is the call graph for this function:

◆ set_s() [2/3]

void Slic3r::client::expr::set_s ( const std::string & s)
inline
336 {
338 if (this->type() == TYPE_STRING)
339 *m_data.s = s;
340 else
341 this->set_s_take_ownership(new std::string(s));
342 }

References m_data, m_deferred, None, s(), set_s_take_ownership(), type(), and TYPE_STRING.

Referenced by digits(), operator+=(), operator=(), regex_replace(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::client::MyContext::vector_element_to_expr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_s() [3/3]

void Slic3r::client::expr::set_s ( std::string && s)
inline
343 {
345 if (this->type() == TYPE_STRING)
346 *m_data.s = std::move(s);
347 else
348 this->set_s_take_ownership(new std::string(std::move(s)));
349 }

References m_data, m_deferred, None, s(), set_s_take_ownership(), type(), and TYPE_STRING.

Here is the call graph for this function:

◆ set_s_take_ownership()

void Slic3r::client::expr::set_s_take_ownership ( std::string * s)
inlineprivate
892{ assert(this->type() != TYPE_STRING); Data tmp; tmp.s = s; m_data.set(tmp); m_type = TYPE_STRING; }
std::string * s
Definition PlaceholderParser.cpp:901

References m_data, m_type, Slic3r::client::expr::Data::s, s(), type(), and TYPE_STRING.

Referenced by set_s(), set_s(), and set_s().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ throw_exception()

void Slic3r::client::expr::throw_exception ( const char * message) const
inline
871 {
872 if (this->deferred())
873 message = deferred_message();
874 boost::throw_exception(qi::expectation_failure<Iterator>(
875 this->it_range.begin(), this->it_range.end(), spirit::info(std::string("*") + message)));
876 }
static const char * deferred_message()
Definition PlaceholderParser.cpp:864

References deferred(), and deferred_message().

Referenced by Slic3r::client::InterpolateTableContext::add_pair(), ceil(), Slic3r::client::MyContext::check_numeric(), digits(), Slic3r::client::InterpolateTableContext::evaluate(), evaluate_boolean(), evaluate_boolean_to_string(), Slic3r::client::MyContext::evaluate_count(), Slic3r::client::MyContext::evaluate_index(), floor(), function_2params(), Slic3r::client::InterpolateTableContext::init(), one_of_test(), one_of_test_regex(), operator%=(), operator/=(), regex_op(), regex_replace(), round(), throw_if_deferred(), throw_if_not_numeric(), unary_integer(), unary_minus(), unary_not(), and Slic3r::client::MyContext::vector_variable_assign_expr_with_count().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ throw_if_deferred()

void Slic3r::client::expr::throw_if_deferred ( ) const
inline
885 {
886 if (this->deferred())
888 }

References deferred(), deferred_message(), and throw_exception().

Referenced by compare_op(), Slic3r::client::MyContext::filament_change(), logical_op(), one_of_test(), operator+=(), regex_op(), and regex_replace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ throw_if_not_numeric() [1/2]

void Slic3r::client::expr::throw_if_not_numeric ( const char * message) const
inline
879 {
880 if (! this->numeric_type())
881 this->throw_exception(message);
882 }
bool numeric_type() const
Definition PlaceholderParser.cpp:313

References numeric_type(), and throw_exception().

Here is the call graph for this function:

◆ throw_if_not_numeric() [2/2]

void Slic3r::client::expr::throw_if_not_numeric ( const expr & param)
inlinestatic
674 {
675 const char *err_msg = L("Not a numeric type.");
676 param.throw_if_not_numeric(err_msg);
677 }

References expr(), L, and throw_if_not_numeric().

Referenced by digits(), function_2params(), operator%=(), operator*=(), operator+=(), operator-=(), operator/=(), random(), and throw_if_not_numeric().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

std::string Slic3r::client::expr::to_string ( ) const
inline
359 {
360 std::string out;
361 switch (this->type()) {
362 case TYPE_EMPTY:
363 // Inside an if / else block to be skipped.
364 break;
365 case TYPE_BOOL: out = this->b() ? "true" : "false"; break;
366 case TYPE_INT: out = std::to_string(this->i()); break;
367 case TYPE_DOUBLE:
368#if 0
369 // The default converter produces trailing zeros after the decimal point.
370 out = std::to_string(data.d);
371#else
372 // ostringstream default converter produces no trailing zeros after the decimal point.
373 // It seems to be doing what the old boost::to_string() did.
374 {
375 std::ostringstream ss;
376 ss << this->d();
377 out = ss.str();
378 }
379#endif
380 break;
381 case TYPE_STRING: out = this->s(); break;
382 default: break;
383 }
384 return out;
385 }

References b(), d(), i(), s(), type(), TYPE_BOOL, TYPE_DOUBLE, TYPE_EMPTY, TYPE_INT, and TYPE_STRING.

Referenced by compare_op(), operator+=(), regex_replace(), Slic3r::client::MyContext::scalar_variable_assign_scalar(), to_string2(), Slic3r::client::MyContext::vector_variable_assign_expr_with_count(), and Slic3r::client::MyContext::vector_variable_element_assign_scalar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string2()

void Slic3r::client::expr::to_string2 ( expr & self,
std::string & out )
inlinestatic
598 {
599 if (self.type() != TYPE_EMPTY)
600 // Not inside an if / else block to be skipped
601 out = self.to_string();
602 }

References expr(), to_string(), type(), and TYPE_EMPTY.

Referenced by Slic3r::client::macro_processor::macro_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

◆ unary_integer()

expr Slic3r::client::expr::unary_integer ( const Iterator start_pos) const
inline
410 {
411 switch (this->type()) {
412 case TYPE_EMPTY:
413 // Inside an if / else block to be skipped.
414 return expr();
415 case TYPE_INT:
416 return expr(this->i(), start_pos, this->it_range.end());
417 case TYPE_DOUBLE:
418 return expr(static_cast<int>(this->d()), start_pos, this->it_range.end());
419 default:
420 this->throw_exception(L("Cannot convert to integer."));
421 }
422 assert(false);
423 // Suppress compiler warnings.
424 return expr();
425 }

References expr(), d(), i(), L, throw_exception(), type(), TYPE_DOUBLE, TYPE_EMPTY, and TYPE_INT.

Referenced by Slic3r::client::FactorActions::to_int().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unary_minus()

expr Slic3r::client::expr::unary_minus ( const Iterator start_pos) const
inline
392 {
393 switch (this->type()) {
394 case TYPE_EMPTY:
395 // Inside an if / else block to be skipped.
396 return expr();
397 case TYPE_INT :
398 return expr(- this->i(), start_pos, this->it_range.end());
399 case TYPE_DOUBLE:
400 return expr(- this->d(), start_pos, this->it_range.end());
401 default:
402 this->throw_exception(L("Cannot apply unary minus operator."));
403 }
404 assert(false);
405 // Suppress compiler warnings.
406 return expr();
407 }

References expr(), d(), i(), L, throw_exception(), type(), TYPE_DOUBLE, TYPE_EMPTY, and TYPE_INT.

Referenced by Slic3r::client::FactorActions::minus_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unary_not()

expr Slic3r::client::expr::unary_not ( const Iterator start_pos) const
inline
476 {
477 switch (this->type()) {
478 case TYPE_EMPTY:
479 // Inside an if / else block to be skipped.
480 return expr();
481 case TYPE_BOOL:
482 return expr(! this->b(), start_pos, this->it_range.end());
483 default:
484 this->throw_exception(L("Cannot apply a not operator."));
485 }
486 assert(false);
487 // Suppress compiler warnings.
488 return expr();
489 }

References expr(), b(), L, throw_exception(), type(), TYPE_BOOL, and TYPE_EMPTY.

Referenced by Slic3r::client::FactorActions::not_().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ it_range

◆ m_data

◆ m_deferred

Deferred Slic3r::client::expr::m_deferred = Deferred::None
private

◆ m_type


The documentation for this struct was generated from the following file: