Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef INCLUDE_EXPRTK_HPP
- #define INCLUDE_EXPRTK_HPP
- #include <algorithm>
- #include <cassert>
- #include <cctype>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <deque>
- #include <functional>
- #include <iterator>
- #include <limits>
- #include <list>
- #include <map>
- #include <set>
- #include <stack>
- #include <stdexcept>
- #include <string>
- #include <utility>
- #include <vector>
- namespace exprtk
- {
- #ifdef exprtk_enable_debugging
- #define exprtk_debug(params) printf params
- #else
- #define exprtk_debug(params) (void)0
- #endif
- #define exprtk_error_location \
- "exprtk.hpp:" + details::to_str(__LINE__) \
- #if __cplusplus >= 201103L
- #define exprtk_override override
- #define exprtk_final final
- #define exprtk_delete = delete
- #else
- #define exprtk_override
- #define exprtk_final
- #define exprtk_delete
- #endif
- #if __cplusplus >= 201603L
- #define exprtk_fallthrough [[fallthrough]];
- #else
- #define exprtk_fallthrough
- #endif
- namespace details
- {
- typedef char char_t;
- typedef char_t* char_ptr;
- typedef char_t const* char_cptr;
- typedef unsigned char uchar_t;
- typedef uchar_t* uchar_ptr;
- typedef uchar_t const* uchar_cptr;
- typedef unsigned long long int _uint64_t;
- typedef long long int _int64_t;
- inline bool is_whitespace(const char_t c)
- {
- return (' ' == c) || ('\n' == c) ||
- ('\r' == c) || ('\t' == c) ||
- ('\b' == c) || ('\v' == c) ||
- ('\f' == c) ;
- }
- inline bool is_operator_char(const char_t c)
- {
- return ('+' == c) || ('-' == c) ||
- ('*' == c) || ('/' == c) ||
- ('^' == c) || ('<' == c) ||
- ('>' == c) || ('=' == c) ||
- (',' == c) || ('!' == c) ||
- ('(' == c) || (')' == c) ||
- ('[' == c) || (']' == c) ||
- ('{' == c) || ('}' == c) ||
- ('%' == c) || (':' == c) ||
- ('?' == c) || ('&' == c) ||
- ('|' == c) || (';' == c) ;
- }
- inline bool is_letter(const char_t c)
- {
- return (('a' <= c) && (c <= 'z')) ||
- (('A' <= c) && (c <= 'Z')) ;
- }
- inline bool is_digit(const char_t c)
- {
- return ('0' <= c) && (c <= '9');
- }
- inline bool is_letter_or_digit(const char_t c)
- {
- return is_letter(c) || is_digit(c);
- }
- inline bool is_left_bracket(const char_t c)
- {
- return ('(' == c) || ('[' == c) || ('{' == c);
- }
- inline bool is_right_bracket(const char_t c)
- {
- return (')' == c) || (']' == c) || ('}' == c);
- }
- inline bool is_bracket(const char_t c)
- {
- return is_left_bracket(c) || is_right_bracket(c);
- }
- inline bool is_sign(const char_t c)
- {
- return ('+' == c) || ('-' == c);
- }
- inline bool is_invalid(const char_t c)
- {
- return !is_whitespace (c) &&
- !is_operator_char(c) &&
- !is_letter (c) &&
- !is_digit (c) &&
- ('.' != c) &&
- ('_' != c) &&
- ('$' != c) &&
- ('~' != c) &&
- ('\'' != c);
- }
- inline bool is_valid_string_char(const char_t c)
- {
- return std::isprint(static_cast<uchar_t>(c)) ||
- is_whitespace(c);
- }
- #ifndef exprtk_disable_caseinsensitivity
- inline void case_normalise(std::string& s)
- {
- for (std::size_t i = 0; i < s.size(); ++i)
- {
- s[i] = static_cast<std::string::value_type>(std::tolower(s[i]));
- }
- }
- inline bool imatch(const char_t c1, const char_t c2)
- {
- return std::tolower(c1) == std::tolower(c2);
- }
- inline bool imatch(const std::string& s1, const std::string& s2)
- {
- if (s1.size() == s2.size())
- {
- for (std::size_t i = 0; i < s1.size(); ++i)
- {
- if (std::tolower(s1[i]) != std::tolower(s2[i]))
- {
- return false;
- }
- }
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement