[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/kmplayer
From:       Koos Vriezen <koos.vriezen () gmail ! com>
Date:       2010-02-27 22:53:05
Message-ID: 1267311185.547840.2397.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1096923 by vriezen:

Implement expression function string-join()

 M  +30 -0     src/expression.cpp  
 M  +1 -1      tests/state.smil  


--- trunk/extragear/multimedia/kmplayer/src/expression.cpp #1096922:1096923
@@ -240,6 +240,12 @@
     virtual QString toString () const;
 };
 
+struct StringJoin : public StringBase {
+    StringJoin (EvalState *ev) : StringBase (ev) {}
+
+    virtual QString toString () const;
+};
+
 struct CurrentTime : public StringBase {
     CurrentTime (EvalState *ev) : StringBase (ev) {}
 
@@ -744,6 +750,28 @@
     return string;
 }
 
+QString StringJoin::toString () const {
+    if (eval_state->sequence != sequence) {
+        sequence = eval_state->sequence;
+        string.clear ();
+        AST *child = first_child;
+        if (child) {
+            NodeValueList *lst = child->toNodeList ();
+            NodeValueItem *n = lst->first();
+            if (n) {
+                QString sep;
+                if (child->next_sibling)
+                    sep = child->next_sibling->toString ();
+                string = n->data.value ();
+                for (n = n->nextSibling (); n; n = n->nextSibling ())
+                    string += sep + n->data.value ();
+            }
+            delete lst;
+        }
+    }
+    return string;
+}
+
 QString CurrentTime::toString () const {
     if (eval_state->sequence != sequence) {
         char buf[200];
@@ -1271,6 +1299,8 @@
                     func = new Position (ast->eval_state);
                 else if (name == "sort")
                     func = new Sort (ast->eval_state);
+                else if (name == "string-join")
+                    func = new StringJoin (ast->eval_state);
                 else
                     return false;
                 appendASTChild (ast, func);
--- trunk/extragear/multimedia/kmplayer/tests/state.smil #1096922:1096923
@@ -47,7 +47,7 @@
     <par dur="5">
       <text src="data:,books%20with%20price%20{//book[@price]}" left="10" top="10" \
                width="300" height="20"/>
       <text src="data:,books%20with%20price%2010p%20{//book[@price=&quot;10p&quot;]/title}" \
                left="10" top="40" width="300" height="20"/>
-      <text src="data:,price%20of%20Pygmalion%20{//book[title=&quot;Pygmalion&quot;]/@price}" \
left="10" top="70" width="300" height="20"/> +      <text \
src="data:,price%20of%20{string-join(//book[3]/title | //book[3]/@price, ' is ')}" \
                left="10" top="70" width="300" height="20"/>
       <text src="data:,attributes%20on%20second%20book%20{//book[2]/@*}" left="10" \
                top="100" width="300" height="20"/>
       <text src="data:,total%20attributes%20on%20book%20{//book/@*}" left="10" \
                top="130" width="300" height="20"/>
       <text src="data:,second%20attribute%20on%20book%20{//book/@*[2]}" left="10" \
top="160" width="300" height="20"/>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic