Parcourir la source

FIX: EventBus:: Cleared up typedefs

ctkLDAPSearchFilter::Dictionary is now ctkDictionary and
ctkInvalidSyntaxException has been removed and std::invalid_argument
is being used directly.
Sascha Zelzer il y a 14 ans
Parent
commit
a2be3ae38d

+ 3 - 3
Libs/PluginFramework/EventBus/ctkEvent.cpp

@@ -6,7 +6,7 @@ class ctkEventPrivate {
 
 public:
 
-  ctkEventPrivate(const QString& topic, const ctkLDAPSearchFilter::Dictionary& properties)
+  ctkEventPrivate(const QString& topic, const ctkDictionary& properties)
     : ref(1), topic(topic), properties(properties)
   {
 
@@ -14,12 +14,12 @@ public:
 
   QAtomicInt ref;
   const QString topic;
-  const ctkLDAPSearchFilter::Dictionary properties;
+  const ctkDictionary properties;
 
 };
 
 
-ctkEvent::ctkEvent(const QString& topic, const ctkLDAPSearchFilter::Dictionary& properties)
+ctkEvent::ctkEvent(const QString& topic, const ctkDictionary& properties)
   : d(new ctkEventPrivate(topic, properties))
 {
 

+ 1 - 1
Libs/PluginFramework/EventBus/ctkEvent.h

@@ -19,7 +19,7 @@
     typedef QMap<QString, QVariant> Properties;
 
     //TODO: what are we doing about malformed topic strings? Use exceptions in CTK?
-    ctkEvent(const QString& topic, const ctkLDAPSearchFilter::Dictionary& properties = Properties());
+    ctkEvent(const QString& topic, const ctkDictionary& properties = ctkDictionary());
     ctkEvent(const ctkEvent& event);
     ~ctkEvent();
 

+ 3 - 3
Libs/PluginFramework/Testing/Cpp/ctkLDAPExpreTest.cpp

@@ -61,7 +61,7 @@ int TestParsing( )
     ldap = ctkLDAPExpr( "(o=univ*of*mich*)" );
     ldap = ctkLDAPExpr( "(cn=Babs Jensen)" );
   }
-  catch ( ctkInvalidSyntaxException &e )
+  catch ( std::invalid_argument &e )
   {
     std::cerr << e.what() << std::endl;
     return EXIT_FAILURE;
@@ -74,7 +74,7 @@ int TestParsing( )
     ctkLDAPExpr ldap( "cn=Babs Jensen)" );
     return EXIT_FAILURE;
   }
-  catch ( ctkInvalidSyntaxException &e )
+  catch ( std::invalid_argument &e )
   {
     // Nothing to do
     int i = 0;
@@ -135,7 +135,7 @@ int TestEvaluate( )
       return EXIT_FAILURE;
     }
   }
