Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class strstr_function : public function_expression {
- public:
- explicit strstr_function(const args_list& args)
- : function_expression("strstr", args, 2, 2)
- {}
- private:
- variant execute(const formula_callable& variables) const {
- const std::string& haystack = args()[0]->evaluate(variables).as_string();
- const std::string& needle = args()[1]->evaluate(variables).as_string();
- const size_t pos = haystack.find(needle);
- if(pos == std::string::npos) {
- return variant(0);
- } else {
- return variant(pos + 1);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment