[vlc-devel] commit: Skins2: Refactor string manipulation event handling a bit and replace some static const members with an enum . (JP Dinger )

git version control git at videolan.org
Sat Dec 5 22:35:06 CET 2009


vlc | branch: master | JP Dinger <jpd at videolan.org> | Sun Nov 15 23:24:41 2009 +0100| [c8dbc4eb30e377b6a9a34bd04b84155549bec353] | committer: JP Dinger 

Skins2: Refactor string manipulation event handling a bit and replace some static const members with an enum.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8dbc4eb30e377b6a9a34bd04b84155549bec353
---

 modules/gui/skins2/events/evt_input.cpp |   30 ++++++++----------------------
 modules/gui/skins2/events/evt_input.hpp |    5 +----
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/modules/gui/skins2/events/evt_input.cpp b/modules/gui/skins2/events/evt_input.cpp
index b8f2a3f..d56d45e 100644
--- a/modules/gui/skins2/events/evt_input.cpp
+++ b/modules/gui/skins2/events/evt_input.cpp
@@ -24,16 +24,9 @@
 
 #include "evt_input.hpp"
 
-const int EvtInput::kModNone  = 0;
-const int EvtInput::kModAlt   = 1;
-const int EvtInput::kModCtrl  = 2;
-const int EvtInput::kModShift = 4;
 
-
-EvtInput::EvtInput( intf_thread_t *pIntf, int mod ):
-    EvtGeneric( pIntf), m_mod( mod )
-{
-}
+EvtInput::EvtInput( intf_thread_t *pIntf, int mod )
+    : EvtGeneric( pIntf), m_mod( mod ) { }
 
 
 void EvtInput::addModifier( string &rEvtString ) const
@@ -44,21 +37,14 @@ void EvtInput::addModifier( string &rEvtString ) const
     }
     else
     {
-        string modList = ":";
+        string m = ":";
         if( m_mod & kModAlt )
-        {
-            modList += "alt,";
-        }
+            m += "alt,";
         if( m_mod & kModCtrl )
-        {
-            modList += "ctrl,";
-        }
+            m += "ctrl,";
         if( m_mod & kModShift )
-        {
-            modList += "shift,";
-        }
-        // Remove the last ','
-        modList = modList.substr( 0, modList.size() - 1 );
-        rEvtString += modList;
+            m += "shift,";
+        // Append the result except the last ','
+        rEvtString.insert( rEvtString.end(), m.begin(), m.end()-1 );
     }
 }
diff --git a/modules/gui/skins2/events/evt_input.hpp b/modules/gui/skins2/events/evt_input.hpp
index 1656d8f..a001c0e 100644
--- a/modules/gui/skins2/events/evt_input.hpp
+++ b/modules/gui/skins2/events/evt_input.hpp
@@ -35,10 +35,7 @@ public:
     virtual ~EvtInput() { }
 
     /// Masks for modifier keys
-    static const int kModNone;
-    static const int kModAlt;
-    static const int kModCtrl;
-    static const int kModShift;
+    enum { kModNone=0, kModAlt=1, kModCtrl=2, kModShift=4 };
 
     /// Get the modifiers
     virtual int getMod() const { return m_mod; }




More information about the vlc-devel mailing list