aknlayoutcompiler/inc/FormulaTree.h
changeset 0 f58d6ec98e88
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #ifndef FORMULATREE_H
       
    18 #define FORMULATREE_H
       
    19 
       
    20 #include <string>
       
    21 #include <vector>
       
    22 using namespace std;
       
    23 
       
    24 class ParseResult;
       
    25 
       
    26 class FormulaTreeNode
       
    27 	{
       
    28 public:
       
    29 	enum TNodeType
       
    30 		{
       
    31 		EReal=1,		// Real() = the number
       
    32 		EInt,			// Int() = the number
       
    33 		ECell,			// Char() = cell name
       
    34 		EParent,		// nothing special
       
    35 		EParentCell,	// Char() = parent cell name
       
    36 		ETableCell,		// Real() = target table
       
    37 		EComponent,		// Real() = component id, [0] = cell name
       
    38 		EAbsolute,		// Text() = whole thing, [0], [1] = real components, [2] = cell name
       
    39 		EUnits,			// Real() = units
       
    40 		EConstant,		// Real() = constant
       
    41 		EAttribute,		// Int() = attribute
       
    42 		EMystery,		// Text() = whole thing, [0], [1] = int components
       
    43 		EFunction,		// Text() = function name, [0] = parameter
       
    44 		EArithmetic,	// Char() = arithmetic operator, [0], [1] = sub expressions
       
    45 		ECondition,		// Text() = comparison operator, [0], [1] = sub expressions
       
    46 		EConditional	// no content, [0] = condition, [1] = then expression, [2] = else expression
       
    47 		};
       
    48 
       
    49 public:
       
    50 	static FormulaTreeNode* Parse(const string& aFormula);
       
    51 	virtual ~FormulaTreeNode();
       
    52 
       
    53 	int Size() const;
       
    54 	FormulaTreeNode& operator[](int aIndex);
       
    55 	const FormulaTreeNode& operator[](int aIndex) const;
       
    56 	
       
    57 	TNodeType Type() const;
       
    58 
       
    59 	string Text() const;
       
    60 	char Char() const;
       
    61 	int Int() const;
       
    62 	double Real() const;
       
    63 
       
    64 	FormulaTreeNode(const FormulaTreeNode& aOther);
       
    65 	static void Print(const FormulaTreeNode& aNode);
       
    66 
       
    67 private:
       
    68 	FormulaTreeNode(TNodeType aType, const string& aSource, int aStart, int aLen);
       
    69 	static FormulaTreeNode* NewTree(const ParseResult& aParse, const string& aFormula);
       
    70 	const FormulaTreeNode& operator=(const FormulaTreeNode& aOther);
       
    71 
       
    72 public:
       
    73 	vector<FormulaTreeNode*> iSubNodes;
       
    74 
       
    75 private:
       
    76 	const string& iSource;
       
    77 	int iStart;
       
    78 	int iLen;
       
    79 	TNodeType iType;
       
    80 	};
       
    81 
       
    82 
       
    83 #endif