-  catch ( ctkInvalidSyntaxException &e )
+  catch ( std::invalid_argument &e )
   {
     std::cerr << e.what() << std::endl;
     return EXIT_FAILURE;

+ 7 - 7
Libs/PluginFramework/ctkLDAPExpr.cpp

@@ -31,7 +31,7 @@ const QString ctkLDAPExpr::EOS       = "Unexpected end of query";
 const QString ctkLDAPExpr::MALFORMED = "Malformed query";
 const QString ctkLDAPExpr::OPERATOR  = "Undefined operator";
 
-ctkLDAPExpr::ctkLDAPExpr( const QString &filter ) throw (ctkInvalidSyntaxException)
+ctkLDAPExpr::ctkLDAPExpr( const QString &filter ) throw (std::invalid_argument)
 {
   ParseState ps(filter);
   try {
@@ -124,7 +124,7 @@ bool ctkLDAPExpr::isSimple(
   return false;
 }
 
-bool ctkLDAPExpr::query( const QString &filter, const ctkDictionary &pd ) throw (ctkInvalidSyntaxException)
+bool ctkLDAPExpr::query( const QString &filter, const ctkDictionary &pd ) throw (std::invalid_argument)
 {
   return ctkLDAPExpr(filter).evaluate(pd, false);
 }
@@ -289,7 +289,7 @@ bool ctkLDAPExpr::patSubstr( const QString &s, const QString &pat )
   return s.isNull() ? false : patSubstr(s,0,pat,0);
 }
 
-ctkLDAPExpr ctkLDAPExpr::parseExpr( ParseState &ps ) throw (ctkInvalidSyntaxException)
+ctkLDAPExpr ctkLDAPExpr::parseExpr( ParseState &ps ) throw (std::invalid_argument)
 {
   ps.skipWhite();
   if (!ps.prefix("("))
@@ -320,7 +320,7 @@ ctkLDAPExpr ctkLDAPExpr::parseExpr( ParseState &ps ) throw (ctkInvalidSyntaxExce
   return ctkLDAPExpr(op, v);
 }
 
-ctkLDAPExpr ctkLDAPExpr::parseSimple( ParseState &ps ) throw (ctkInvalidSyntaxException)
+ctkLDAPExpr ctkLDAPExpr::parseSimple( ParseState &ps ) throw (std::invalid_argument)
 {
   QString attrName = ps.getAttributeName();
   if (attrName.isNull())
@@ -393,7 +393,7 @@ const QString ctkLDAPExpr::toQString() const
   return res;
 }
 
-ctkLDAPExpr::ParseState::ParseState( const QString &str ) throw (ctkInvalidSyntaxException)
+ctkLDAPExpr::ParseState::ParseState( const QString &str ) throw (std::invalid_argument)
 {
   m_str = str;
   if (m_str.length() == 0)
@@ -484,8 +484,8 @@ const QString ctkLDAPExpr::ParseState::getAttributeValue()
   return sb;
 }
 
-void ctkLDAPExpr::ParseState::error( const QString &m ) throw (ctkInvalidSyntaxException)
+void ctkLDAPExpr::ParseState::error( const QString &m ) throw (std::invalid_argument)
 {
   QString error = m + ": " + (m_str.isNull() ? "" : m_str.mid(m_pos) );
-  throw ctkInvalidSyntaxException( error.toStdString() );
+  throw std::invalid_argument( error.toStdString() );
 }

+ 9 - 11
Libs/PluginFramework/ctkLDAPExpr.h

@@ -20,6 +20,8 @@ limitations under the License.
 =============================================================================*/
 
 #include "ctkPluginConstants.h"
+#include "ctkPluginFramework_global.h"
+
 #include <exception>
 
 #include <QString>
@@ -28,10 +30,6 @@ limitations under the License.
 
 #include <stdexcept>
 
-
-
-typedef std::invalid_argument ctkInvalidSyntaxException;
-typedef QHash< QString, QVariant > ctkDictionary;
 class ctkLDAPExprData;
 
 /**
@@ -56,7 +54,7 @@ public:
 
 public:
   //!
-  ctkLDAPExpr(const QString &filter) throw ( ctkInvalidSyntaxException );
+  ctkLDAPExpr(const QString &filter) throw ( std::invalid_argument );
 
   //!
   ctkLDAPExpr(const ctkLDAPExpr& other);
@@ -65,7 +63,7 @@ public:
    * Get object class set matched by this LDAP expression. This will not work
    * with wildcards and NOT expressions. If a set can not be determined return null.
    *
-   * @return std::set of classes matched, otherwise <code>null</code>.
+   * @return A set of classes matched, otherwise an empty set.
    */
   QSet<QString> getMatchedObjectClasses() const;
 
@@ -99,7 +97,7 @@ public:
 
   //! 
   static bool query(const QString &filter, const ctkDictionary &pd)
-    throw (ctkInvalidSyntaxException);
+      throw (std::invalid_argument);
 
   //! Evaluate this LDAP filter.
   bool evaluate(const ctkDictionary &p, bool matchCase) const;
@@ -130,7 +128,7 @@ private:
     QString m_str;
 
   public:
-    ParseState(const QString &str) throw (ctkInvalidSyntaxException);
+    ParseState(const QString &str) throw (std::invalid_argument);
 
     //! Move m_pos to remove the prefix \a pre
     bool prefix(const QString &pre);
@@ -156,17 +154,17 @@ private:
     const QString getAttributeValue();
 
     //! Throw InvalidSyntaxException exception
-    void error(const QString &m) throw (ctkInvalidSyntaxException);
+    void error(const QString &m) throw (std::invalid_argument);
 
   };
 
   //!
   static ctkLDAPExpr parseExpr(ParseState &ps)
-    throw (ctkInvalidSyntaxException);
+    throw (std::invalid_argument);
 
   //!
   static ctkLDAPExpr parseSimple(ParseState &ps)
-    throw (ctkInvalidSyntaxException);
+    throw (std::invalid_argument);
 
 private:
   //!

+ 2 - 2
Libs/PluginFramework/ctkLDAPSearchFilter.cpp

@@ -52,12 +52,12 @@ ctkLDAPSearchFilter::~ctkLDAPSearchFilter()
     delete d;
 }
 
-bool ctkLDAPSearchFilter::match(const Dictionary& dictionary) const
+bool ctkLDAPSearchFilter::match(const ctkDictionary& dictionary) const
 {
   return d->ldapExpr.evaluate(dictionary, false);
 }
 
-bool ctkLDAPSearchFilter::matchCase(const Dictionary& dictionary) const
+bool ctkLDAPSearchFilter::matchCase(const ctkDictionary& dictionary) const
 {
   return d->ldapExpr.evaluate(dictionary, true);
 }

+ 4 - 4
Libs/PluginFramework/ctkLDAPSearchFilter.h

@@ -24,6 +24,8 @@
 
 #include "CTKPluginFrameworkExport.h"
 
+#include "ctkPluginFramework_global.h"
+
 #include <QMap>
 #include <QString>
 #include <QVariant>
@@ -34,15 +36,13 @@ class CTK_PLUGINFW_EXPORT ctkLDAPSearchFilter {
 
 public:
 
-  typedef QMap<QString, QVariant> Dictionary;
-
   ctkLDAPSearchFilter(const QString& filter = "");
   ctkLDAPSearchFilter(const ctkLDAPSearchFilter& filter);
 
   ~ctkLDAPSearchFilter();
 
-  bool match(const Dictionary& dictionary) const;
-  bool matchCase(const Dictionary& dictionary) const;
+  bool match(const ctkDictionary& dictionary) const;
+  bool matchCase(const ctkDictionary& dictionary) const;
 
   bool operator==(const ctkLDAPSearchFilter& other) const;
   ctkLDAPSearchFilter& operator=(const ctkLDAPSearchFilter& filter);

+ 1 - 1
Libs/PluginFramework/ctkPluginFramework_global.h

@@ -27,6 +27,6 @@
 
 
 typedef QHash<QString, QVariant> ServiceProperties;
-
+typedef QHash<QString, QVariant> ctkDictionary;
 
 #endif // CTKPLUGINFRAMEWORK_GLOBAL_H