|
Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
|
00001 /* Rapicorn 00002 * Copyright (C) 2010 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_COMPATH_HH__ 00018 #define __RAPICORN_COMPATH_HH__ 00019 00020 #include <ui/item.hh> 00021 00022 namespace Rapicorn { 00023 00024 struct ComponentMatcher : protected NonCopyable { 00025 enum StepType { ORIGIN, BELOW, EXPRESSION }; 00026 explicit ComponentMatcher (StepType st); 00027 virtual ~ComponentMatcher (); 00028 inline StepType step () { return m_step; } 00029 static ComponentMatcher* parse_path (String path); 00030 private: 00031 const StepType m_step; 00032 class Parser; 00033 }; 00034 00035 struct ComponentMatcherExpression : public ComponentMatcher { 00036 enum OpType { INVALID, EQUAL, UNEQUAL, MATCH }; 00037 explicit ComponentMatcherExpression (String prop, OpType op, String val); 00038 inline String attribute () { return m_attribute; } 00039 inline OpType operator_ () { return m_operator; } 00040 inline String value () { return m_value; } 00041 private: 00042 const String m_attribute, m_value; 00043 const OpType m_operator; 00044 }; 00045 00046 struct ComponentMatcherSegment : public ComponentMatcher { 00047 typedef vector<ComponentMatcher*> Matchers; 00048 explicit ComponentMatcherSegment (StepType st, 00049 String typetag, 00050 String idselector); 00051 /*Des*/ ~ComponentMatcherSegment (); 00052 void add_predicate (ComponentMatcher &cmatch); 00053 inline String typetag () { return m_typetag; } 00054 inline String idselector () { return m_idselector; } 00055 inline const Matchers& predicates () { return m_predicates; } 00056 ComponentMatcherSegment* next () { return m_next; } 00057 void link (ComponentMatcherSegment &cms); 00058 private: 00059 const String m_typetag; 00060 const String m_idselector; 00061 Matchers m_predicates; 00062 ComponentMatcherSegment *m_next; 00063 }; 00064 00065 vector<ItemImpl*> collect_items (ItemImpl &origin, 00066 ComponentMatcher &cmatch); 00067 00068 } // Rapicorn 00069 00070 #endif /* __RAPICORN_COMPATH_HH__ */
1.7.4