muParser: muParserInt.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Examples

# muParserInt.h

Go to the documentation of this file.

    00001 /*
    00002                  __________
    00003     _____   __ __\______   \_____  _______  ______  ____ _______
    00004    /     \ |  |  \|     ___/\__  \ \_  __ \/  ___/_/ __ \\_  __ \
    00005   |  Y Y  \|  |  /|    |     / __ \_|  | \/\___ \ \  ___/ |  | \/
    00006   |__|_|  /|____/ |____|    (____  /|__|  /____  > \___  >|__|
    00007         \/                       \/            \/      \/
    00008   Copyright (C) 2004-2008 Ingo Berg
    00009
    00010   Permission is hereby granted, free of charge, to any person obtaining a copy of this
    00011   software and associated documentation files (the "Software"), to deal in the Software
    00012   without restriction, including without limitation the rights to use, copy, modify,
    00013   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
    00014   permit persons to whom the Software is furnished to do so, subject to the following conditions:
    00015
    00016   The above copyright notice and this permission notice shall be included in all copies or
    00017   substantial portions of the Software.
    00018
    00019   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
    00020   NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    00021   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
    00022   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00023   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00024 */
    00025
    00026 #ifndef MU_PARSER_INT_H
    00027 #define MU_PARSER_INT_H
    00028
    00029 #include "muParserBase.h"
    00030 #include <vector>
    00031
    00037 namespace mu
    00038 {
    00039
    00045 class ParserInt : public ParserBase
    00046 {
    00047 private:
    00048     static int  Round(value_type v) { return (int)(v + ((v>=0) ? 0.5 : -0.5) ); };
    00049
    00050     static value_type  Abs(value_type);
    00051           static value_type  Sign(value_type);
    00052     static value_type  Ite(value_type, value_type, value_type);
    00053     // !! The unary Minus is a MUST, otherwise you cant use negative signs !!
    00054     static value_type  UnaryMinus(value_type);
    00055     // Functions with variable number of arguments
    00056     static value_type  Sum(const value_type* a_afArg, int a_iArgc);  // sum
    00057     static value_type  Min(const value_type* a_afArg, int a_iArgc);  // minimum
    00058     static value_type  Max(const value_type* a_afArg, int a_iArgc);  // maximum
    00059     // binary operator callbacks
    00060     static value_type  Add(value_type v1, value_type v2);
    00061     static value_type  Sub(value_type v1, value_type v2);
    00062     static value_type  Mul(value_type v1, value_type v2);
    00063     static value_type  Div(value_type v1, value_type v2);
    00064     static value_type  Mod(value_type v1, value_type v2);
    00065     static value_type  Shr(value_type v1, value_type v2);
    00066     static value_type  Shl(value_type v1, value_type v2);
    00067     static value_type  LogAnd(value_type v1, value_type v2);
    00068     static value_type  LogOr(value_type v1, value_type v2);
    00069     static value_type  LogXor(value_type v1, value_type v2);
    00070     static value_type  And(value_type v1, value_type v2);
    00071     static value_type  Or(value_type v1, value_type v2);
    00072     static value_type  Xor(value_type v1, value_type v2);
    00073     static value_type  Less(value_type v1, value_type v2);
    00074     static value_type  Greater(value_type v1, value_type v2);
    00075     static value_type  LessEq(value_type v1, value_type v2);
    00076     static value_type  GreaterEq(value_type v1, value_type v2);
    00077     static value_type  Equal(value_type v1, value_type v2);
    00078     static value_type  NotEqual(value_type v1, value_type v2);
    00079     static value_type  Not(value_type v1);
    00080
    00081     static int IsHexVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal);
    00082     static int IsBinVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal);
    00083     static int IsVal   (const char_type* a_szExpr, int *a_iPos, value_type *a_iVal);
    00084
    00085 public:
    00086     ParserInt();
    00087
    00088     virtual void InitFun();
    00089           virtual void InitOprt();
    00090     virtual void InitConst();
    00091     virtual void InitCharSets();
    00092 };
    00093
    00094 } // namespace mu
    00095
    00096 #endif
    00097