Current Version: 1.0.10
Project Name: csspp
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
csspp::expression Class Reference

#include <expression.h>

Collaboration diagram for csspp::expression:
Collaboration graph
[legend]

Public Member Functions

 expression (node::pointer_t n)
 
node::pointer_t compile ()
 
void compile_args (bool divide_font_metrics)
 
void set_variable_handler (expression_variables_interface *handler)
 

Static Public Member Functions

static bool boolean (node::pointer_t n)
 Check whether a node represents true or false. More...
 
static int get_unique_id_counter ()
 
static void set_unique_id_counter (int counter)
 

Private Types

typedef std::vector< std::string > dimension_vector_t
 
typedef std::map< std::string,
node::pointer_t
variable_vector_t
 

Private Member Functions

node::pointer_t additive ()
 
node::pointer_t apply_power (node::pointer_t lhs, node::pointer_t rhs)
 
node::pointer_t assignment ()
 
node::pointer_t compile_list (node::pointer_t parent)
 
node::pointer_t conditional ()
 
void dimensions_to_vectors (position const &pos, std::string const &dimension, dimension_vector_t &dividend, dimension_vector_t &divisor)
 
bool end_of_nodes ()
 
node::pointer_t equality ()
 
node::pointer_t excecute_function (node::pointer_t func)
 
node::pointer_t expression_list ()
 
node::pointer_t internal_function__abs (node::pointer_t func)
 
node::pointer_t internal_function__acos (node::pointer_t func)
 
node::pointer_t internal_function__adjust_hue (node::pointer_t func)
 
node::pointer_t internal_function__alpha (node::pointer_t func)
 
node::pointer_t internal_function__asin (node::pointer_t func)
 
node::pointer_t internal_function__atan (node::pointer_t func)
 
node::pointer_t internal_function__blue (node::pointer_t func)
 
node::pointer_t internal_function__ceil (node::pointer_t func)
 
node::pointer_t internal_function__cos (node::pointer_t func)
 
node::pointer_t internal_function__decimal_number (node::pointer_t func)
 
node::pointer_t internal_function__floor (node::pointer_t func)
 
node::pointer_t internal_function__frgb (node::pointer_t func)
 
node::pointer_t internal_function__frgba (node::pointer_t func)
 
node::pointer_t internal_function__function_exists (node::pointer_t func)
 
node::pointer_t internal_function__get_any (node::pointer_t func, size_t argn)
 
node::pointer_t internal_function__get_color (node::pointer_t func, size_t argn, color &col)
 
node::pointer_t internal_function__get_number (node::pointer_t func, size_t argn, decimal_number_t &number)
 
node::pointer_t internal_function__get_number_or_percent (node::pointer_t func, size_t argn, decimal_number_t &number)
 
node::pointer_t internal_function__get_string (node::pointer_t func, size_t argn, std::string &str)
 
node::pointer_t internal_function__get_string_or_identifier (node::pointer_t func, size_t argn, std::string &str)
 
node::pointer_t internal_function__global_variable_exists (node::pointer_t func)
 
node::pointer_t internal_function__green (node::pointer_t func)
 
node::pointer_t internal_function__hsl (node::pointer_t func)
 
node::pointer_t internal_function__hsla (node::pointer_t func)
 
node::pointer_t internal_function__hue (node::pointer_t func)
 
node::pointer_t internal_function__identifier (node::pointer_t func)
 
node::pointer_t internal_function__if (node::pointer_t func)
 
node::pointer_t internal_function__inspect (node::pointer_t func)
 
node::pointer_t internal_function__integer (node::pointer_t func)
 
node::pointer_t internal_function__lightness (node::pointer_t func)
 
node::pointer_t internal_function__log (node::pointer_t func)
 
node::pointer_t internal_function__max (node::pointer_t func)
 
node::pointer_t internal_function__min (node::pointer_t func)
 
node::pointer_t internal_function__not (node::pointer_t func)
 
node::pointer_t internal_function__percentage (node::pointer_t func)
 
node::pointer_t internal_function__random (node::pointer_t func)
 
node::pointer_t internal_function__red (node::pointer_t func)
 
node::pointer_t internal_function__rgb (node::pointer_t func)
 
node::pointer_t internal_function__rgba (node::pointer_t func)
 
node::pointer_t internal_function__round (node::pointer_t func)
 
