|
Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
|
00001 /* Rapicorn 00002 * Copyright (C) 2008 Tim Janik 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * A copy of the GNU Lesser General Public License should ship along 00015 * with this library; if not, see http://www.gnu.org/copyleft/. 00016 */ 00017 #ifndef __RAPICORN_SINFEX_HH__ 00018 #define __RAPICORN_SINFEX_HH__ 00019 00020 #include <ui/utilities.hh> 00021 00022 namespace Rapicorn { 00023 00024 class Sinfex : public virtual ReferenceCountable, protected NonCopyable { 00025 protected: 00026 uint *m_start; 00027 explicit Sinfex (); 00028 virtual ~Sinfex (); 00029 public: 00030 static Sinfex* parse_string (const String &expression); 00031 class Value; 00032 struct Scope { 00033 virtual Value resolve_variable (const String &entity, 00034 const String &name) = 0; 00035 virtual Value call_function (const String &entity, 00036 const String &name, 00037 const vector<Value> &args) = 0; 00038 }; 00039 virtual Value eval (Scope &scope) = 0; 00040 /* Sinfex::Value implementation */ 00041 class Value { 00042 String m_string; 00043 double m_real; 00044 bool m_strflag; 00045 String real2string () const; 00046 double string2real () const; 00047 public: 00048 bool isreal () const { return !m_strflag; } 00049 bool isstring () const { return m_strflag; } 00050 double real () const { return !m_strflag ? m_real : string2real(); } 00051 String string () const { return m_strflag ? m_string : real2string(); } 00052 bool asbool () const { return (!m_strflag && m_real) || (m_strflag && m_string != ""); } 00053 explicit Value (double d) : m_real (d), m_strflag (0) {} 00054 explicit Value (const String &s); 00055 }; 00056 }; 00057 00058 } // Rapicorn 00059 00060 #endif /* __RAPICORN_SINFEX_HH__ */
1.7.4