schema_editor/comdel/domain/functionsignature.h

54 lines
1.1 KiB
C
Raw Normal View History

2022-05-15 09:17:05 +00:00
#ifndef DOMAIN_FUNCTION_VALIDATOR_H
#define DOMAIN_FUNCTION_VALIDATOR_H
2022-03-31 21:20:41 +00:00
#include<functional>
2022-04-12 21:37:05 +00:00
#include<vector>
2022-03-31 21:20:41 +00:00
#include "value.h"
namespace domain {
2022-05-15 09:17:05 +00:00
class FunctionValidator {
private:
2022-03-31 21:20:41 +00:00
std::string name;
2022-05-15 09:17:05 +00:00
std::vector<Value::ValueType> signature;
protected:
FunctionValidator(std::string name, std::vector<Value::ValueType> signature) {
this->name = name;
this->signature = signature;
}
public:
std::string getName() {
return name;
}
std::vector<Value::ValueType> getSignature() {
return signature;
}
bool validateSignature(std::vector<Value> signature) {
if(this->signature.size() != signature.size()) {
return false;
}
for(int i=0; i<this->signature.size(); i++) {
if(this->signature[i] != signature[i].getType()) {
return false;
}
}
return true;
}
virtual bool validate(std::vector<Value> values) = 0;
virtual void clear() = 0;
2022-03-31 21:20:41 +00:00
};
2022-05-15 09:17:05 +00:00
std::vector<FunctionValidator*> getSupportedValidators();
2022-04-10 12:23:18 +00:00
2022-03-31 21:20:41 +00:00
} // namespace domain
2022-05-15 09:17:05 +00:00
#endif // DOMAIN_FUNCTION_VALIDATOR_H