node::pointer_t internal_function__saturation (node::pointer_t func)
 
node::pointer_t internal_function__sign (node::pointer_t func)
 
node::pointer_t internal_function__sin (node::pointer_t func)
 
node::pointer_t internal_function__sqrt (node::pointer_t func)
 
node::pointer_t internal_function__str_length (node::pointer_t func)
 
node::pointer_t internal_function__string (node::pointer_t func)
 
node::pointer_t internal_function__tan (node::pointer_t func)
 
node::pointer_t internal_function__type_of (node::pointer_t func)
 
node::pointer_t internal_function__unique_id (node::pointer_t funct)
 
node::pointer_t internal_function__unit (node::pointer_t func)
 
node::pointer_t internal_function__variable_exists (node::pointer_t func)
 
bool is_comparable (node::pointer_t lhs, node::pointer_t rhs)
 
bool is_equal (node::pointer_t lhs, node::pointer_t rhs)
 
bool is_label () const
 
bool is_less_than (node::pointer_t lhs, node::pointer_t rhs)
 
node::pointer_t logical_and ()
 
node::pointer_t logical_or ()
 
void mark_start ()
 
node::pointer_t multiplicative ()
 
std::string multiplicative_dimension (position const &pos, std::string const &dim1, node_type_t const op, std::string const &dim2)
 
node::pointer_t multiply (node_type_t op, node::pointer_t lhs, node::pointer_t rhs)
 
void next ()
 
node::pointer_t post ()
 
node::pointer_t power ()
 
std::string rebuild_dimension (dimension_vector_t const &dividend, dimension_vector_t const &divisor)
 
node::pointer_t relational ()
 
node::pointer_t replace_with_result (node::pointer_t result)
 
node::pointer_t unary ()
 

Private Attributes

node::pointer_t f_current
 
bool f_divide_font_metrics = false
 
node::pointer_t f_node
 
size_t f_pos = 0
 
size_t f_start = static_cast<size_t>(-1)
 
expression_variables_interfacef_variable_handler = nullptr
 
variable_vector_t f_variables
 

Detailed Description

Definition at line 34 of file expression.h.

Member Typedef Documentation

typedef std::vector<std::string> csspp::expression::dimension_vector_t
private

Definition at line 50 of file expression.h.

typedef std::map<std::string, node::pointer_t> csspp::expression::variable_vector_t
private

Definition at line 49 of file expression.h.

Constructor & Destructor Documentation

csspp::expression::expression ( node::pointer_t  n)

Definition at line 40 of file expression.cpp.

References f_node.

Member Function Documentation

node::pointer_t csspp::expression::additive ( )
private
node::pointer_t csspp::expression::apply_power ( node::pointer_t  lhs,
node::pointer_t  rhs 
)
private
node::pointer_t csspp::expression::assignment ( )
private

Definition at line 157 of file expr_list.cpp.

References csspp::ASSIGNMENT, conditional(), f_current, f_variables, csspp::IDENTIFIER, and next().

Referenced by expression_list().

bool csspp::expression::boolean ( node::pointer_t  n)
static

This function checks whether a node represents a valid boolean. If so it returns true or false depending on that fact.

If the node does not represent a boolean, then the function returns false after it generated an error.

Note
The function is also used by the conditional() and logical_or() functions.
Parameters
[in]nThe node to check whether it is true or false.
Returns
true or false.

Definition at line 56 of file expr_logical_and.cpp.

References csspp::BOOLEAN_INVALID, csspp::BOOLEAN_TRUE, csspp::ERROR_ERROR, and csspp::error::instance().

Referenced by csspp::compiler::replace_else(), and csspp::compiler::replace_if().

node::pointer_t csspp::expression::compile ( )
void csspp::expression::compile_args ( bool  divide_font_metrics)
node::pointer_t csspp::expression::compile_list ( node::pointer_t  parent)
private
node::pointer_t csspp::expression::conditional ( )
private
void csspp::expression::dimensions_to_vectors ( position const &  pos,
std::string const &  dimension,
dimension_vector_t dividend,
dimension_vector_t divisor 
)
private
bool csspp::expression::end_of_nodes ( )
private

Definition at line 62 of file expression.cpp.

References f_node, and f_pos.

Referenced by compile_list().

node::pointer_t csspp::expression::equality ( )
private
node::pointer_t csspp::expression::excecute_function ( node::pointer_t  func)
private

