Replaced sub_nb class in mr.h by boost::dynamic_bitset
[libdai.git] / src / properties.cpp
index 2b131b3..9166b32 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <iostream>
 #include <dai/properties.h>
-#include <dai/alldai.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -40,36 +40,8 @@ std::ostream& operator<< (std::ostream & os, const Property & p) {
         os << boost::any_cast<bool>(p.second);
     else if( p.second.type() == typeid(PropertySet) )
         os << boost::any_cast<PropertySet>(p.second);
-#ifdef WITH_BP
-    else if( p.second.type() == typeid(BP::Properties::UpdateType) )
-        os << boost::any_cast<BP::Properties::UpdateType>(p.second);
-#endif
-#ifdef WITH_HAK
-    else if( p.second.type() == typeid(HAK::Properties::ClustersType) )
-        os << boost::any_cast<HAK::Properties::ClustersType>(p.second);
-#endif
-#ifdef WITH_JTREE
-    else if( p.second.type() == typeid(JTree::Properties::UpdateType) )
-        os << boost::any_cast<JTree::Properties::UpdateType>(p.second);
-#endif
-#ifdef WITH_MR
-    else if( p.second.type() == typeid(MR::Properties::UpdateType) )
-        os << boost::any_cast<MR::Properties::UpdateType>(p.second);
-    else if( p.second.type() == typeid(MR::Properties::InitType) )
-        os << boost::any_cast<MR::Properties::InitType>(p.second);
-#endif
-#ifdef WITH_TREEEP
-    else if( p.second.type() == typeid(TreeEP::Properties::TypeType) )
-        os << boost::any_cast<TreeEP::Properties::TypeType>(p.second);
-#endif
-#ifdef WITH_LC
-    else if( p.second.type() == typeid(LC::Properties::CavityType) )
-        os << boost::any_cast<LC::Properties::CavityType>(p.second);
-    else if( p.second.type() == typeid(LC::Properties::UpdateType) )
-        os << boost::any_cast<LC::Properties::UpdateType>(p.second);
-#endif
     else
-        throw "Unknown property type";
+        DAI_THROW(UNKNOWN_PROPERTY_TYPE);
     return( os );
 }
 
@@ -96,7 +68,7 @@ std::istream& operator >> (std::istream& is, PropertySet & ps) {
 
     // Check whether s is of the form "[.*]"
     if( (s.length() < 2) || (s.at(0) != '[') || (s.at(s.length()-1)) != ']' )
-        throw "Malformed property";
+        DAI_THROW(MALFORMED_PROPERTY);
 
     size_t N = s.length() - 1;
     for( size_t token_start = 1; token_start < N; ) {
@@ -107,7 +79,7 @@ std::istream& operator >> (std::istream& is, PropertySet & ps) {
             if( s[token_end] == '=' )
                 break;
         if( token_end == N )
-            throw "Malformed property key";
+            DAI_THROW(MALFORMED_PROPERTY);
         // we found a key
         std::string key = s.substr(token_start, token_end - token_start);
 
@@ -123,7 +95,7 @@ std::istream& operator >> (std::istream& is, PropertySet & ps) {
                 break;
         }
         if( !(level == 0) )
-            throw "Malformed property value";
+            DAI_THROW(MALFORMED_PROPERTY);
         // we found a vlue
         std::string value = s.substr(token_start, token_end - token_start);