SSPCPP-616 - fix tuple namespaces and string literal errors
[shibboleth/cpp-sp.git] / shibsp / attribute / resolver / impl / MetadataAttributeExtractor.cpp
index 0244d17..3a4ed59 100644 (file)
@@ -96,8 +96,8 @@ namespace shibsp {
             m_orgName,
             m_orgDisplayName,
             m_orgURL;
-        typedef tuple< string,xstring,boost::shared_ptr<AttributeDecoder> > contact_tuple_t;
-        typedef tuple< string,int,int,boost::shared_ptr<AttributeDecoder> > logo_tuple_t;
+        typedef boost::tuple< string,xstring,boost::shared_ptr<AttributeDecoder> > contact_tuple_t;
+        typedef boost::tuple< string,int,int,boost::shared_ptr<AttributeDecoder> > logo_tuple_t;
         vector<contact_tuple_t> m_contacts; // tuple is attributeID, contact type, decoder
         vector<logo_tuple_t> m_logos;       // tuple is attributeID, height, width, decoder
 
@@ -173,11 +173,10 @@ void MetadataExtractor::getAttributeIds(vector<string>& attributes) const
         attributes.push_back(m_orgDisplayName);
     if (!m_orgURL.empty())
         attributes.push_back(m_orgURL);
-    static void (vector<string>::* push_back)(const string&) = &vector<string>::push_back;
-    static const string& (contact_tuple_t::* tget)() const = &contact_tuple_t::get<0>;
-    static const string& (logo_tuple_t::* tget2)() const = &logo_tuple_t::get<0>;
-    for_each(m_contacts.begin(), m_contacts.end(), boost::bind(push_back, boost::ref(attributes), boost::bind(tget, _1)));
-    for_each(m_logos.begin(), m_logos.end(), boost::bind(push_back, boost::ref(attributes), boost::bind(tget2, _1)));
+    for (vector<contact_tuple_t>::const_iterator c = m_contacts.begin(); c != m_contacts.end(); ++c)
+        attributes.push_back(c->get<0>());
+    for (vector<logo_tuple_t>::const_iterator l = m_logos.begin(); l != m_logos.end(); ++l)
+        attributes.push_back(l->get<0>());
 }
 
 void MetadataExtractor::extractAttributes(
@@ -289,7 +288,7 @@ template <class T> void MetadataExtractor::doLangSensitive(
     if (!match)
         match = objects.front();
 
-    auto_ptr_char temp(match->getTextContent());
+    auto_arrayptr<char> temp(toUTF8(match->getTextContent()));
     if (temp.get() && *temp.get()) {
         auto_ptr<SimpleAttribute> attr(new SimpleAttribute(vector<string>(1, id)));
         attr->getValues().push_back(temp.get());
@@ -311,11 +310,11 @@ void MetadataExtractor::doLogo(
     if (request && request->startLangMatching()) {
         do {
             for (vector<Logo*>::const_iterator i = logos.begin(); i != logos.end(); ++i) {
-                if (request->matchLang((*i)->getLang())) {
+                if (!(*i)->getLang() || request->matchLang((*i)->getLang())) {
                     sizediff = 0;
                     if (h > 0) {
                         dim = (*i)->getHeight();
-                        sizediff = abs(h - dim.second);
+                        sizediff += abs(h - dim.second);
                     }
                     if (w > 0) {
                         dim = (*i)->getWidth();
@@ -338,7 +337,7 @@ void MetadataExtractor::doLogo(
             sizediff = 0;
             if (h > 0) {
                 dim = (*i)->getHeight();
-                sizediff = abs(h - dim.second);
+                sizediff += abs(h - dim.second);
             }
             if (w > 0) {
                 dim = (*i)->getWidth();