Definition at line 1862 of file internal_functions.cpp.

References csspp::BOOLEAN, csspp::ERROR_ERROR, csspp::expression_variables_interface::execute_user_function(), f_current, f_variable_handler, csspp::error::instance(), internal_function__abs(), internal_function__acos(), internal_function__alpha(), internal_function__asin(), internal_function__atan(), internal_function__blue(), internal_function__ceil(), internal_function__cos(), internal_function__decimal_number(), internal_function__floor(), internal_function__frgb(), internal_function__frgba(), internal_function__function_exists(), internal_function__get_string_or_identifier(), internal_function__global_variable_exists(), internal_function__green(), internal_function__hsl(), internal_function__hsla(), internal_function__hue(), internal_function__identifier(), internal_function__if(), internal_function__inspect(), internal_function__integer(), internal_function__lightness(), internal_function__log(), internal_function__max(), internal_function__min(), internal_function__not(), internal_function__percentage(), internal_function__random(), internal_function__red(), internal_function__rgb(), internal_function__rgba(), internal_function__round(), internal_function__saturation(), internal_function__sign(), internal_function__sin(), internal_function__sqrt(), internal_function__str_length(), internal_function__string(), internal_function__tan(), internal_function__type_of(), internal_function__unique_id(), internal_function__unit(), and internal_function__variable_exists().

Referenced by unary().

node::pointer_t csspp::expression::expression_list ( )
private
int csspp::expression::get_unique_id_counter ( )
static
node::pointer_t csspp::expression::internal_function__abs ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__acos ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__adjust_hue ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__alpha ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__asin ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__atan ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__blue ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__ceil ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__cos ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__decimal_number ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__floor ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__frgb ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__frgba ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__function_exists ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__get_any ( node::pointer_t  func,
size_t  argn 
)
private
node::pointer_t csspp::expression::internal_function__get_color ( node::pointer_t  func,
size_t  argn,
color col 
)
private
node::pointer_t csspp::expression::internal_function__get_number ( node::pointer_t  func,
size_t  argn,
decimal_number_t number 
)
private
node::pointer_t csspp::expression::internal_function__get_number_or_percent ( node::pointer_t  func,
size_t  argn,
decimal_number_t number 
)
private
node::pointer_t csspp::expression::internal_function__get_string ( node::pointer_t  func,
size_t  argn,
std::string &  str 
)
private

Definition at line 194 of file internal_functions.cpp.

References csspp::STRING.

Referenced by internal_function__str_length().

node::pointer_t csspp::expression::internal_function__get_string_or_identifier ( node::pointer_t  func,
size_t  argn,
std::string &  str 
)
private
node::pointer_t csspp::expression::internal_function__global_variable_exists ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__green ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__hsl ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__hsla ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__hue ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__identifier ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__if ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__inspect ( node::pointer_t  func)
private

Definition at line 893 of file internal_functions.cpp.

References csspp::node::g_to_string_flag_show_quotes, and csspp::STRING.

Referenced by excecute_function().

node::pointer_t csspp::expression::internal_function__integer ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__lightness ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__log ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__max ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__min ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__not ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__percentage ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__random ( node::pointer_t  func)
private

Definition at line 1385 of file internal_functions.cpp.

References csspp::DECIMAL_NUMBER.

Referenced by excecute_function().

node::pointer_t csspp::expression::internal_function__red ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__rgb ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__rgba ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__round ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__saturation ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__sign ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__sin ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__sqrt ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__str_length ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__string ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__tan ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__type_of ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__unique_id ( node::pointer_t  funct)
private
node::pointer_t csspp::expression::internal_function__unit ( node::pointer_t  func)
private
node::pointer_t csspp::expression::internal_function__variable_exists ( node::pointer_t  func)
private
bool csspp::expression::is_comparable ( node::pointer_t  lhs,
node::pointer_t  rhs 
)
private
bool csspp::expression::is_equal ( node::pointer_t  lhs,
node::pointer_t  rhs 
)
private
bool csspp::expression::is_label ( ) const
private

Definition at line 40 of file expr_list.cpp.

References csspp::COLON, f_current, f_node, f_pos, and csspp::IDENTIFIER.

Referenced by expression_list().

bool csspp::expression::is_less_than ( node::pointer_t  lhs,
node::pointer_t  rhs 
)
private
node::pointer_t csspp::expression::logical_and ( )
private

