constexpr char const * parser_name( parser_type<NumType> fptr ) { return fptr == &standard_sto< NumType > ? stdsto_func_name(NumType()) : fptr == get_vanorder_parser< NumType >() ? vanorder::utils::sto_func_name(NumType()) : throw std::runtime_error( "Unknown parser function: " + std::to_string( (size_t)(void*)fptr ) ) ; }
inline NumType absolute(NumType const& x) { if (x < NumType(0)) return -x; return x; }
size_t Database::MaxIndex(DataTypes aType) { size_t num = NumType(aType); if(num == 0) { MACRO_THROW_EXCEPTION(ArgumentException, "No points for datatype"); } else return (num - 1); }
size_t AsyncDatabase::MaxIndex(DataTypes aType) { size_t num = NumType(aType); if(num == 0) throw ArgumentException(LOCATION, "No points for datatype"); else return (num-1); }
Constraint* ConstraintSUB(TYPE* type, AbstractVariable *var1, AbstractVariable* var2, AbstractVariable* calcResult) { ASSERT(var1 != NULL); Constraint *Q = new Constraint(); Partial* P = new std::list<Element*>(); Element *cons1, *cons2, *cons3; // num - num // operand var1 cons1 = new Element(); cons1 -> subTypeSet(var1 -> id, type, 0); // operand P -> insert( P -> end(), cons1); // operand var2, if the second variable doesn't exists, it is a immediate number. if(var2 != NULL){ cons2 = new Element(); cons2 -> subTypeSet(var2 -> id, type, 0); // operand P -> insert( P -> end(), cons2); } // result, if the result doesn't exists, the destination is a memory slot. if(calcResult != NULL){ cons3 = new Element(); cons3 -> subTypeSet(calcResult -> id, type, 1); // result P -> insert( P -> end(), cons3); } Q -> addPart(P); if(type -> getSize() == 32){ // pointer - num P = new std::list<Element*>(); cons1 = new Element(); cons1 -> subTypeSet(var1 -> id, (TYPE*)Ptr_s, 0); P -> insert(P -> end(), cons1); if(var2 != NULL){ cons2 = new Element(); cons2 -> subTypeSet(var2 -> id, (TYPE*)NumType(32), 0); P -> insert(P -> end(), cons2); } if(calcResult != NULL){ cons3 = new Element(); cons3 -> subTypeSet(calcResult -> id, (TYPE*)Ptr_s, 1); P -> insert(P -> end(), cons3); } Q -> addPart(P); // pointer - pointer, the var2 can't be null if(var2 != NULL) { P = new std::list<Element*>(); cons1 = new Element(); cons1 -> subTypeSet(var2 -> id, (TYPE*)Ptr_s, 0); P -> insert( P -> end(), cons1); cons2 = new Element(); cons2 -> subTypeSet(var1 -> id, (TYPE*)Ptr_s, 0); P -> insert( P -> end(), cons2); if(calcResult != NULL){ cons3 = new Element(); cons3 -> subTypeSet(calcResult -> id, (TYPE*)NumType(32), 1); P -> insert( P -> end(), cons3); } // the type of the result will change! Q -> addPart(P); } } return Q; }