Definition at line 68 of file expr_logical_and.cpp.

References csspp::AND, csspp::BOOLEAN, equality(), f_current, csspp::IDENTIFIER, and next().

Referenced by logical_or().

node::pointer_t csspp::expression::logical_or ( )
private

Definition at line 40 of file expr_logical_or.cpp.

References csspp::BOOLEAN, csspp::COLUMN, f_current, csspp::IDENTIFIER, logical_and(), and next().

Referenced by conditional().

void csspp::expression::mark_start ( )
private

Definition at line 67 of file expression.cpp.

References f_pos, and f_start.

Referenced by compile(), compile_list(), and replace_with_result().

node::pointer_t csspp::expression::multiplicative ( )
private
std::string csspp::expression::multiplicative_dimension ( position const &  pos,
std::string const &  dim1,
node_type_t const  op,
std::string const &  dim2 
)
private

Definition at line 197 of file expr_multiplicative.cpp.

References dimensions_to_vectors(), csspp::MULTIPLY, and rebuild_dimension().

Referenced by multiply().

node::pointer_t csspp::expression::multiply ( node_type_t  op,
node::pointer_t  lhs,
node::pointer_t  rhs 
)
private
void csspp::expression::next ( )
private
node::pointer_t csspp::expression::post ( )
private
node::pointer_t csspp::expression::power ( )
private

Definition at line 187 of file expr_power.cpp.

References apply_power(), f_current, csspp::IDENTIFIER, next(), post(), and csspp::POWER.

Referenced by multiplicative(), and unary().

std::string csspp::expression::rebuild_dimension ( dimension_vector_t const &  dividend,
dimension_vector_t const &  divisor 
)
private
node::pointer_t csspp::expression::relational ( )
private
node::pointer_t csspp::expression::replace_with_result ( node::pointer_t  result)
private

Definition at line 72 of file expression.cpp.

References csspp::EOF_TOKEN, f_current, f_node, f_pos, f_start, mark_start(), and csspp::WHITESPACE.

Referenced by compile(), and compile_list().

void csspp::expression::set_unique_id_counter ( int  counter)
static
void csspp::expression::set_variable_handler ( expression_variables_interface handler)
node::pointer_t csspp::expression::unary ( )
private

Member Data Documentation

node::pointer_t csspp::expression::f_current
private

Definition at line 151 of file expression.h.

Referenced by additive(), apply_power(), assignment(), compile_list(), conditional(), equality(), excecute_function(), expression_list(), internal_function__abs(), internal_function__acos(), internal_function__alpha(), internal_function__asin(), internal_function__atan(), internal_function__blue(), internal_function__ceil(), internal_function__cos(), internal_function__decimal_number(), internal_function__floor(), internal_function__frgb(), internal_function__frgba(), internal_function__function_exists(), internal_function__global_variable_exists(), internal_function__green(), internal_function__hsl(), internal_function__hsla(), internal_function__hue(), internal_function__identifier(), internal_function__if(), internal_function__integer(), internal_function__lightness(), internal_function__log(), internal_function__max(), internal_function__min(), internal_function__not(), internal_function__percentage(), internal_function__red(), internal_function__rgb(), internal_function__rgba(), internal_function__round(), internal_function__saturation(), internal_function__sign(), internal_function__sin(), internal_function__sqrt(), internal_function__str_length(), internal_function__string(), internal_function__tan(), internal_function__type_of(), internal_function__unique_id(), internal_function__unit(), internal_function__variable_exists(), is_label(), logical_and(), logical_or(), multiplicative(), multiply(), next(), post(), power(), relational(), replace_with_result(), and unary().

bool csspp::expression::f_divide_font_metrics = false
private

Definition at line 153 of file expression.h.

Referenced by multiply().

node::pointer_t csspp::expression::f_node
private
size_t csspp::expression::f_pos = 0
private
size_t csspp::expression::f_start = static_cast<size_t>(-1)
private

Definition at line 150 of file expression.h.

Referenced by mark_start(), and replace_with_result().

expression_variables_interface* csspp::expression::f_variable_handler = nullptr
private
variable_vector_t csspp::expression::f_variables
private

Definition at line 152 of file expression.h.

Referenced by assignment(), and unary().


The documentation for this class was generated from the following files:

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.